xref: /AOO41X/test/testgui/source/fvt/gui/sc/rowcolumn/InsertRowAndColumn.java (revision 80a6f5c575dba650469ea4eacf1c8652e4eec583)
1*80a6f5c5SLiu Zhe /**************************************************************
2*80a6f5c5SLiu Zhe  *
3*80a6f5c5SLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
4*80a6f5c5SLiu Zhe  * or more contributor license agreements.  See the NOTICE file
5*80a6f5c5SLiu Zhe  * distributed with this work for additional information
6*80a6f5c5SLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
7*80a6f5c5SLiu Zhe  * to you under the Apache License, Version 2.0 (the
8*80a6f5c5SLiu Zhe  * "License"); you may not use this file except in compliance
9*80a6f5c5SLiu Zhe  * with the License.  You may obtain a copy of the License at
10*80a6f5c5SLiu Zhe  *
11*80a6f5c5SLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
12*80a6f5c5SLiu Zhe  *
13*80a6f5c5SLiu Zhe  * Unless required by applicable law or agreed to in writing,
14*80a6f5c5SLiu Zhe  * software distributed under the License is distributed on an
15*80a6f5c5SLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*80a6f5c5SLiu Zhe  * KIND, either express or implied.  See the License for the
17*80a6f5c5SLiu Zhe  * specific language governing permissions and limitations
18*80a6f5c5SLiu Zhe  * under the License.
19*80a6f5c5SLiu Zhe  *
20*80a6f5c5SLiu Zhe  *************************************************************/
21*80a6f5c5SLiu Zhe package fvt.gui.sc.rowcolumn;
22*80a6f5c5SLiu Zhe 
23*80a6f5c5SLiu Zhe import static org.junit.Assert.*;
24*80a6f5c5SLiu Zhe import static testlib.gui.AppTool.*;
25*80a6f5c5SLiu Zhe import static testlib.gui.UIMap.*;
26*80a6f5c5SLiu Zhe 
27*80a6f5c5SLiu Zhe import org.junit.After;
28*80a6f5c5SLiu Zhe import org.junit.Before;
29*80a6f5c5SLiu Zhe import org.junit.Rule;
30*80a6f5c5SLiu Zhe import org.junit.Test;
31*80a6f5c5SLiu Zhe import org.openoffice.test.common.Logger;
32*80a6f5c5SLiu Zhe 
33*80a6f5c5SLiu Zhe import testlib.gui.SCTool;
34*80a6f5c5SLiu Zhe 
35*80a6f5c5SLiu Zhe public class InsertRowAndColumn {
36*80a6f5c5SLiu Zhe 
37*80a6f5c5SLiu Zhe 	@Rule
38*80a6f5c5SLiu Zhe 	public Logger log = Logger.getLogger(this);
39*80a6f5c5SLiu Zhe 
40*80a6f5c5SLiu Zhe 	@Before
41*80a6f5c5SLiu Zhe 	public void setUp() throws Exception {
42*80a6f5c5SLiu Zhe 		app.start();
43*80a6f5c5SLiu Zhe 		app.dispatch("private:factory/scalc");
44*80a6f5c5SLiu Zhe 		calc.waitForExistence(10, 3);
45*80a6f5c5SLiu Zhe 	}
46*80a6f5c5SLiu Zhe 
47*80a6f5c5SLiu Zhe 	@After
48*80a6f5c5SLiu Zhe 	public void tearDown() throws Exception {
49*80a6f5c5SLiu Zhe 		app.close();
50*80a6f5c5SLiu Zhe 	}
51*80a6f5c5SLiu Zhe 
52*80a6f5c5SLiu Zhe 	/**
53*80a6f5c5SLiu Zhe 	 * Insert new entire row and column
54*80a6f5c5SLiu Zhe 	 *
55*80a6f5c5SLiu Zhe 	 * @throws Exception
56*80a6f5c5SLiu Zhe 	 */
57*80a6f5c5SLiu Zhe 
58*80a6f5c5SLiu Zhe 	@Test
59*80a6f5c5SLiu Zhe 	public void testInsertEntireRowColumn() {
60*80a6f5c5SLiu Zhe 
61*80a6f5c5SLiu Zhe 		// insert data in cell A2 and B2
62*80a6f5c5SLiu Zhe 		SCTool.selectRange("Sheet1.A2");
63*80a6f5c5SLiu Zhe 		typeKeys("123");
64*80a6f5c5SLiu Zhe 		SCTool.selectRange("Sheet1.B2");
65*80a6f5c5SLiu Zhe 		typeKeys("456");
66*80a6f5c5SLiu Zhe 
67*80a6f5c5SLiu Zhe 		// Set expected result after executing insert one row
68*80a6f5c5SLiu Zhe 		String[][] expectedInsertRowResult = new String[][] { { "", "" }, { "", "" }, { "123", "456" }, };
69*80a6f5c5SLiu Zhe 
70*80a6f5c5SLiu Zhe 		// Select Cell A2
71*80a6f5c5SLiu Zhe 		SCTool.selectRange("Sheet1.A2");
72*80a6f5c5SLiu Zhe 
73*80a6f5c5SLiu Zhe 		// Insert one entire Row via menu
74*80a6f5c5SLiu Zhe 		calc.menuItem("Insert->Rows").select();
75*80a6f5c5SLiu Zhe 
76*80a6f5c5SLiu Zhe 		// Verify results after inserting one row
77*80a6f5c5SLiu Zhe 		assertArrayEquals("Verify results after inserting one row", expectedInsertRowResult, SCTool.getCellTexts("A1:B3"));
78*80a6f5c5SLiu Zhe 
79*80a6f5c5SLiu Zhe 		// Set expected result after executing insert column
80*80a6f5c5SLiu Zhe 		String[][] expectedInsertColumnResult = new String[][] { { "", "", "" }, { "", "", "" }, { "", "123", "456" }, };
81*80a6f5c5SLiu Zhe 		// Select Cell A3
82*80a6f5c5SLiu Zhe 		SCTool.selectRange("Sheet1.A3");
83*80a6f5c5SLiu Zhe 
84*80a6f5c5SLiu Zhe 		// Insert one entire Column via menu
85*80a6f5c5SLiu Zhe 		calc.menuItem("Insert->Columns").select();
86*80a6f5c5SLiu Zhe 
87*80a6f5c5SLiu Zhe 		// Verify results after inserting one column
88*80a6f5c5SLiu Zhe 		assertArrayEquals("Verify results after inserting one column", expectedInsertColumnResult, SCTool.getCellTexts("A1:C3"));
89*80a6f5c5SLiu Zhe 
90*80a6f5c5SLiu Zhe 	}
91*80a6f5c5SLiu Zhe 
92*80a6f5c5SLiu Zhe }
93