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