15d495d4bSLiu Zhe /**************************************************************
25d495d4bSLiu Zhe  *
35d495d4bSLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
45d495d4bSLiu Zhe  * or more contributor license agreements.  See the NOTICE file
55d495d4bSLiu Zhe  * distributed with this work for additional information
65d495d4bSLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
75d495d4bSLiu Zhe  * to you under the Apache License, Version 2.0 (the
85d495d4bSLiu Zhe  * "License"); you may not use this file except in compliance
95d495d4bSLiu Zhe  * with the License.  You may obtain a copy of the License at
105d495d4bSLiu Zhe  *
115d495d4bSLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
125d495d4bSLiu Zhe  *
135d495d4bSLiu Zhe  * Unless required by applicable law or agreed to in writing,
145d495d4bSLiu Zhe  * software distributed under the License is distributed on an
155d495d4bSLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165d495d4bSLiu Zhe  * KIND, either express or implied.  See the License for the
175d495d4bSLiu Zhe  * specific language governing permissions and limitations
185d495d4bSLiu Zhe  * under the License.
195d495d4bSLiu Zhe  *
205d495d4bSLiu Zhe  *************************************************************/
2180a6f5c5SLiu Zhe package fvt.gui.sc.sheet;
225d495d4bSLiu Zhe 
235d495d4bSLiu Zhe import static org.junit.Assert.*;
2495269d92SLiu Zhe import static testlib.gui.UIMap.*;
2595269d92SLiu Zhe 
265d495d4bSLiu Zhe import org.junit.After;
275d495d4bSLiu Zhe import org.junit.Before;
285d495d4bSLiu Zhe import org.junit.Rule;
295d495d4bSLiu Zhe import org.junit.Test;
3022a14f28SLiu Zhe import org.openoffice.test.common.Logger;
315d495d4bSLiu Zhe 
32424494b0SLi Feng Wang import testlib.gui.AppTool;
33424494b0SLi Feng Wang 
345d495d4bSLiu Zhe /**
3522a14f28SLiu Zhe  * Before running the testing class, you need specify the AOO location firstly
3622a14f28SLiu Zhe  * with system property openoffice.home.
3722a14f28SLiu Zhe  *
385d495d4bSLiu Zhe  *
395d495d4bSLiu Zhe  */
405d495d4bSLiu Zhe 
41424494b0SLi Feng Wang public class Sheets {
42*fd348426SLi Feng Wang 
43*fd348426SLi Feng Wang 	@Rule
44*fd348426SLi Feng Wang 	public Logger log = Logger.getLogger(this);
4594794f51SLiu Zhe 
465d495d4bSLiu Zhe 	@Before
setUp()475d495d4bSLiu Zhe 	public void setUp() throws Exception {
484d3496b1SLiu Zhe 		app.start(true);
49424494b0SLi Feng Wang 		AppTool.newSpreadsheet();
505d495d4bSLiu Zhe 	}
515d495d4bSLiu Zhe 
525d495d4bSLiu Zhe 	@After
tearDown()535d495d4bSLiu Zhe 	public void tearDown() throws Exception {
54424494b0SLi Feng Wang 		app.stop();
555d495d4bSLiu Zhe 	}
5694794f51SLiu Zhe 
575d495d4bSLiu Zhe 	/**
585d495d4bSLiu Zhe 	 * Insert one sheet in different place
5922a14f28SLiu Zhe 	 *
605d495d4bSLiu Zhe 	 * @throws Exception
615d495d4bSLiu Zhe 	 */
625d495d4bSLiu Zhe 	@Test
testInsertMultipleSheet()6322a14f28SLiu Zhe 	public void testInsertMultipleSheet() {
6422a14f28SLiu Zhe 		// Open Insert Sheet dialog via main menu Insert-> Sheet
653816404dSLiu Zhe 		app.dispatch(".uno:Insert");
6622a14f28SLiu Zhe 		// Change new sheet number into 3 to insert 3 new sheet one time
67b4d2d410SLiu Zhe 		scSheetNumber.setText("3");
6822a14f28SLiu Zhe 		// Click OK button to create sheet with default setting
69b4d2d410SLiu Zhe 		scInsertSheetDlg.ok();
7022a14f28SLiu Zhe 		// Verify new sheets have been inserted before Sheet1
713816404dSLiu Zhe 		app.dispatch(".uno:SelectTables");
723816404dSLiu Zhe 		// To support multi-language, just verify the number in the sheet name
73424494b0SLi Feng Wang 		assertTrue("The first sheet name not contain 4",scSheetsList.getItemsText()[0].contains("4"));
74424494b0SLi Feng Wang 		assertTrue("The second sheet name not contain 5",scSheetsList.getItemsText()[1].contains("5"));
75424494b0SLi Feng Wang 		assertTrue("The third sheet name not contain 6",scSheetsList.getItemsText()[2].contains("6"));
76424494b0SLi Feng Wang 		assertTrue("The fourth sheet name not contain 1",scSheetsList.getItemsText()[3].contains("1"));
77424494b0SLi Feng Wang 		assertTrue("The fifth sheet name not contain 2",scSheetsList.getItemsText()[4].contains("2"));
78424494b0SLi Feng Wang 		assertTrue("The sixth sheet name not contain 3",scSheetsList.getItemsText()[5].contains("3"));
79b4d2d410SLiu Zhe 		scSelectSheetsDlg.ok();
805d495d4bSLiu Zhe 	}
8194794f51SLiu Zhe 
825d495d4bSLiu Zhe 	/**
835d495d4bSLiu Zhe 	 * Insert one sheet in different place
8422a14f28SLiu Zhe 	 *
855d495d4bSLiu Zhe 	 * @throws Exception
865d495d4bSLiu Zhe 	 */
875d495d4bSLiu Zhe 	@Test
testInsertOneSheet()8822a14f28SLiu Zhe 	public void testInsertOneSheet() {
8922a14f28SLiu Zhe 		// Open Insert Sheet dialog via main menu Insert-> Sheet
903816404dSLiu Zhe 		app.dispatch(".uno:Insert");
9122a14f28SLiu Zhe 		// Click OK button to create sheet with default setting
92b4d2d410SLiu Zhe 		scInsertSheetDlg.ok();
9322a14f28SLiu Zhe 		// Verify new sheet has been inserted before Sheet1
943816404dSLiu Zhe 		app.dispatch(".uno:SelectTables");
953816404dSLiu Zhe 		// To support multi-language, just verify the number in the sheet name
96b4d2d410SLiu Zhe 		assertTrue(scSheetsList.getItemsText()[0].contains("4"));
97b4d2d410SLiu Zhe 		assertTrue(scSheetsList.getItemsText()[1].contains("1"));
98b4d2d410SLiu Zhe 		assertTrue(scSheetsList.getItemsText()[2].contains("2"));
99b4d2d410SLiu Zhe 		assertTrue(scSheetsList.getItemsText()[3].contains("3"));
100b4d2d410SLiu Zhe 		scSelectSheetsDlg.ok();
1015d495d4bSLiu Zhe 	}
1025d495d4bSLiu Zhe }
103