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