189070d26SLiu Zhe /**************************************************************
289070d26SLiu Zhe  *
389070d26SLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
489070d26SLiu Zhe  * or more contributor license agreements.  See the NOTICE file
589070d26SLiu Zhe  * distributed with this work for additional information
689070d26SLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
789070d26SLiu Zhe  * to you under the Apache License, Version 2.0 (the
889070d26SLiu Zhe  * "License"); you may not use this file except in compliance
989070d26SLiu Zhe  * with the License.  You may obtain a copy of the License at
1089070d26SLiu Zhe  *
1189070d26SLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
1289070d26SLiu Zhe  *
1389070d26SLiu Zhe  * Unless required by applicable law or agreed to in writing,
1489070d26SLiu Zhe  * software distributed under the License is distributed on an
1589070d26SLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1689070d26SLiu Zhe  * KIND, either express or implied.  See the License for the
1789070d26SLiu Zhe  * specific language governing permissions and limitations
1889070d26SLiu Zhe  * under the License.
1989070d26SLiu Zhe  *
2089070d26SLiu Zhe  *************************************************************/
21*80a6f5c5SLiu Zhe package fvt.gui.sc.rowcolumn;
2289070d26SLiu Zhe 
2389070d26SLiu Zhe import static org.junit.Assert.*;
24b4d2d410SLiu Zhe import static testlib.gui.AppTool.*;
2589070d26SLiu Zhe import static testlib.gui.UIMap.*;
2689070d26SLiu Zhe 
2789070d26SLiu Zhe import org.junit.After;
2889070d26SLiu Zhe import org.junit.Before;
2989070d26SLiu Zhe import org.junit.Rule;
3089070d26SLiu Zhe import org.junit.Test;
3122a14f28SLiu Zhe import org.openoffice.test.common.Logger;
3289070d26SLiu Zhe 
33b4d2d410SLiu Zhe import testlib.gui.SCTool;
3489070d26SLiu Zhe 
3589070d26SLiu Zhe public class InsertRowAndColumn {
3622a14f28SLiu Zhe 
3789070d26SLiu Zhe 	@Rule
3822a14f28SLiu Zhe 	public Logger log = Logger.getLogger(this);
3989070d26SLiu Zhe 
4089070d26SLiu Zhe 	@Before
4189070d26SLiu Zhe 	public void setUp() throws Exception {
4289070d26SLiu Zhe 		app.start();
4389070d26SLiu Zhe 		app.dispatch("private:factory/scalc");
4489070d26SLiu Zhe 		calc.waitForExistence(10, 3);
4589070d26SLiu Zhe 	}
4689070d26SLiu Zhe 
4789070d26SLiu Zhe 	@After
4889070d26SLiu Zhe 	public void tearDown() throws Exception {
4989070d26SLiu Zhe 		app.close();
5089070d26SLiu Zhe 	}
5189070d26SLiu Zhe 
5289070d26SLiu Zhe 	/**
5389070d26SLiu Zhe 	 * Insert new entire row and column
5422a14f28SLiu Zhe 	 *
5589070d26SLiu Zhe 	 * @throws Exception
5689070d26SLiu Zhe 	 */
5722a14f28SLiu Zhe 
5889070d26SLiu Zhe 	@Test
5922a14f28SLiu Zhe 	public void testInsertEntireRowColumn() {
6022a14f28SLiu Zhe 
6122a14f28SLiu Zhe 		// insert data in cell A2 and B2
62b4d2d410SLiu Zhe 		SCTool.selectRange("Sheet1.A2");
6389070d26SLiu Zhe 		typeKeys("123");
64b4d2d410SLiu Zhe 		SCTool.selectRange("Sheet1.B2");
6589070d26SLiu Zhe 		typeKeys("456");
6622a14f28SLiu Zhe 
6722a14f28SLiu Zhe 		// Set expected result after executing insert one row
6822a14f28SLiu Zhe 		String[][] expectedInsertRowResult = new String[][] { { "", "" }, { "", "" }, { "123", "456" }, };
6922a14f28SLiu Zhe 
7022a14f28SLiu Zhe 		// Select Cell A2
71b4d2d410SLiu Zhe 		SCTool.selectRange("Sheet1.A2");
7222a14f28SLiu Zhe 
7322a14f28SLiu Zhe 		// Insert one entire Row via menu
7489070d26SLiu Zhe 		calc.menuItem("Insert->Rows").select();
7522a14f28SLiu Zhe 
7622a14f28SLiu Zhe 		// Verify results after inserting one row
77b4d2d410SLiu Zhe 		assertArrayEquals("Verify results after inserting one row", expectedInsertRowResult, SCTool.getCellTexts("A1:B3"));
7822a14f28SLiu Zhe 
7922a14f28SLiu Zhe 		// Set expected result after executing insert column
8022a14f28SLiu Zhe 		String[][] expectedInsertColumnResult = new String[][] { { "", "", "" }, { "", "", "" }, { "", "123", "456" }, };
8122a14f28SLiu Zhe 		// Select Cell A3
82b4d2d410SLiu Zhe 		SCTool.selectRange("Sheet1.A3");
8322a14f28SLiu Zhe 
8422a14f28SLiu Zhe 		// Insert one entire Column via menu
8589070d26SLiu Zhe 		calc.menuItem("Insert->Columns").select();
8622a14f28SLiu Zhe 
8722a14f28SLiu Zhe 		// Verify results after inserting one column
88b4d2d410SLiu Zhe 		assertArrayEquals("Verify results after inserting one column", expectedInsertColumnResult, SCTool.getCellTexts("A1:C3"));
8922a14f28SLiu Zhe 
9089070d26SLiu Zhe 	}
9189070d26SLiu Zhe 
9289070d26SLiu Zhe }
93