View | Details | Raw Unified | Return to issue 120552
Collapse All | Expand All

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

Return to issue 120552