xref: /aoo41x/test/testgui/source/fvt/gui/sc/cell/Cells.java (revision fd348426)
107d7dbdcSHerbert Dürr /**************************************************************
207d7dbdcSHerbert Dürr  *
307d7dbdcSHerbert Dürr  * Licensed to the Apache Software Foundation (ASF) under one
407d7dbdcSHerbert Dürr  * or more contributor license agreements.  See the NOTICE file
507d7dbdcSHerbert Dürr  * distributed with this work for additional information
607d7dbdcSHerbert Dürr  * regarding copyright ownership.  The ASF licenses this file
707d7dbdcSHerbert Dürr  * to you under the Apache License, Version 2.0 (the
807d7dbdcSHerbert Dürr  * "License"); you may not use this file except in compliance
907d7dbdcSHerbert Dürr  * with the License.  You may obtain a copy of the License at
1007d7dbdcSHerbert Dürr  *
1107d7dbdcSHerbert Dürr  *   http://www.apache.org/licenses/LICENSE-2.0
1207d7dbdcSHerbert Dürr  *
1307d7dbdcSHerbert Dürr  * Unless required by applicable law or agreed to in writing,
1407d7dbdcSHerbert Dürr  * software distributed under the License is distributed on an
1507d7dbdcSHerbert Dürr  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1607d7dbdcSHerbert Dürr  * KIND, either express or implied.  See the License for the
1707d7dbdcSHerbert Dürr  * specific language governing permissions and limitations
1807d7dbdcSHerbert Dürr  * under the License.
1907d7dbdcSHerbert Dürr  *
2007d7dbdcSHerbert Dürr  *************************************************************/
2107d7dbdcSHerbert Dürr 
2280a6f5c5SLiu Zhe package fvt.gui.sc.cell;
23cb6ac572SLiu Zhe 
24cb6ac572SLiu Zhe import static org.junit.Assert.*;
25b4d2d410SLiu Zhe import static testlib.gui.AppTool.*;
26cb6ac572SLiu Zhe import static testlib.gui.UIMap.*;
27cb6ac572SLiu Zhe 
28cb6ac572SLiu Zhe import org.junit.After;
29cb6ac572SLiu Zhe import org.junit.Before;
30*fd348426SLi Feng Wang import org.junit.Rule;
31cb6ac572SLiu Zhe import org.junit.Test;
32*fd348426SLi Feng Wang import org.openoffice.test.common.Logger;
33cb6ac572SLiu Zhe 
34424494b0SLi Feng Wang import testlib.gui.AppTool;
35b4d2d410SLiu Zhe import testlib.gui.SCTool;
36cb6ac572SLiu Zhe 
37cb6ac572SLiu Zhe 
38cb6ac572SLiu Zhe 
39424494b0SLi Feng Wang public class Cells {
40424494b0SLi Feng Wang 
41*fd348426SLi Feng Wang 	@Rule
42*fd348426SLi Feng Wang 	public Logger log = Logger.getLogger(this);
43*fd348426SLi Feng Wang 
44cb6ac572SLiu Zhe 	@Before
setUp()45cb6ac572SLiu Zhe 	public void setUp() throws Exception {
46cb6ac572SLiu Zhe 		app.start();
47424494b0SLi Feng Wang 		AppTool.newSpreadsheet();
48cb6ac572SLiu Zhe 	}
49cb6ac572SLiu Zhe 
50cb6ac572SLiu Zhe 	@After
tearDown()51cb6ac572SLiu Zhe 	public void tearDown() throws Exception {
52424494b0SLi Feng Wang 		app.stop();
53cb6ac572SLiu Zhe 	}
5422a14f28SLiu Zhe 
55cb6ac572SLiu Zhe 	/**
56cb6ac572SLiu Zhe 	 * Shift row and column, insert entire row and column
5722a14f28SLiu Zhe 	 *
58cb6ac572SLiu Zhe 	 * @throws Exception
59cb6ac572SLiu Zhe 	 */
6022a14f28SLiu Zhe 
61cb6ac572SLiu Zhe 	@Test
testShiftRowandColumn()6222a14f28SLiu Zhe 	public void testShiftRowandColumn() {
6322a14f28SLiu Zhe 
6422a14f28SLiu Zhe 		// Input data to cell range A1:B2
65b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
66cb6ac572SLiu Zhe 		typeKeys("1<right>2<down><left>3<right>4");
6722a14f28SLiu Zhe 		// Set expected result after executing shift cell down
68424494b0SLi Feng Wang 		String[][] expectedShiftCellDownResult = new String[][] { { "", "2" },
69424494b0SLi Feng Wang 				{ "1", "4" }, { "3", "" }, };
7022a14f28SLiu Zhe 		// Select Cell A1
71b4d2d410SLiu Zhe 		SCTool.selectRange("Sheet1.A1");
7222a14f28SLiu Zhe 		// Launch insert cells dialog via menu
73cb6ac572SLiu Zhe 		calc.menuItem("Insert->Cells...").select();
7422a14f28SLiu Zhe 		// Select the first option "shift cells down" from dialog
75cb6ac572SLiu Zhe 		typeKeys("<enter>");
7622a14f28SLiu Zhe 		// 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"));
7922a14f28SLiu Zhe 		// Set expected result after executing shift cell right
80424494b0SLi Feng Wang 		String[][] expectedShiftCellRightResult = new String[][] {
81424494b0SLi Feng Wang 				{ "", "1", "2" }, { "3", "4", "" }, };
82cb6ac572SLiu Zhe 		// Undo
83cb6ac572SLiu Zhe 		calc.menuItem("Edit->Undo: Insert").select();
84424494b0SLi Feng Wang 
8522a14f28SLiu Zhe 		// Select cell B2
86b4d2d410SLiu Zhe 		SCTool.selectRange("Sheet1.A1");
8722a14f28SLiu Zhe 		// Launch insert cells dialog via menu
8822a14f28SLiu Zhe 		calc.menuItem("Insert->Cells...").select();
8922a14f28SLiu Zhe 		// Select the second option "shift cells right" from dialog
90cb6ac572SLiu Zhe 		typeKeys("<down>");
91cb6ac572SLiu Zhe 		typeKeys("<enter>");
9222a14f28SLiu Zhe 		// 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"));
9522a14f28SLiu Zhe 		// Set expected result after executing insert entire row
96424494b0SLi Feng Wang 		String[][] expectedEntireRowResult = new String[][] { { "", "" },
97424494b0SLi Feng Wang 				{ "1", "2" }, { "3", "4" }, };
9822a14f28SLiu Zhe 
99cb6ac572SLiu Zhe 		// Undo
100cb6ac572SLiu Zhe 		calc.menuItem("Edit->Undo: Insert").select();
10122a14f28SLiu Zhe 		// Select Cell B2
102b4d2d410SLiu Zhe 		SCTool.selectRange("Sheet1.A1");
10322a14f28SLiu Zhe 		// Launch insert cells dialog via menu
10422a14f28SLiu Zhe 		calc.menuItem("Insert->Cells...").select();
10522a14f28SLiu Zhe 
10622a14f28SLiu Zhe 		// Select the third option "Entire row" from dialog
107cb6ac572SLiu Zhe 		typeKeys("<down>");
108cb6ac572SLiu Zhe 		typeKeys("<enter>");
10922a14f28SLiu Zhe 
11022a14f28SLiu Zhe 		// Verify results after insert entire row
111424494b0SLi Feng Wang 		assertArrayEquals("Verify results after insert entire row",
112424494b0SLi Feng Wang 				expectedEntireRowResult, SCTool.getCellTexts("A1:B3"));
11322a14f28SLiu Zhe 
11422a14f28SLiu Zhe 		// Set expected result after executing insert entire column
115cb6ac572SLiu Zhe 		String[][] expectedEntireColumnResult = new String[][] {
11622a14f28SLiu Zhe 		{ "", "1", "2" }, { "", "3", "4" }, };
117cb6ac572SLiu Zhe 		// Undo
118cb6ac572SLiu Zhe 		calc.menuItem("Edit->Undo: Insert").select();
11922a14f28SLiu Zhe 
12022a14f28SLiu Zhe 		// Select Cell A1
121b4d2d410SLiu Zhe 		SCTool.selectRange("Sheet1.A1");
12222a14f28SLiu Zhe 
12322a14f28SLiu Zhe 		// Launch insert cells dialog via menu
12422a14f28SLiu Zhe 		calc.menuItem("Insert->Cells...").select();
12522a14f28SLiu Zhe 
12622a14f28SLiu Zhe 		// Select the fourth option "Entire column" from dialog
127cb6ac572SLiu Zhe 		typeKeys("<down>");
128cb6ac572SLiu Zhe 		typeKeys("<enter>");
12922a14f28SLiu Zhe 
13022a14f28SLiu Zhe 		// 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"));
13322a14f28SLiu Zhe 
134cb6ac572SLiu Zhe 	}
135cb6ac572SLiu Zhe 
136cb6ac572SLiu Zhe }
137