xref: /AOO41X/test/testgui/source/fvt/gui/sc/rowcolumn/InsertRowAndColumn.java (revision 424494b095bc90dc2fe31bd4233af124f1760355)
180a6f5c5SLiu Zhe /**************************************************************
280a6f5c5SLiu Zhe  *
380a6f5c5SLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
480a6f5c5SLiu Zhe  * or more contributor license agreements.  See the NOTICE file
580a6f5c5SLiu Zhe  * distributed with this work for additional information
680a6f5c5SLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
780a6f5c5SLiu Zhe  * to you under the Apache License, Version 2.0 (the
880a6f5c5SLiu Zhe  * "License"); you may not use this file except in compliance
980a6f5c5SLiu Zhe  * with the License.  You may obtain a copy of the License at
1080a6f5c5SLiu Zhe  *
1180a6f5c5SLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
1280a6f5c5SLiu Zhe  *
1380a6f5c5SLiu Zhe  * Unless required by applicable law or agreed to in writing,
1480a6f5c5SLiu Zhe  * software distributed under the License is distributed on an
1580a6f5c5SLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1680a6f5c5SLiu Zhe  * KIND, either express or implied.  See the License for the
1780a6f5c5SLiu Zhe  * specific language governing permissions and limitations
1880a6f5c5SLiu Zhe  * under the License.
1980a6f5c5SLiu Zhe  *
2080a6f5c5SLiu Zhe  *************************************************************/
2180a6f5c5SLiu Zhe package fvt.gui.sc.rowcolumn;
2280a6f5c5SLiu Zhe 
2380a6f5c5SLiu Zhe import static org.junit.Assert.*;
2480a6f5c5SLiu Zhe import static testlib.gui.AppTool.*;
2580a6f5c5SLiu Zhe import static testlib.gui.UIMap.*;
2680a6f5c5SLiu Zhe 
2780a6f5c5SLiu Zhe import org.junit.After;
2880a6f5c5SLiu Zhe import org.junit.Before;
2980a6f5c5SLiu Zhe import org.junit.Rule;
3080a6f5c5SLiu Zhe import org.junit.Test;
3180a6f5c5SLiu Zhe import org.openoffice.test.common.Logger;
3280a6f5c5SLiu Zhe 
33*424494b0SLi Feng Wang import testlib.gui.AppTool;
3480a6f5c5SLiu Zhe import testlib.gui.SCTool;
3580a6f5c5SLiu Zhe 
3680a6f5c5SLiu Zhe public class InsertRowAndColumn {
3780a6f5c5SLiu Zhe 
3880a6f5c5SLiu Zhe 	@Before
3980a6f5c5SLiu Zhe 	public void setUp() throws Exception {
4080a6f5c5SLiu Zhe 		app.start();
41*424494b0SLi Feng Wang 		AppTool.newSpreadsheet();
4280a6f5c5SLiu Zhe 	}
4380a6f5c5SLiu Zhe 
4480a6f5c5SLiu Zhe 	@After
4580a6f5c5SLiu Zhe 	public void tearDown() throws Exception {
46*424494b0SLi Feng Wang 		app.stop();
4780a6f5c5SLiu Zhe 	}
4880a6f5c5SLiu Zhe 
4980a6f5c5SLiu Zhe 	/**
5080a6f5c5SLiu Zhe 	 * Insert new entire row and column
5180a6f5c5SLiu Zhe 	 *
5280a6f5c5SLiu Zhe 	 * @throws Exception
5380a6f5c5SLiu Zhe 	 */
5480a6f5c5SLiu Zhe 
5580a6f5c5SLiu Zhe 	@Test
5680a6f5c5SLiu Zhe 	public void testInsertEntireRowColumn() {
5780a6f5c5SLiu Zhe 
5880a6f5c5SLiu Zhe 		// insert data in cell A2 and B2
5980a6f5c5SLiu Zhe 		SCTool.selectRange("Sheet1.A2");
6080a6f5c5SLiu Zhe 		typeKeys("123");
6180a6f5c5SLiu Zhe 		SCTool.selectRange("Sheet1.B2");
6280a6f5c5SLiu Zhe 		typeKeys("456");
6380a6f5c5SLiu Zhe 
6480a6f5c5SLiu Zhe 		// Set expected result after executing insert one row
6580a6f5c5SLiu Zhe 		String[][] expectedInsertRowResult = new String[][] { { "", "" }, { "", "" }, { "123", "456" }, };
6680a6f5c5SLiu Zhe 
6780a6f5c5SLiu Zhe 		// Select Cell A2
6880a6f5c5SLiu Zhe 		SCTool.selectRange("Sheet1.A2");
6980a6f5c5SLiu Zhe 
7080a6f5c5SLiu Zhe 		// Insert one entire Row via menu
7180a6f5c5SLiu Zhe 		calc.menuItem("Insert->Rows").select();
7280a6f5c5SLiu Zhe 
7380a6f5c5SLiu Zhe 		// Verify results after inserting one row
7480a6f5c5SLiu Zhe 		assertArrayEquals("Verify results after inserting one row", expectedInsertRowResult, SCTool.getCellTexts("A1:B3"));
7580a6f5c5SLiu Zhe 
7680a6f5c5SLiu Zhe 		// Set expected result after executing insert column
7780a6f5c5SLiu Zhe 		String[][] expectedInsertColumnResult = new String[][] { { "", "", "" }, { "", "", "" }, { "", "123", "456" }, };
7880a6f5c5SLiu Zhe 		// Select Cell A3
7980a6f5c5SLiu Zhe 		SCTool.selectRange("Sheet1.A3");
8080a6f5c5SLiu Zhe 		// Insert one entire Column via menu
8180a6f5c5SLiu Zhe 		calc.menuItem("Insert->Columns").select();
8280a6f5c5SLiu Zhe 
8380a6f5c5SLiu Zhe 		// Verify results after inserting one column
8480a6f5c5SLiu Zhe 		assertArrayEquals("Verify results after inserting one column", expectedInsertColumnResult, SCTool.getCellTexts("A1:C3"));
8580a6f5c5SLiu Zhe 
8680a6f5c5SLiu Zhe 	}
8780a6f5c5SLiu Zhe 
8880a6f5c5SLiu Zhe }
89