xref: /AOO41X/test/testuno/source/fvt/uno/sc/cell/InsertDeleteCells.java (revision 07d7dbdcb8e526dfaf85923a181c45494526d79d)
1*07d7dbdcSHerbert Dürr /**************************************************************
2*07d7dbdcSHerbert Dürr  *
3*07d7dbdcSHerbert Dürr  * Licensed to the Apache Software Foundation (ASF) under one
4*07d7dbdcSHerbert Dürr  * or more contributor license agreements.  See the NOTICE file
5*07d7dbdcSHerbert Dürr  * distributed with this work for additional information
6*07d7dbdcSHerbert Dürr  * regarding copyright ownership.  The ASF licenses this file
7*07d7dbdcSHerbert Dürr  * to you under the Apache License, Version 2.0 (the
8*07d7dbdcSHerbert Dürr  * "License"); you may not use this file except in compliance
9*07d7dbdcSHerbert Dürr  * with the License.  You may obtain a copy of the License at
10*07d7dbdcSHerbert Dürr  *
11*07d7dbdcSHerbert Dürr  *   http://www.apache.org/licenses/LICENSE-2.0
12*07d7dbdcSHerbert Dürr  *
13*07d7dbdcSHerbert Dürr  * Unless required by applicable law or agreed to in writing,
14*07d7dbdcSHerbert Dürr  * software distributed under the License is distributed on an
15*07d7dbdcSHerbert Dürr  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*07d7dbdcSHerbert Dürr  * KIND, either express or implied.  See the License for the
17*07d7dbdcSHerbert Dürr  * specific language governing permissions and limitations
18*07d7dbdcSHerbert Dürr  * under the License.
19*07d7dbdcSHerbert Dürr  *
20*07d7dbdcSHerbert Dürr  *************************************************************/
21*07d7dbdcSHerbert Dürr 
22eba4d44aSLiu Zhe package fvt.uno.sc.cell;
23eba4d44aSLiu Zhe 
24eba4d44aSLiu Zhe import static org.junit.Assert.*;
25eba4d44aSLiu Zhe 
26eba4d44aSLiu Zhe import org.junit.After;
27eba4d44aSLiu Zhe import org.junit.Before;
28eba4d44aSLiu Zhe import org.junit.Test;
29eba4d44aSLiu Zhe 
30eba4d44aSLiu Zhe import org.openoffice.test.uno.UnoApp;
31eba4d44aSLiu Zhe 
32eba4d44aSLiu Zhe import com.sun.star.container.XIndexAccess;
33eba4d44aSLiu Zhe import com.sun.star.lang.XComponent;
34eba4d44aSLiu Zhe import com.sun.star.sheet.CellDeleteMode;
35eba4d44aSLiu Zhe import com.sun.star.sheet.CellInsertMode;
36eba4d44aSLiu Zhe import com.sun.star.sheet.XCellRangeAddressable;
37eba4d44aSLiu Zhe import com.sun.star.sheet.XSpreadsheet;
38eba4d44aSLiu Zhe import com.sun.star.sheet.XSpreadsheetDocument;
39eba4d44aSLiu Zhe import com.sun.star.sheet.XSpreadsheets;
40eba4d44aSLiu Zhe import com.sun.star.table.XCell;
41eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime;
42eba4d44aSLiu Zhe import com.sun.star.table.XCellRange;
43eba4d44aSLiu Zhe import com.sun.star.table.CellRangeAddress;
44eba4d44aSLiu Zhe import com.sun.star.sheet.XCellRangeMovement;
45eba4d44aSLiu Zhe 
46eba4d44aSLiu Zhe /**
47eba4d44aSLiu Zhe  * Test insert or delete cells
48eba4d44aSLiu Zhe  * @author BinGuo 8/30/2012
49eba4d44aSLiu Zhe  *
50eba4d44aSLiu Zhe  */
51eba4d44aSLiu Zhe 
52eba4d44aSLiu Zhe public class InsertDeleteCells {
53eba4d44aSLiu Zhe 
54eba4d44aSLiu Zhe 	UnoApp unoApp = new UnoApp();
55eba4d44aSLiu Zhe 	XSpreadsheetDocument scDocument = null;
56eba4d44aSLiu Zhe 	XComponent scComponent = null;
57eba4d44aSLiu Zhe 
58eba4d44aSLiu Zhe 	@Before
setUp()59eba4d44aSLiu Zhe 	public void setUp() throws Exception {
60eba4d44aSLiu Zhe 		unoApp.start();
61eba4d44aSLiu Zhe 	}
62eba4d44aSLiu Zhe 
63eba4d44aSLiu Zhe 	@After
tearDown()64eba4d44aSLiu Zhe 	public void tearDown() throws Exception {
65eba4d44aSLiu Zhe 		unoApp.closeDocument(scComponent);
66eba4d44aSLiu Zhe 		unoApp.close();
67eba4d44aSLiu Zhe 		}
68eba4d44aSLiu Zhe 
69eba4d44aSLiu Zhe 	/**
70eba4d44aSLiu Zhe 	 * New spreadsheet
71eba4d44aSLiu Zhe 	 * Create 3x3 cell range A2:C4
72eba4d44aSLiu Zhe 	 * Execute insert empty A2 & B2 cells shift other existing cells in Column A & B down
73eba4d44aSLiu Zhe 	 * Execute insert empty A2 & B2 cells shift other existing cells in row 2 move right
74eba4d44aSLiu Zhe 	 * Execute insert entire empty Row 2 make the whole existing cell range moves down
75eba4d44aSLiu Zhe 	 * Execute insert entire empty Columns A & B make the whole existing cell range moves right
76eba4d44aSLiu Zhe 	 * Verify results after insert cells
77eba4d44aSLiu Zhe 	 */
78eba4d44aSLiu Zhe 
79eba4d44aSLiu Zhe 	@Test
testInsertCells()80eba4d44aSLiu Zhe 	public void testInsertCells() throws Exception {
81eba4d44aSLiu Zhe 
82eba4d44aSLiu Zhe 		scComponent = unoApp.newDocument("scalc");
83eba4d44aSLiu Zhe 		scDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, scComponent);
84eba4d44aSLiu Zhe 		XSpreadsheets xSpreadsheets = scDocument.getSheets();
85eba4d44aSLiu Zhe 
86eba4d44aSLiu Zhe 		// Gets the first sheet in the document.
87eba4d44aSLiu Zhe         XIndexAccess xSheetsIA = (XIndexAccess)UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
88eba4d44aSLiu Zhe         Object sheetObj = (XSpreadsheet)UnoRuntime.queryInterface(XSpreadsheet.class, xSheetsIA.getByIndex(0));
89eba4d44aSLiu Zhe 		XSpreadsheet xSheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, sheetObj);
90eba4d44aSLiu Zhe 
91eba4d44aSLiu Zhe 	    // Create a 3x3 cell range "A2:C4" with the values 0 ... 8.
92eba4d44aSLiu Zhe 	    int nCol = 0;
93eba4d44aSLiu Zhe 	    int nValue = 0;
94eba4d44aSLiu Zhe 
95eba4d44aSLiu Zhe 	    for (int n = 1; n < 4; ++n){
96eba4d44aSLiu Zhe 	    	int nRow = 1;
97eba4d44aSLiu Zhe 	    	for (int i = 1; i < 4; ++i) {
98eba4d44aSLiu Zhe 			   xSheet.getCellByPosition( nCol, nRow ).setValue( nValue );
99eba4d44aSLiu Zhe 		       nRow += 1;
100eba4d44aSLiu Zhe 		       nValue += 1;
101eba4d44aSLiu Zhe 		    }
102eba4d44aSLiu Zhe 	        nCol += 1;
103eba4d44aSLiu Zhe 	    }
104eba4d44aSLiu Zhe 
105eba4d44aSLiu Zhe 	    //Insert 2 cells in A2:B2 and shift other existing cells in Column A & B down
106eba4d44aSLiu Zhe 
107eba4d44aSLiu Zhe 		// Get cell range A2:B2 by position - (column, row, column, row)
108eba4d44aSLiu Zhe         XCellRange xCellRange = xSheet.getCellRangeByPosition( 0, 1, 1, 1 );
109eba4d44aSLiu Zhe         XCellRangeMovement xCellRangeMovement = (XCellRangeMovement)
110eba4d44aSLiu Zhe         		UnoRuntime.queryInterface(XCellRangeMovement.class, xSheet);
111eba4d44aSLiu Zhe 
112eba4d44aSLiu Zhe         // Gets the selected range's address/location.
113eba4d44aSLiu Zhe  	    XCellRangeAddressable xCellRangeAddr = (XCellRangeAddressable)
114eba4d44aSLiu Zhe 	            UnoRuntime.queryInterface( XCellRangeAddressable.class, xCellRange );
115eba4d44aSLiu Zhe 	    CellRangeAddress address = xCellRangeAddr.getRangeAddress();
116eba4d44aSLiu Zhe 
117eba4d44aSLiu Zhe 	    //Execute Insert cells in A2:B2 and shift other existing cells in Column A & B down
118eba4d44aSLiu Zhe 	    xCellRangeMovement.insertCells(address, CellInsertMode.DOWN);
119eba4d44aSLiu Zhe 
120eba4d44aSLiu Zhe 	    //Get value of cell A2, B2 and C2
121eba4d44aSLiu Zhe         XCell cellA2 = xSheet.getCellByPosition(0, 1);
122eba4d44aSLiu Zhe         XCell cellB2 = xSheet.getCellByPosition(1, 1);
123eba4d44aSLiu Zhe         XCell cellC2 = xSheet.getCellByPosition(2, 1);
124eba4d44aSLiu Zhe         double expectValueA2 = 0.0;
125eba4d44aSLiu Zhe         double expectValueB2 = 0.0;
126eba4d44aSLiu Zhe         double expectValueC2 = 6;
127eba4d44aSLiu Zhe 
128eba4d44aSLiu Zhe         //Verify results after execute Insert cells in A2:B2 and shift other existing cells in Column A & B down
129eba4d44aSLiu Zhe         assertEquals("Verify value of A2 after execute Insert cells in A2:B2 and shift cells down.",
130eba4d44aSLiu Zhe         		expectValueA2, cellA2.getValue(),0);
131eba4d44aSLiu Zhe         assertEquals("Verify value of B2 after execute Insert cells in A2:B2 and shift cells down.",
132eba4d44aSLiu Zhe         		expectValueB2, cellB2.getValue(),0);
133eba4d44aSLiu Zhe         assertEquals("Verify value of C2 after execute Insert cells in A2:B2 and shift cells down.",
134eba4d44aSLiu Zhe         		expectValueC2, cellC2.getValue(),0);
135eba4d44aSLiu Zhe 
136eba4d44aSLiu Zhe         //Execute Insert cells in A2:B2 and shift other existing cells in row 2 move right
137eba4d44aSLiu Zhe 	    xCellRangeMovement.insertCells(address, CellInsertMode.RIGHT);
138eba4d44aSLiu Zhe 
139eba4d44aSLiu Zhe 	    //Get value of cell C2, D2, E2 and C3
140eba4d44aSLiu Zhe 	    cellC2 = xSheet.getCellByPosition(2, 1);
141eba4d44aSLiu Zhe         XCell cellD2 = xSheet.getCellByPosition(3, 1);
142eba4d44aSLiu Zhe         XCell cellE2 = xSheet.getCellByPosition(4, 1);
143eba4d44aSLiu Zhe         XCell cellC3 = xSheet.getCellByPosition(2, 2);
144eba4d44aSLiu Zhe         double expectValueC2right = 0.0;
145eba4d44aSLiu Zhe         double expectValueD2 = 0.0;
146eba4d44aSLiu Zhe         double expectValueE2 = 6;
147eba4d44aSLiu Zhe         double expectValueC3 = 7;
148eba4d44aSLiu Zhe 
149eba4d44aSLiu Zhe         //Verify results after execute Insert cells in A2:B2 and shift other existing cells in row 2 move right
150eba4d44aSLiu Zhe         assertEquals("Verify value of C2 after execute Insert cells in A2:B2 and shift cells Right.",
151eba4d44aSLiu Zhe         		expectValueC2right, cellC2.getValue(),0);
152eba4d44aSLiu Zhe         assertEquals("Verify value of D2 after execute Insert cells in A2:B2 and shift cells Right.",
153eba4d44aSLiu Zhe         		expectValueD2, cellD2.getValue(),0);
154eba4d44aSLiu Zhe         assertEquals("Verify value of E2 after execute Insert cells in A2:B2 and shift cells Right.",
155eba4d44aSLiu Zhe         		expectValueE2, cellE2.getValue(),0);
156eba4d44aSLiu Zhe         assertEquals("Verify value of C3 after execute Insert cells in A2:B2 and shift cells Right.",
157eba4d44aSLiu Zhe         		expectValueC3, cellC3.getValue(),0);
158eba4d44aSLiu Zhe 
159eba4d44aSLiu Zhe         //Execute Insert Entire Row 2 make the whole existing cell range moves down
160eba4d44aSLiu Zhe 	    xCellRangeMovement.insertCells(address, CellInsertMode.ROWS);
161eba4d44aSLiu Zhe 
162eba4d44aSLiu Zhe 	    //Get value of cell E2, E3 and C3
163eba4d44aSLiu Zhe 	    cellE2 = xSheet.getCellByPosition(4, 1);
164eba4d44aSLiu Zhe         XCell cellE3 = xSheet.getCellByPosition(4, 2);
165eba4d44aSLiu Zhe         cellC3 = xSheet.getCellByPosition(2, 2);
166eba4d44aSLiu Zhe         double expectValueE2rows = 0.0;
167eba4d44aSLiu Zhe         double expectValueE3 = 6;
168eba4d44aSLiu Zhe         double expectValueC3rows = 0.0;
169eba4d44aSLiu Zhe 
170eba4d44aSLiu Zhe         //Verify results after execute Insert Entire Row 2 make the whole existing cell range moves down
171eba4d44aSLiu Zhe         assertEquals("Verify value of E2 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
172eba4d44aSLiu Zhe         		expectValueE2rows, cellE2.getValue(),0);
173eba4d44aSLiu Zhe         assertEquals("Verify value of E3 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
174eba4d44aSLiu Zhe         		expectValueE3, cellE3.getValue(),0);
175eba4d44aSLiu Zhe         assertEquals("Verify value of C3 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
176eba4d44aSLiu Zhe         		expectValueC3rows, cellC3.getValue(),0);
177eba4d44aSLiu Zhe 
178eba4d44aSLiu Zhe 	    //Execute Insert Entire Columns make the whole existing cell range moves right
179eba4d44aSLiu Zhe 	    xCellRangeMovement.insertCells(address, CellInsertMode.COLUMNS);
180eba4d44aSLiu Zhe 
181eba4d44aSLiu Zhe 	    //Get value of cell C4, C5 and C6
182eba4d44aSLiu Zhe 	    XCell cellC4 = xSheet.getCellByPosition(2, 3);
183eba4d44aSLiu Zhe         XCell cellC5 = xSheet.getCellByPosition(2, 4);
184eba4d44aSLiu Zhe         XCell cellC6 = xSheet.getCellByPosition(2, 5);
185eba4d44aSLiu Zhe         double expectValueC4 = 0.0;
186eba4d44aSLiu Zhe         double expectValueC5 = 1;
187eba4d44aSLiu Zhe         double expectValueC6 = 2;
188eba4d44aSLiu Zhe 
189eba4d44aSLiu Zhe         //Verify results after execute Insert Entire Columns make the whole existing cell range moves right
190eba4d44aSLiu Zhe         assertEquals("Verify value of E2 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
191eba4d44aSLiu Zhe     		   expectValueC4, cellC4.getValue(),0);
192eba4d44aSLiu Zhe         assertEquals("Verify value of E3 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
193eba4d44aSLiu Zhe     		   expectValueC5, cellC5.getValue(),0);
194eba4d44aSLiu Zhe         assertEquals("Verify value of C3 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
195eba4d44aSLiu Zhe     		   expectValueC6, cellC6.getValue(),0);
196eba4d44aSLiu Zhe 
197eba4d44aSLiu Zhe     }
198eba4d44aSLiu Zhe 
199eba4d44aSLiu Zhe 	/**
200eba4d44aSLiu Zhe 	 * New spreadsheet
201eba4d44aSLiu Zhe 	 * Create 3x3 cell range A2:C4
202eba4d44aSLiu Zhe 	 * Execute delete cells A2 & B2 shift other existing cells in column A & B move up
203eba4d44aSLiu Zhe 	 * Execute delete cells A2 & B2 shift other existing cells in row 2 move left
204eba4d44aSLiu Zhe 	 * Execute delete entire Row 2 make the whole existing cell range moves up
205eba4d44aSLiu Zhe 	 * Execute delete entire Columns A & B make the whole existing cell range moves left
206eba4d44aSLiu Zhe 	 * Verify results after delete cells
207eba4d44aSLiu Zhe 	 */
208eba4d44aSLiu Zhe 
209eba4d44aSLiu Zhe     @Test
testDeleteCells()210eba4d44aSLiu Zhe     public void testDeleteCells() throws Exception {
211eba4d44aSLiu Zhe 
212eba4d44aSLiu Zhe 	    scComponent = unoApp.newDocument("scalc");
213eba4d44aSLiu Zhe 	    scDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, scComponent);
214eba4d44aSLiu Zhe 	    XSpreadsheets xSpreadsheets = scDocument.getSheets();
215eba4d44aSLiu Zhe 
216eba4d44aSLiu Zhe 	    // Gets the first sheet in the document.
217eba4d44aSLiu Zhe         XIndexAccess xSheetsIA = (XIndexAccess)UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
218eba4d44aSLiu Zhe         Object sheetObj = (XSpreadsheet)UnoRuntime.queryInterface(XSpreadsheet.class, xSheetsIA.getByIndex(0));
219eba4d44aSLiu Zhe 	    XSpreadsheet xSheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, sheetObj);
220eba4d44aSLiu Zhe 
221eba4d44aSLiu Zhe         // Create a 3x3 cell range "A2:C4" with the values 0 ... 8.
222eba4d44aSLiu Zhe         int nCol = 0;
223eba4d44aSLiu Zhe         int nValue = 0;
224eba4d44aSLiu Zhe 
225eba4d44aSLiu Zhe         for (int n = 1; n < 4; ++n){
226eba4d44aSLiu Zhe     	    int nRow = 1;
227eba4d44aSLiu Zhe     	    for (int i = 1; i < 4; ++i) {
228eba4d44aSLiu Zhe 		        xSheet.getCellByPosition( nCol, nRow ).setValue( nValue );
229eba4d44aSLiu Zhe 	            nRow += 1;
230eba4d44aSLiu Zhe 	            nValue += 1;
231eba4d44aSLiu Zhe 	        }
232eba4d44aSLiu Zhe             nCol += 1;
233eba4d44aSLiu Zhe        }
234eba4d44aSLiu Zhe 
235eba4d44aSLiu Zhe         //Insert 2 cells in A2:B2 and shift cells up
236eba4d44aSLiu Zhe 
237eba4d44aSLiu Zhe 	    // Get cell range A2:B2 by position - (column, row, column, row)
238eba4d44aSLiu Zhe         XCellRange xCellRange = xSheet.getCellRangeByPosition( 0, 1, 1, 1 );
239eba4d44aSLiu Zhe         XCellRangeMovement xCellRangeMovement = (XCellRangeMovement)
240eba4d44aSLiu Zhe     		UnoRuntime.queryInterface(XCellRangeMovement.class, xSheet);
241eba4d44aSLiu Zhe 
242eba4d44aSLiu Zhe         // Gets the selected range's address/location.
243eba4d44aSLiu Zhe 	    XCellRangeAddressable xCellRangeAddr = (XCellRangeAddressable)
244eba4d44aSLiu Zhe             UnoRuntime.queryInterface( XCellRangeAddressable.class, xCellRange );
245eba4d44aSLiu Zhe         CellRangeAddress address = xCellRangeAddr.getRangeAddress();
246eba4d44aSLiu Zhe 
247eba4d44aSLiu Zhe         //Execute delete cells in A2:B2 and shift cells in column A & B move up
248eba4d44aSLiu Zhe         xCellRangeMovement.removeRange(address,CellDeleteMode.UP);
249eba4d44aSLiu Zhe 
250eba4d44aSLiu Zhe         //Get value of cell A2, B2 and C2
251eba4d44aSLiu Zhe         XCell cellA2 = xSheet.getCellByPosition(0, 1);
252eba4d44aSLiu Zhe         XCell cellB2 = xSheet.getCellByPosition(1, 1);
253eba4d44aSLiu Zhe         XCell cellC2 = xSheet.getCellByPosition(2, 1);
254eba4d44aSLiu Zhe         double expectValueA2up = 1;
255eba4d44aSLiu Zhe         double expectValueB2up = 4;
256eba4d44aSLiu Zhe         double expectValueC2up = 6;
257eba4d44aSLiu Zhe 
258eba4d44aSLiu Zhe         //Verify results after execute delete cells in A2:B2 and shift cells in column A & B move up
259eba4d44aSLiu Zhe         assertEquals("Verify value of A2 after execute delete cells in A2:B2 and shift cells up.",
260eba4d44aSLiu Zhe     		expectValueA2up, cellA2.getValue(),0);
261eba4d44aSLiu Zhe         assertEquals("Verify value of B2 after execute delete cells in A2:B2 and shift cells up.",
262eba4d44aSLiu Zhe     		expectValueB2up, cellB2.getValue(),0);
263eba4d44aSLiu Zhe         assertEquals("Verify value of C2 after execute delete cells in A2:B2 and shift cells up.",
264eba4d44aSLiu Zhe     		expectValueC2up, cellC2.getValue(),0);
265eba4d44aSLiu Zhe 
266eba4d44aSLiu Zhe         //Execute delete cells in A2:B2 and shift other existing cells in row 2 move left
267eba4d44aSLiu Zhe         xCellRangeMovement.removeRange(address,CellDeleteMode.LEFT);
268eba4d44aSLiu Zhe 
269eba4d44aSLiu Zhe         //Get value of cell A2, B2 and C2
270eba4d44aSLiu Zhe         cellA2 = xSheet.getCellByPosition(0, 1);
271eba4d44aSLiu Zhe         cellB2 = xSheet.getCellByPosition(1, 1);
272eba4d44aSLiu Zhe         cellC2 = xSheet.getCellByPosition(2, 1);
273eba4d44aSLiu Zhe         double expectValueA2left = 6;
274eba4d44aSLiu Zhe         double expectValueB2left = 0.0;
275eba4d44aSLiu Zhe         double expectValueC2left = 0.0;
276eba4d44aSLiu Zhe 
277eba4d44aSLiu Zhe         //Verify results after execute delete cells in A2:B2 and shift other existing cells in row 2 move left
278eba4d44aSLiu Zhe         assertEquals("Verify value of A2 after execute delete cells in A2:B2 and shift cells left.",
279eba4d44aSLiu Zhe     		expectValueA2left, cellA2.getValue(),0);
280eba4d44aSLiu Zhe         assertEquals("Verify value of B2 after execute delete cells in A2:B2 and shift cells left.",
281eba4d44aSLiu Zhe     		expectValueB2left, cellB2.getValue(),0);
282eba4d44aSLiu Zhe         assertEquals("Verify value of C2 after execute delete cells in A2:B2 and shift cells left.",
283eba4d44aSLiu Zhe     		expectValueC2left, cellC2.getValue(),0);
284eba4d44aSLiu Zhe 
285eba4d44aSLiu Zhe         //Execute delete Entire Row 2 make the whole existing cell range moves up
286eba4d44aSLiu Zhe         xCellRangeMovement.removeRange(address,CellDeleteMode.ROWS);
287eba4d44aSLiu Zhe 
288eba4d44aSLiu Zhe         //Get value of cell A2, B2 and C2
289eba4d44aSLiu Zhe         cellA2 = xSheet.getCellByPosition(0, 1);
290eba4d44aSLiu Zhe         cellB2 = xSheet.getCellByPosition(1, 1);
291eba4d44aSLiu Zhe         cellC2 = xSheet.getCellByPosition(2, 1);
292eba4d44aSLiu Zhe         double expectValueA2rows = 2;
293eba4d44aSLiu Zhe         double expectValueB2rows = 5;
294eba4d44aSLiu Zhe         double expectValueC2rows = 7;
295eba4d44aSLiu Zhe 
296eba4d44aSLiu Zhe         //Verify results after delete Entire Row 2 make the whole existing cell range moves up
297eba4d44aSLiu Zhe         assertEquals("Verify value of A2 after delete Entire Row 2 make the whole existing cell range moves up.",
298eba4d44aSLiu Zhe     		expectValueA2rows, cellA2.getValue(),0);
299eba4d44aSLiu Zhe         assertEquals("Verify value of B2 after delete Entire Row 2 make the whole existing cell range moves up.",
300eba4d44aSLiu Zhe     		expectValueB2rows, cellB2.getValue(),0);
301eba4d44aSLiu Zhe         assertEquals("Verify value of C2 after delete Entire Row 2 make the whole existing cell range moves up.",
302eba4d44aSLiu Zhe     		expectValueC2rows, cellC2.getValue(),0);
303eba4d44aSLiu Zhe 
304eba4d44aSLiu Zhe         //Execute delete Entire Columns make the whole existing cell range moves left
305eba4d44aSLiu Zhe         xCellRangeMovement.removeRange(address,CellDeleteMode.COLUMNS);
306eba4d44aSLiu Zhe 
307eba4d44aSLiu Zhe         //Get value of cell A2, B2 and C2
308eba4d44aSLiu Zhe         cellA2 = xSheet.getCellByPosition(0, 1);
309eba4d44aSLiu Zhe         cellB2 = xSheet.getCellByPosition(1, 1);
310eba4d44aSLiu Zhe         cellC2 = xSheet.getCellByPosition(2, 1);
311eba4d44aSLiu Zhe         double expectValueA2columns = 7;
312eba4d44aSLiu Zhe         double expectValueB2columns = 0.0;
313eba4d44aSLiu Zhe         double expectValueC2columns = 0.0;
314eba4d44aSLiu Zhe 
315eba4d44aSLiu Zhe         //Verify results after execute delete Entire Columns make the whole existing cell range moves left
316eba4d44aSLiu Zhe         assertEquals("Verify value of A2 after delete Entire Columns make the whole existing cell range moves left.",
317eba4d44aSLiu Zhe     		expectValueA2columns, cellA2.getValue(),0);
318eba4d44aSLiu Zhe         assertEquals("Verify value of B2 after delete Entire Columns make the whole existing cell range moves left.",
319eba4d44aSLiu Zhe     		expectValueB2columns, cellB2.getValue(),0);
320eba4d44aSLiu Zhe         assertEquals("Verify value of C2 after delete Entire Columns make the whole existing cell range moves left.",
321eba4d44aSLiu Zhe     		expectValueC2columns, cellC2.getValue(),0);
322eba4d44aSLiu Zhe 
323eba4d44aSLiu Zhe     }
324eba4d44aSLiu Zhe 
325eba4d44aSLiu Zhe }
326eba4d44aSLiu Zhe 
327eba4d44aSLiu Zhe 
328