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 testcase.gui.sc.rowcolumn; 22 23 import static org.junit.Assert.*; 24 import static testlib.gui.AppUtil.typeKeys; 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 32 import testlib.gui.CalcUtil; 33 import testlib.gui.Log; 34 35 public class InsertRowAndColumn { 36 37 @Rule 38 public Log LOG = new Log(); 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 * @throws Exception 55 */ 56 57 @Test 58 public void testInsertEntireRowColumn(){ 59 60 //insert data in cell A2 and B2 61 CalcUtil.selectRange("Sheet1.A2"); 62 typeKeys("123"); 63 CalcUtil.selectRange("Sheet1.B2"); 64 typeKeys("456"); 65 66 //Set expected result after executing insert one row 67 String[][] expectedInsertRowResult = new String[][] { 68 {"",""}, 69 {"",""}, 70 {"123","456"}, 71 }; 72 73 //Select Cell A2 74 CalcUtil.selectRange("Sheet1.A2"); 75 76 77 78 //Insert one entire Row via menu 79 calc.menuItem("Insert->Rows").select(); 80 81 //Verify results after inserting one row 82 assertArrayEquals("Verify results after inserting one row", expectedInsertRowResult, CalcUtil.getCellTexts("A1:B3")); 83 84 //Set expected result after executing insert column 85 String[][] expectedInsertColumnResult = new String[][] { 86 {"","",""}, 87 {"","",""}, 88 {"","123","456"}, 89 }; 90 //Select Cell A3 91 CalcUtil.selectRange("Sheet1.A3"); 92 93 //Insert one entire Column via menu 94 calc.menuItem("Insert->Columns").select(); 95 96 //Verify results after inserting one column 97 assertArrayEquals("Verify results after inserting one column", expectedInsertColumnResult, CalcUtil.getCellTexts("A1:C3")); 98 99 } 100 101 } 102