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.AppTool; 34 import testlib.gui.SCTool; 35 36 public class InsertRowAndColumn { 37 38 @Before 39 public void setUp() throws Exception { 40 app.start(); 41 AppTool.newSpreadsheet(); 42 } 43 44 @After 45 public void tearDown() throws Exception { 46 app.stop(); 47 } 48 49 /** 50 * Insert new entire row and column 51 * 52 * @throws Exception 53 */ 54 55 @Test 56 public void testInsertEntireRowColumn() { 57 58 // insert data in cell A2 and B2 59 SCTool.selectRange("Sheet1.A2"); 60 typeKeys("123"); 61 SCTool.selectRange("Sheet1.B2"); 62 typeKeys("456"); 63 64 // Set expected result after executing insert one row 65 String[][] expectedInsertRowResult = new String[][] { { "", "" }, { "", "" }, { "123", "456" }, }; 66 67 // Select Cell A2 68 SCTool.selectRange("Sheet1.A2"); 69 70 // Insert one entire Row via menu 71 calc.menuItem("Insert->Rows").select(); 72 73 // Verify results after inserting one row 74 assertArrayEquals("Verify results after inserting one row", expectedInsertRowResult, SCTool.getCellTexts("A1:B3")); 75 76 // Set expected result after executing insert column 77 String[][] expectedInsertColumnResult = new String[][] { { "", "", "" }, { "", "", "" }, { "", "123", "456" }, }; 78 // Select Cell A3 79 SCTool.selectRange("Sheet1.A3"); 80 // Insert one entire Column via menu 81 calc.menuItem("Insert->Columns").select(); 82 83 // Verify results after inserting one column 84 assertArrayEquals("Verify results after inserting one column", expectedInsertColumnResult, SCTool.getCellTexts("A1:C3")); 85 86 } 87 88 } 89