1424494b0SLi Feng Wang /************************************************************** 2424494b0SLi Feng Wang * 3424494b0SLi Feng Wang * Licensed to the Apache Software Foundation (ASF) under one 4424494b0SLi Feng Wang * or more contributor license agreements. See the NOTICE file 5424494b0SLi Feng Wang * distributed with this work for additional information 6424494b0SLi Feng Wang * regarding copyright ownership. The ASF licenses this file 7424494b0SLi Feng Wang * to you under the Apache License, Version 2.0 (the 8424494b0SLi Feng Wang * "License"); you may not use this file except in compliance 9424494b0SLi Feng Wang * with the License. You may obtain a copy of the License at 10424494b0SLi Feng Wang * 11424494b0SLi Feng Wang * http://www.apache.org/licenses/LICENSE-2.0 12424494b0SLi Feng Wang * 13424494b0SLi Feng Wang * Unless required by applicable law or agreed to in writing, 14424494b0SLi Feng Wang * software distributed under the License is distributed on an 15424494b0SLi Feng Wang * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16424494b0SLi Feng Wang * KIND, either express or implied. See the License for the 17424494b0SLi Feng Wang * specific language governing permissions and limitations 18424494b0SLi Feng Wang * under the License. 19424494b0SLi Feng Wang * 20424494b0SLi Feng Wang *************************************************************/ 21424494b0SLi Feng Wang 22424494b0SLi Feng Wang package fvt.gui.sc.cell; 23424494b0SLi Feng Wang 24424494b0SLi Feng Wang import static org.junit.Assert.*; 25424494b0SLi Feng Wang import static testlib.gui.AppTool.*; 26424494b0SLi Feng Wang import static testlib.gui.UIMap.*; 27424494b0SLi Feng Wang 28424494b0SLi Feng Wang import org.junit.After; 29424494b0SLi Feng Wang import org.junit.Before; 30*fd348426SLi Feng Wang import org.junit.Rule; 31424494b0SLi Feng Wang import org.junit.Test; 32*fd348426SLi Feng Wang import org.openoffice.test.common.Logger; 33424494b0SLi Feng Wang 34424494b0SLi Feng Wang import testlib.gui.AppTool; 35424494b0SLi Feng Wang import testlib.gui.SCTool; 36424494b0SLi Feng Wang 37424494b0SLi Feng Wang 38424494b0SLi Feng Wang 39424494b0SLi Feng Wang public class Cells { 40424494b0SLi Feng Wang 41*fd348426SLi Feng Wang @Rule 42*fd348426SLi Feng Wang public Logger log = Logger.getLogger(this); 43424494b0SLi Feng Wang 44424494b0SLi Feng Wang @Before setUp()45424494b0SLi Feng Wang public void setUp() throws Exception { 46424494b0SLi Feng Wang app.start(); 47424494b0SLi Feng Wang AppTool.newSpreadsheet(); 48424494b0SLi Feng Wang } 49424494b0SLi Feng Wang 50424494b0SLi Feng Wang @After tearDown()51424494b0SLi Feng Wang public void tearDown() throws Exception { 52424494b0SLi Feng Wang app.stop(); 53424494b0SLi Feng Wang } 54424494b0SLi Feng Wang 55424494b0SLi Feng Wang /** 56424494b0SLi Feng Wang * Shift row and column, insert entire row and column 57424494b0SLi Feng Wang * 58424494b0SLi Feng Wang * @throws Exception 59424494b0SLi Feng Wang */ 60424494b0SLi Feng Wang 61424494b0SLi Feng Wang @Test testShiftRowandColumn()62424494b0SLi Feng Wang public void testShiftRowandColumn() { 63424494b0SLi Feng Wang 64424494b0SLi Feng Wang // Input data to cell range A1:B2 65424494b0SLi Feng Wang SCTool.selectRange("A1"); 66424494b0SLi Feng Wang typeKeys("1<right>2<down><left>3<right>4"); 67424494b0SLi Feng Wang // Set expected result after executing shift cell down 68424494b0SLi Feng Wang String[][] expectedShiftCellDownResult = new String[][] { { "", "2" }, 69424494b0SLi Feng Wang { "1", "4" }, { "3", "" }, }; 70424494b0SLi Feng Wang // Select Cell A1 71424494b0SLi Feng Wang SCTool.selectRange("Sheet1.A1"); 72424494b0SLi Feng Wang // Launch insert cells dialog via menu 73424494b0SLi Feng Wang calc.menuItem("Insert->Cells...").select(); 74424494b0SLi Feng Wang // Select the first option "shift cells down" from dialog 75424494b0SLi Feng Wang typeKeys("<enter>"); 76424494b0SLi Feng Wang // Verify results after shift one cell down 77424494b0SLi Feng Wang assertArrayEquals("Verify results after shift one cell down", 78424494b0SLi Feng Wang expectedShiftCellDownResult, SCTool.getCellTexts("A1:B3")); 79424494b0SLi Feng Wang // Set expected result after executing shift cell right 80424494b0SLi Feng Wang String[][] expectedShiftCellRightResult = new String[][] { 81424494b0SLi Feng Wang { "", "1", "2" }, { "3", "4", "" }, }; 82424494b0SLi Feng Wang // Undo 83424494b0SLi Feng Wang calc.menuItem("Edit->Undo: Insert").select(); 84424494b0SLi Feng Wang 85424494b0SLi Feng Wang // Select cell B2 86424494b0SLi Feng Wang SCTool.selectRange("Sheet1.A1"); 87424494b0SLi Feng Wang // Launch insert cells dialog via menu 88424494b0SLi Feng Wang calc.menuItem("Insert->Cells...").select(); 89424494b0SLi Feng Wang // Select the second option "shift cells right" from dialog 90424494b0SLi Feng Wang typeKeys("<down>"); 91424494b0SLi Feng Wang typeKeys("<enter>"); 92424494b0SLi Feng Wang // Verify results after shift one cell right 93424494b0SLi Feng Wang assertArrayEquals("Verify results after shift one cell right", 94424494b0SLi Feng Wang expectedShiftCellRightResult, SCTool.getCellTexts("A1:C2")); 95424494b0SLi Feng Wang // Set expected result after executing insert entire row 96424494b0SLi Feng Wang String[][] expectedEntireRowResult = new String[][] { { "", "" }, 97424494b0SLi Feng Wang { "1", "2" }, { "3", "4" }, }; 98424494b0SLi Feng Wang 99424494b0SLi Feng Wang // Undo 100424494b0SLi Feng Wang calc.menuItem("Edit->Undo: Insert").select(); 101424494b0SLi Feng Wang // Select Cell B2 102424494b0SLi Feng Wang SCTool.selectRange("Sheet1.A1"); 103424494b0SLi Feng Wang // Launch insert cells dialog via menu 104424494b0SLi Feng Wang calc.menuItem("Insert->Cells...").select(); 105424494b0SLi Feng Wang 106424494b0SLi Feng Wang // Select the third option "Entire row" from dialog 107424494b0SLi Feng Wang typeKeys("<down>"); 108424494b0SLi Feng Wang typeKeys("<enter>"); 109424494b0SLi Feng Wang 110424494b0SLi Feng Wang // Verify results after insert entire row 111424494b0SLi Feng Wang assertArrayEquals("Verify results after insert entire row", 112424494b0SLi Feng Wang expectedEntireRowResult, SCTool.getCellTexts("A1:B3")); 113424494b0SLi Feng Wang 114424494b0SLi Feng Wang // Set expected result after executing insert entire column 115424494b0SLi Feng Wang String[][] expectedEntireColumnResult = new String[][] { 116424494b0SLi Feng Wang { "", "1", "2" }, { "", "3", "4" }, }; 117424494b0SLi Feng Wang // Undo 118424494b0SLi Feng Wang calc.menuItem("Edit->Undo: Insert").select(); 119424494b0SLi Feng Wang 120424494b0SLi Feng Wang // Select Cell A1 121424494b0SLi Feng Wang SCTool.selectRange("Sheet1.A1"); 122424494b0SLi Feng Wang 123424494b0SLi Feng Wang // Launch insert cells dialog via menu 124424494b0SLi Feng Wang calc.menuItem("Insert->Cells...").select(); 125424494b0SLi Feng Wang 126424494b0SLi Feng Wang // Select the fourth option "Entire column" from dialog 127424494b0SLi Feng Wang typeKeys("<down>"); 128424494b0SLi Feng Wang typeKeys("<enter>"); 129424494b0SLi Feng Wang 130424494b0SLi Feng Wang // Verify the results after inserting entire column 131424494b0SLi Feng Wang assertArrayEquals("Verify the results after inserting entire column", 132424494b0SLi Feng Wang expectedEntireColumnResult, SCTool.getCellTexts("A1:C2")); 133424494b0SLi Feng Wang 134424494b0SLi Feng Wang } 135424494b0SLi Feng Wang 136424494b0SLi Feng Wang } 137