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;
234f4f7c7bSLiu Zhe 
244f4f7c7bSLiu Zhe import static org.junit.Assert.*;
254f4f7c7bSLiu Zhe 
264f4f7c7bSLiu Zhe import org.junit.After;
274f4f7c7bSLiu Zhe import org.junit.Before;
284f4f7c7bSLiu Zhe import org.junit.Test;
294f4f7c7bSLiu Zhe 
304f4f7c7bSLiu Zhe import org.openoffice.test.uno.UnoApp;
314f4f7c7bSLiu Zhe 
324f4f7c7bSLiu Zhe import com.sun.star.container.XIndexAccess;
334f4f7c7bSLiu Zhe import com.sun.star.lang.XComponent;
344f4f7c7bSLiu Zhe import com.sun.star.sheet.CellDeleteMode;
354f4f7c7bSLiu Zhe import com.sun.star.sheet.CellInsertMode;
364f4f7c7bSLiu Zhe import com.sun.star.sheet.XCellRangeAddressable;
374f4f7c7bSLiu Zhe import com.sun.star.sheet.XSpreadsheet;
384f4f7c7bSLiu Zhe import com.sun.star.sheet.XSpreadsheetDocument;
394f4f7c7bSLiu Zhe import com.sun.star.sheet.XSpreadsheets;
404f4f7c7bSLiu Zhe import com.sun.star.table.XCell;
414f4f7c7bSLiu Zhe import com.sun.star.uno.UnoRuntime;
424f4f7c7bSLiu Zhe import com.sun.star.table.XCellRange;
434f4f7c7bSLiu Zhe import com.sun.star.table.CellRangeAddress;
444f4f7c7bSLiu Zhe import com.sun.star.sheet.XCellRangeMovement;
454f4f7c7bSLiu Zhe 
464f4f7c7bSLiu Zhe /**
474f4f7c7bSLiu Zhe  * Test insert or delete cells
484f4f7c7bSLiu Zhe  * @author BinGuo 8/30/2012
494f4f7c7bSLiu Zhe  *
504f4f7c7bSLiu Zhe  */
514f4f7c7bSLiu Zhe 
524f4f7c7bSLiu Zhe public class InsertDeleteCells {
534f4f7c7bSLiu Zhe 
544f4f7c7bSLiu Zhe 	UnoApp unoApp = new UnoApp();
554f4f7c7bSLiu Zhe 	XSpreadsheetDocument scDocument = null;
564f4f7c7bSLiu Zhe 	XComponent scComponent = null;
574f4f7c7bSLiu Zhe 
584f4f7c7bSLiu Zhe 	@Before
setUp()594f4f7c7bSLiu Zhe 	public void setUp() throws Exception {
604f4f7c7bSLiu Zhe 		unoApp.start();
614f4f7c7bSLiu Zhe 	}
624f4f7c7bSLiu Zhe 
634f4f7c7bSLiu Zhe 	@After
tearDown()644f4f7c7bSLiu Zhe 	public void tearDown() throws Exception {
654f4f7c7bSLiu Zhe 		unoApp.closeDocument(scComponent);
664f4f7c7bSLiu Zhe 		unoApp.close();
674f4f7c7bSLiu Zhe 		}
684f4f7c7bSLiu Zhe 
694f4f7c7bSLiu Zhe 	/**
704f4f7c7bSLiu Zhe 	 * New spreadsheet
714f4f7c7bSLiu Zhe 	 * Create 3x3 cell range A2:C4
724f4f7c7bSLiu Zhe 	 * Execute insert empty A2 & B2 cells shift other existing cells in Column A & B down
734f4f7c7bSLiu Zhe 	 * Execute insert empty A2 & B2 cells shift other existing cells in row 2 move right
744f4f7c7bSLiu Zhe 	 * Execute insert entire empty Row 2 make the whole existing cell range moves down
754f4f7c7bSLiu Zhe 	 * Execute insert entire empty Columns A & B make the whole existing cell range moves right
764f4f7c7bSLiu Zhe 	 * Verify results after insert cells
774f4f7c7bSLiu Zhe 	 */
784f4f7c7bSLiu Zhe 
794f4f7c7bSLiu Zhe 	@Test
testInsertCells()804f4f7c7bSLiu Zhe 	public void testInsertCells() throws Exception {
814f4f7c7bSLiu Zhe 
824f4f7c7bSLiu Zhe 		scComponent = unoApp.newDocument("scalc");
834f4f7c7bSLiu Zhe 		scDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, scComponent);
844f4f7c7bSLiu Zhe 		XSpreadsheets xSpreadsheets = scDocument.getSheets();
854f4f7c7bSLiu Zhe 
864f4f7c7bSLiu Zhe 		// Gets the first sheet in the document.
874f4f7c7bSLiu Zhe         XIndexAccess xSheetsIA = (XIndexAccess)UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
884f4f7c7bSLiu Zhe         Object sheetObj = (XSpreadsheet)UnoRuntime.queryInterface(XSpreadsheet.class, xSheetsIA.getByIndex(0));
894f4f7c7bSLiu Zhe 		XSpreadsheet xSheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, sheetObj);
904f4f7c7bSLiu Zhe 
914f4f7c7bSLiu Zhe 	    // Create a 3x3 cell range "A2:C4" with the values 0 ... 8.
924f4f7c7bSLiu Zhe 	    int nCol = 0;
934f4f7c7bSLiu Zhe 	    int nValue = 0;
944f4f7c7bSLiu Zhe 
954f4f7c7bSLiu Zhe 	    for (int n = 1; n < 4; ++n){
964f4f7c7bSLiu Zhe 	    	int nRow = 1;
974f4f7c7bSLiu Zhe 	    	for (int i = 1; i < 4; ++i) {
984f4f7c7bSLiu Zhe 			   xSheet.getCellByPosition( nCol, nRow ).setValue( nValue );
994f4f7c7bSLiu Zhe 		       nRow += 1;
1004f4f7c7bSLiu Zhe 		       nValue += 1;
1014f4f7c7bSLiu Zhe 		    }
1024f4f7c7bSLiu Zhe 	        nCol += 1;
1034f4f7c7bSLiu Zhe 	    }
1044f4f7c7bSLiu Zhe 
1054f4f7c7bSLiu Zhe 	    //Insert 2 cells in A2:B2 and shift other existing cells in Column A & B down
1064f4f7c7bSLiu Zhe 
1074f4f7c7bSLiu Zhe 		// Get cell range A2:B2 by position - (column, row, column, row)
1084f4f7c7bSLiu Zhe         XCellRange xCellRange = xSheet.getCellRangeByPosition( 0, 1, 1, 1 );
1094f4f7c7bSLiu Zhe         XCellRangeMovement xCellRangeMovement = (XCellRangeMovement)
1104f4f7c7bSLiu Zhe         		UnoRuntime.queryInterface(XCellRangeMovement.class, xSheet);
1114f4f7c7bSLiu Zhe 
1124f4f7c7bSLiu Zhe         // Gets the selected range's address/location.
1134f4f7c7bSLiu Zhe  	    XCellRangeAddressable xCellRangeAddr = (XCellRangeAddressable)
1144f4f7c7bSLiu Zhe 	            UnoRuntime.queryInterface( XCellRangeAddressable.class, xCellRange );
1154f4f7c7bSLiu Zhe 	    CellRangeAddress address = xCellRangeAddr.getRangeAddress();
1164f4f7c7bSLiu Zhe 
1174f4f7c7bSLiu Zhe 	    //Execute Insert cells in A2:B2 and shift other existing cells in Column A & B down
1184f4f7c7bSLiu Zhe 	    xCellRangeMovement.insertCells(address, CellInsertMode.DOWN);
1194f4f7c7bSLiu Zhe 
1204f4f7c7bSLiu Zhe 	    //Get value of cell A2, B2 and C2
1214f4f7c7bSLiu Zhe         XCell cellA2 = xSheet.getCellByPosition(0, 1);
1224f4f7c7bSLiu Zhe         XCell cellB2 = xSheet.getCellByPosition(1, 1);
1234f4f7c7bSLiu Zhe         XCell cellC2 = xSheet.getCellByPosition(2, 1);
1244f4f7c7bSLiu Zhe         double expectValueA2 = 0.0;
1254f4f7c7bSLiu Zhe         double expectValueB2 = 0.0;
1264f4f7c7bSLiu Zhe         double expectValueC2 = 6;
1274f4f7c7bSLiu Zhe 
1284f4f7c7bSLiu Zhe         //Verify results after execute Insert cells in A2:B2 and shift other existing cells in Column A & B down
1294f4f7c7bSLiu Zhe         assertEquals("Verify value of A2 after execute Insert cells in A2:B2 and shift cells down.",
1304f4f7c7bSLiu Zhe         		expectValueA2, cellA2.getValue(),0);
1314f4f7c7bSLiu Zhe         assertEquals("Verify value of B2 after execute Insert cells in A2:B2 and shift cells down.",
1324f4f7c7bSLiu Zhe         		expectValueB2, cellB2.getValue(),0);
1334f4f7c7bSLiu Zhe         assertEquals("Verify value of C2 after execute Insert cells in A2:B2 and shift cells down.",
1344f4f7c7bSLiu Zhe         		expectValueC2, cellC2.getValue(),0);
1354f4f7c7bSLiu Zhe 
1364f4f7c7bSLiu Zhe         //Execute Insert cells in A2:B2 and shift other existing cells in row 2 move right
1374f4f7c7bSLiu Zhe 	    xCellRangeMovement.insertCells(address, CellInsertMode.RIGHT);
1384f4f7c7bSLiu Zhe 
1394f4f7c7bSLiu Zhe 	    //Get value of cell C2, D2, E2 and C3
1404f4f7c7bSLiu Zhe 	    cellC2 = xSheet.getCellByPosition(2, 1);
1414f4f7c7bSLiu Zhe         XCell cellD2 = xSheet.getCellByPosition(3, 1);
1424f4f7c7bSLiu Zhe         XCell cellE2 = xSheet.getCellByPosition(4, 1);
1434f4f7c7bSLiu Zhe         XCell cellC3 = xSheet.getCellByPosition(2, 2);
1444f4f7c7bSLiu Zhe         double expectValueC2right = 0.0;
1454f4f7c7bSLiu Zhe         double expectValueD2 = 0.0;
1464f4f7c7bSLiu Zhe         double expectValueE2 = 6;
1474f4f7c7bSLiu Zhe         double expectValueC3 = 7;
1484f4f7c7bSLiu Zhe 
1494f4f7c7bSLiu Zhe         //Verify results after execute Insert cells in A2:B2 and shift other existing cells in row 2 move right
1504f4f7c7bSLiu Zhe         assertEquals("Verify value of C2 after execute Insert cells in A2:B2 and shift cells Right.",
1514f4f7c7bSLiu Zhe         		expectValueC2right, cellC2.getValue(),0);
1524f4f7c7bSLiu Zhe         assertEquals("Verify value of D2 after execute Insert cells in A2:B2 and shift cells Right.",
1534f4f7c7bSLiu Zhe         		expectValueD2, cellD2.getValue(),0);
1544f4f7c7bSLiu Zhe         assertEquals("Verify value of E2 after execute Insert cells in A2:B2 and shift cells Right.",
1554f4f7c7bSLiu Zhe         		expectValueE2, cellE2.getValue(),0);
1564f4f7c7bSLiu Zhe         assertEquals("Verify value of C3 after execute Insert cells in A2:B2 and shift cells Right.",
1574f4f7c7bSLiu Zhe         		expectValueC3, cellC3.getValue(),0);
1584f4f7c7bSLiu Zhe 
1594f4f7c7bSLiu Zhe         //Execute Insert Entire Row 2 make the whole existing cell range moves down
1604f4f7c7bSLiu Zhe 	    xCellRangeMovement.insertCells(address, CellInsertMode.ROWS);
1614f4f7c7bSLiu Zhe 
1624f4f7c7bSLiu Zhe 	    //Get value of cell E2, E3 and C3
1634f4f7c7bSLiu Zhe 	    cellE2 = xSheet.getCellByPosition(4, 1);
1644f4f7c7bSLiu Zhe         XCell cellE3 = xSheet.getCellByPosition(4, 2);
1654f4f7c7bSLiu Zhe         cellC3 = xSheet.getCellByPosition(2, 2);
1664f4f7c7bSLiu Zhe         double expectValueE2rows = 0.0;
1674f4f7c7bSLiu Zhe         double expectValueE3 = 6;
1684f4f7c7bSLiu Zhe         double expectValueC3rows = 0.0;
1694f4f7c7bSLiu Zhe 
1704f4f7c7bSLiu Zhe         //Verify results after execute Insert Entire Row 2 make the whole existing cell range moves down
1714f4f7c7bSLiu Zhe         assertEquals("Verify value of E2 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
1724f4f7c7bSLiu Zhe         		expectValueE2rows, cellE2.getValue(),0);
1734f4f7c7bSLiu Zhe         assertEquals("Verify value of E3 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
1744f4f7c7bSLiu Zhe         		expectValueE3, cellE3.getValue(),0);
1754f4f7c7bSLiu Zhe         assertEquals("Verify value of C3 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
1764f4f7c7bSLiu Zhe         		expectValueC3rows, cellC3.getValue(),0);
1774f4f7c7bSLiu Zhe 
1784f4f7c7bSLiu Zhe 	    //Execute Insert Entire Columns make the whole existing cell range moves right
1794f4f7c7bSLiu Zhe 	    xCellRangeMovement.insertCells(address, CellInsertMode.COLUMNS);
1804f4f7c7bSLiu Zhe 
1814f4f7c7bSLiu Zhe 	    //Get value of cell C4, C5 and C6
1824f4f7c7bSLiu Zhe 	    XCell cellC4 = xSheet.getCellByPosition(2, 3);
1834f4f7c7bSLiu Zhe         XCell cellC5 = xSheet.getCellByPosition(2, 4);
1844f4f7c7bSLiu Zhe         XCell cellC6 = xSheet.getCellByPosition(2, 5);
1854f4f7c7bSLiu Zhe         double expectValueC4 = 0.0;
1864f4f7c7bSLiu Zhe         double expectValueC5 = 1;
1874f4f7c7bSLiu Zhe         double expectValueC6 = 2;
1884f4f7c7bSLiu Zhe 
1894f4f7c7bSLiu Zhe         //Verify results after execute Insert Entire Columns make the whole existing cell range moves right
1904f4f7c7bSLiu Zhe         assertEquals("Verify value of E2 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
1914f4f7c7bSLiu Zhe     		   expectValueC4, cellC4.getValue(),0);
1924f4f7c7bSLiu Zhe         assertEquals("Verify value of E3 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
1934f4f7c7bSLiu Zhe     		   expectValueC5, cellC5.getValue(),0);
1944f4f7c7bSLiu Zhe         assertEquals("Verify value of C3 after execute Insert Entire Row 2 make the whole existing cell range moves down.",
1954f4f7c7bSLiu Zhe     		   expectValueC6, cellC6.getValue(),0);
1964f4f7c7bSLiu Zhe 
1974f4f7c7bSLiu Zhe     }
1984f4f7c7bSLiu Zhe 
1994f4f7c7bSLiu Zhe 	/**
2004f4f7c7bSLiu Zhe 	 * New spreadsheet
2014f4f7c7bSLiu Zhe 	 * Create 3x3 cell range A2:C4
2024f4f7c7bSLiu Zhe 	 * Execute delete cells A2 & B2 shift other existing cells in column A & B move up
2034f4f7c7bSLiu Zhe 	 * Execute delete cells A2 & B2 shift other existing cells in row 2 move left
2044f4f7c7bSLiu Zhe 	 * Execute delete entire Row 2 make the whole existing cell range moves up
2054f4f7c7bSLiu Zhe 	 * Execute delete entire Columns A & B make the whole existing cell range moves left
2064f4f7c7bSLiu Zhe 	 * Verify results after delete cells
2074f4f7c7bSLiu Zhe 	 */
2084f4f7c7bSLiu Zhe 
2094f4f7c7bSLiu Zhe     @Test
testDeleteCells()2104f4f7c7bSLiu Zhe     public void testDeleteCells() throws Exception {
2114f4f7c7bSLiu Zhe 
2124f4f7c7bSLiu Zhe 	    scComponent = unoApp.newDocument("scalc");
2134f4f7c7bSLiu Zhe 	    scDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, scComponent);
2144f4f7c7bSLiu Zhe 	    XSpreadsheets xSpreadsheets = scDocument.getSheets();
2154f4f7c7bSLiu Zhe 
2164f4f7c7bSLiu Zhe 	    // Gets the first sheet in the document.
2174f4f7c7bSLiu Zhe         XIndexAccess xSheetsIA = (XIndexAccess)UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
2184f4f7c7bSLiu Zhe         Object sheetObj = (XSpreadsheet)UnoRuntime.queryInterface(XSpreadsheet.class, xSheetsIA.getByIndex(0));
2194f4f7c7bSLiu Zhe 	    XSpreadsheet xSheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, sheetObj);
2204f4f7c7bSLiu Zhe 
2214f4f7c7bSLiu Zhe         // Create a 3x3 cell range "A2:C4" with the values 0 ... 8.
2224f4f7c7bSLiu Zhe         int nCol = 0;
2234f4f7c7bSLiu Zhe         int nValue = 0;
2244f4f7c7bSLiu Zhe 
2254f4f7c7bSLiu Zhe         for (int n = 1; n < 4; ++n){
2264f4f7c7bSLiu Zhe     	    int nRow = 1;
2274f4f7c7bSLiu Zhe     	    for (int i = 1; i < 4; ++i) {
2284f4f7c7bSLiu Zhe 		        xSheet.getCellByPosition( nCol, nRow ).setValue( nValue );
2294f4f7c7bSLiu Zhe 	            nRow += 1;
2304f4f7c7bSLiu Zhe 	            nValue += 1;
2314f4f7c7bSLiu Zhe 	        }
2324f4f7c7bSLiu Zhe             nCol += 1;
2334f4f7c7bSLiu Zhe        }
2344f4f7c7bSLiu Zhe 
2354f4f7c7bSLiu Zhe         //Insert 2 cells in A2:B2 and shift cells up
2364f4f7c7bSLiu Zhe 
2374f4f7c7bSLiu Zhe 	    // Get cell range A2:B2 by position - (column, row, column, row)
2384f4f7c7bSLiu Zhe         XCellRange xCellRange = xSheet.getCellRangeByPosition( 0, 1, 1, 1 );
2394f4f7c7bSLiu Zhe         XCellRangeMovement xCellRangeMovement = (XCellRangeMovement)
2404f4f7c7bSLiu Zhe     		UnoRuntime.queryInterface(XCellRangeMovement.class, xSheet);
2414f4f7c7bSLiu Zhe 
2424f4f7c7bSLiu Zhe         // Gets the selected range's address/location.
2434f4f7c7bSLiu Zhe 	    XCellRangeAddressable xCellRangeAddr = (XCellRangeAddressable)
2444f4f7c7bSLiu Zhe             UnoRuntime.queryInterface( XCellRangeAddressable.class, xCellRange );
2454f4f7c7bSLiu Zhe         CellRangeAddress address = xCellRangeAddr.getRangeAddress();
2464f4f7c7bSLiu Zhe 
2474f4f7c7bSLiu Zhe         //Execute delete cells in A2:B2 and shift cells in column A & B move up
2484f4f7c7bSLiu Zhe         xCellRangeMovement.removeRange(address,CellDeleteMode.UP);
2494f4f7c7bSLiu Zhe 
2504f4f7c7bSLiu Zhe         //Get value of cell A2, B2 and C2
2514f4f7c7bSLiu Zhe         XCell cellA2 = xSheet.getCellByPosition(0, 1);
2524f4f7c7bSLiu Zhe         XCell cellB2 = xSheet.getCellByPosition(1, 1);
2534f4f7c7bSLiu Zhe         XCell cellC2 = xSheet.getCellByPosition(2, 1);
2544f4f7c7bSLiu Zhe         double expectValueA2up = 1;
2554f4f7c7bSLiu Zhe         double expectValueB2up = 4;
2564f4f7c7bSLiu Zhe         double expectValueC2up = 6;
2574f4f7c7bSLiu Zhe 
2584f4f7c7bSLiu Zhe         //Verify results after execute delete cells in A2:B2 and shift cells in column A & B move up
2594f4f7c7bSLiu Zhe         assertEquals("Verify value of A2 after execute delete cells in A2:B2 and shift cells up.",
2604f4f7c7bSLiu Zhe     		expectValueA2up, cellA2.getValue(),0);
2614f4f7c7bSLiu Zhe         assertEquals("Verify value of B2 after execute delete cells in A2:B2 and shift cells up.",
2624f4f7c7bSLiu Zhe     		expectValueB2up, cellB2.getValue(),0);
2634f4f7c7bSLiu Zhe         assertEquals("Verify value of C2 after execute delete cells in A2:B2 and shift cells up.",
2644f4f7c7bSLiu Zhe     		expectValueC2up, cellC2.getValue(),0);
2654f4f7c7bSLiu Zhe 
2664f4f7c7bSLiu Zhe         //Execute delete cells in A2:B2 and shift other existing cells in row 2 move left
2674f4f7c7bSLiu Zhe         xCellRangeMovement.removeRange(address,CellDeleteMode.LEFT);
2684f4f7c7bSLiu Zhe 
2694f4f7c7bSLiu Zhe         //Get value of cell A2, B2 and C2
2704f4f7c7bSLiu Zhe         cellA2 = xSheet.getCellByPosition(0, 1);
2714f4f7c7bSLiu Zhe         cellB2 = xSheet.getCellByPosition(1, 1);
2724f4f7c7bSLiu Zhe         cellC2 = xSheet.getCellByPosition(2, 1);
2734f4f7c7bSLiu Zhe         double expectValueA2left = 6;
2744f4f7c7bSLiu Zhe         double expectValueB2left = 0.0;
2754f4f7c7bSLiu Zhe         double expectValueC2left = 0.0;
2764f4f7c7bSLiu Zhe 
2774f4f7c7bSLiu Zhe         //Verify results after execute delete cells in A2:B2 and shift other existing cells in row 2 move left
2784f4f7c7bSLiu Zhe         assertEquals("Verify value of A2 after execute delete cells in A2:B2 and shift cells left.",
2794f4f7c7bSLiu Zhe     		expectValueA2left, cellA2.getValue(),0);
2804f4f7c7bSLiu Zhe         assertEquals("Verify value of B2 after execute delete cells in A2:B2 and shift cells left.",
2814f4f7c7bSLiu Zhe     		expectValueB2left, cellB2.getValue(),0);
2824f4f7c7bSLiu Zhe         assertEquals("Verify value of C2 after execute delete cells in A2:B2 and shift cells left.",
2834f4f7c7bSLiu Zhe     		expectValueC2left, cellC2.getValue(),0);
2844f4f7c7bSLiu Zhe 
2854f4f7c7bSLiu Zhe         //Execute delete Entire Row 2 make the whole existing cell range moves up
2864f4f7c7bSLiu Zhe         xCellRangeMovement.removeRange(address,CellDeleteMode.ROWS);
2874f4f7c7bSLiu Zhe 
2884f4f7c7bSLiu Zhe         //Get value of cell A2, B2 and C2
2894f4f7c7bSLiu Zhe         cellA2 = xSheet.getCellByPosition(0, 1);
2904f4f7c7bSLiu Zhe         cellB2 = xSheet.getCellByPosition(1, 1);
2914f4f7c7bSLiu Zhe         cellC2 = xSheet.getCellByPosition(2, 1);
2924f4f7c7bSLiu Zhe         double expectValueA2rows = 2;
2934f4f7c7bSLiu Zhe         double expectValueB2rows = 5;
2944f4f7c7bSLiu Zhe         double expectValueC2rows = 7;
2954f4f7c7bSLiu Zhe 
2964f4f7c7bSLiu Zhe         //Verify results after delete Entire Row 2 make the whole existing cell range moves up
2974f4f7c7bSLiu Zhe         assertEquals("Verify value of A2 after delete Entire Row 2 make the whole existing cell range moves up.",
2984f4f7c7bSLiu Zhe     		expectValueA2rows, cellA2.getValue(),0);
2994f4f7c7bSLiu Zhe         assertEquals("Verify value of B2 after delete Entire Row 2 make the whole existing cell range moves up.",
3004f4f7c7bSLiu Zhe     		expectValueB2rows, cellB2.getValue(),0);
3014f4f7c7bSLiu Zhe         assertEquals("Verify value of C2 after delete Entire Row 2 make the whole existing cell range moves up.",
3024f4f7c7bSLiu Zhe     		expectValueC2rows, cellC2.getValue(),0);
3034f4f7c7bSLiu Zhe 
3044f4f7c7bSLiu Zhe         //Execute delete Entire Columns make the whole existing cell range moves left
3054f4f7c7bSLiu Zhe         xCellRangeMovement.removeRange(address,CellDeleteMode.COLUMNS);
3064f4f7c7bSLiu Zhe 
3074f4f7c7bSLiu Zhe         //Get value of cell A2, B2 and C2
3084f4f7c7bSLiu Zhe         cellA2 = xSheet.getCellByPosition(0, 1);
3094f4f7c7bSLiu Zhe         cellB2 = xSheet.getCellByPosition(1, 1);
3104f4f7c7bSLiu Zhe         cellC2 = xSheet.getCellByPosition(2, 1);
3114f4f7c7bSLiu Zhe         double expectValueA2columns = 7;
3124f4f7c7bSLiu Zhe         double expectValueB2columns = 0.0;
3134f4f7c7bSLiu Zhe         double expectValueC2columns = 0.0;
3144f4f7c7bSLiu Zhe 
3154f4f7c7bSLiu Zhe         //Verify results after execute delete Entire Columns make the whole existing cell range moves left
3164f4f7c7bSLiu Zhe         assertEquals("Verify value of A2 after delete Entire Columns make the whole existing cell range moves left.",
3174f4f7c7bSLiu Zhe     		expectValueA2columns, cellA2.getValue(),0);
3184f4f7c7bSLiu Zhe         assertEquals("Verify value of B2 after delete Entire Columns make the whole existing cell range moves left.",
3194f4f7c7bSLiu Zhe     		expectValueB2columns, cellB2.getValue(),0);
3204f4f7c7bSLiu Zhe         assertEquals("Verify value of C2 after delete Entire Columns make the whole existing cell range moves left.",
3214f4f7c7bSLiu Zhe     		expectValueC2columns, cellC2.getValue(),0);
3224f4f7c7bSLiu Zhe 
3234f4f7c7bSLiu Zhe     }
3244f4f7c7bSLiu Zhe 
3254f4f7c7bSLiu Zhe }
3264f4f7c7bSLiu Zhe 
3274f4f7c7bSLiu Zhe 
328