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