xref: /trunk/test/testgui/source/fvt/gui/sc/cell/Cells.java (revision fd348426)
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 
22 package fvt.gui.sc.cell;
23 
24 import static org.junit.Assert.*;
25 import static testlib.gui.AppTool.*;
26 import static testlib.gui.UIMap.*;
27 
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Rule;
31 import org.junit.Test;
32 import org.openoffice.test.common.Logger;
33 
34 import testlib.gui.AppTool;
35 import testlib.gui.SCTool;
36 
37 
38 
39 public class Cells {
40 
41 	@Rule
42 	public Logger log = Logger.getLogger(this);
43 
44 	@Before
setUp()45 	public void setUp() throws Exception {
46 		app.start();
47 		AppTool.newSpreadsheet();
48 	}
49 
50 	@After
tearDown()51 	public void tearDown() throws Exception {
52 		app.stop();
53 	}
54 
55 	/**
56 	 * Shift row and column, insert entire row and column
57 	 *
58 	 * @throws Exception
59 	 */
60 
61 	@Test
testShiftRowandColumn()62 	public void testShiftRowandColumn() {
63 
64 		// Input data to cell range A1:B2
65 		SCTool.selectRange("A1");
66 		typeKeys("1<right>2<down><left>3<right>4");
67 		// Set expected result after executing shift cell down
68 		String[][] expectedShiftCellDownResult = new String[][] { { "", "2" },
69 				{ "1", "4" }, { "3", "" }, };
70 		// Select Cell A1
71 		SCTool.selectRange("Sheet1.A1");
72 		// Launch insert cells dialog via menu
73 		calc.menuItem("Insert->Cells...").select();
74 		// Select the first option "shift cells down" from dialog
75 		typeKeys("<enter>");
76 		// Verify results after shift one cell down
77 		assertArrayEquals("Verify results after shift one cell down",
78 				expectedShiftCellDownResult, SCTool.getCellTexts("A1:B3"));
79 		// Set expected result after executing shift cell right
80 		String[][] expectedShiftCellRightResult = new String[][] {
81 				{ "", "1", "2" }, { "3", "4", "" }, };
82 		// Undo
83 		calc.menuItem("Edit->Undo: Insert").select();
84 
85 		// Select cell B2
86 		SCTool.selectRange("Sheet1.A1");
87 		// Launch insert cells dialog via menu
88 		calc.menuItem("Insert->Cells...").select();
89 		// Select the second option "shift cells right" from dialog
90 		typeKeys("<down>");
91 		typeKeys("<enter>");
92 		// Verify results after shift one cell right
93 		assertArrayEquals("Verify results after shift one cell right",
94 				expectedShiftCellRightResult, SCTool.getCellTexts("A1:C2"));
95 		// Set expected result after executing insert entire row
96 		String[][] expectedEntireRowResult = new String[][] { { "", "" },
97 				{ "1", "2" }, { "3", "4" }, };
98 
99 		// Undo
100 		calc.menuItem("Edit->Undo: Insert").select();
101 		// Select Cell B2
102 		SCTool.selectRange("Sheet1.A1");
103 		// Launch insert cells dialog via menu
104 		calc.menuItem("Insert->Cells...").select();
105 
106 		// Select the third option "Entire row" from dialog
107 		typeKeys("<down>");
108 		typeKeys("<enter>");
109 
110 		// Verify results after insert entire row
111 		assertArrayEquals("Verify results after insert entire row",
112 				expectedEntireRowResult, SCTool.getCellTexts("A1:B3"));
113 
114 		// Set expected result after executing insert entire column
115 		String[][] expectedEntireColumnResult = new String[][] {
116 		{ "", "1", "2" }, { "", "3", "4" }, };
117 		// Undo
118 		calc.menuItem("Edit->Undo: Insert").select();
119 
120 		// Select Cell A1
121 		SCTool.selectRange("Sheet1.A1");
122 
123 		// Launch insert cells dialog via menu
124 		calc.menuItem("Insert->Cells...").select();
125 
126 		// Select the fourth option "Entire column" from dialog
127 		typeKeys("<down>");
128 		typeKeys("<enter>");
129 
130 		// Verify the results after inserting entire column
131 		assertArrayEquals("Verify the results after inserting entire column",
132 				expectedEntireColumnResult, SCTool.getCellTexts("A1:C2"));
133 
134 	}
135 
136 }
137