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 
32*424494b0SLi Feng Wang import testlib.gui.AppTool;
33*424494b0SLi 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 
41*424494b0SLi Feng Wang public class Sheets {
4294794f51SLiu Zhe 
435d495d4bSLiu Zhe 	@Before
445d495d4bSLiu Zhe 	public void setUp() throws Exception {
454d3496b1SLiu Zhe 		app.start(true);
46*424494b0SLi Feng Wang 		AppTool.newSpreadsheet();
475d495d4bSLiu Zhe 	}
485d495d4bSLiu Zhe 
495d495d4bSLiu Zhe 	@After
505d495d4bSLiu Zhe 	public void tearDown() throws Exception {
51*424494b0SLi Feng Wang 		app.stop();
525d495d4bSLiu Zhe 	}
5394794f51SLiu Zhe 
545d495d4bSLiu Zhe 	/**
555d495d4bSLiu Zhe 	 * Insert one sheet in different place
5622a14f28SLiu Zhe 	 *
575d495d4bSLiu Zhe 	 * @throws Exception
585d495d4bSLiu Zhe 	 */
595d495d4bSLiu Zhe 	@Test
6022a14f28SLiu Zhe 	public void testInsertMultipleSheet() {
6122a14f28SLiu Zhe 		// Open Insert Sheet dialog via main menu Insert-> Sheet
623816404dSLiu Zhe 		app.dispatch(".uno:Insert");
6322a14f28SLiu Zhe 		// Change new sheet number into 3 to insert 3 new sheet one time
64b4d2d410SLiu Zhe 		scSheetNumber.setText("3");
6522a14f28SLiu Zhe 		// Click OK button to create sheet with default setting
66b4d2d410SLiu Zhe 		scInsertSheetDlg.ok();
6722a14f28SLiu Zhe 		// Verify new sheets have been inserted before Sheet1
683816404dSLiu Zhe 		app.dispatch(".uno:SelectTables");
693816404dSLiu Zhe 		// To support multi-language, just verify the number in the sheet name
70*424494b0SLi Feng Wang 		assertTrue("The first sheet name not contain 4",scSheetsList.getItemsText()[0].contains("4"));
71*424494b0SLi Feng Wang 		assertTrue("The second sheet name not contain 5",scSheetsList.getItemsText()[1].contains("5"));
72*424494b0SLi Feng Wang 		assertTrue("The third sheet name not contain 6",scSheetsList.getItemsText()[2].contains("6"));
73*424494b0SLi Feng Wang 		assertTrue("The fourth sheet name not contain 1",scSheetsList.getItemsText()[3].contains("1"));
74*424494b0SLi Feng Wang 		assertTrue("The fifth sheet name not contain 2",scSheetsList.getItemsText()[4].contains("2"));
75*424494b0SLi Feng Wang 		assertTrue("The sixth sheet name not contain 3",scSheetsList.getItemsText()[5].contains("3"));
76b4d2d410SLiu Zhe 		scSelectSheetsDlg.ok();
775d495d4bSLiu Zhe 	}
7894794f51SLiu Zhe 
795d495d4bSLiu Zhe 	/**
805d495d4bSLiu Zhe 	 * Insert one sheet in different place
8122a14f28SLiu Zhe 	 *
825d495d4bSLiu Zhe 	 * @throws Exception
835d495d4bSLiu Zhe 	 */
845d495d4bSLiu Zhe 	@Test
8522a14f28SLiu Zhe 	public void testInsertOneSheet() {
8622a14f28SLiu Zhe 		// Open Insert Sheet dialog via main menu Insert-> Sheet
873816404dSLiu Zhe 		app.dispatch(".uno:Insert");
8822a14f28SLiu Zhe 		// Click OK button to create sheet with default setting
89b4d2d410SLiu Zhe 		scInsertSheetDlg.ok();
9022a14f28SLiu Zhe 		// Verify new sheet has been inserted before Sheet1
913816404dSLiu Zhe 		app.dispatch(".uno:SelectTables");
923816404dSLiu Zhe 		// To support multi-language, just verify the number in the sheet name
93b4d2d410SLiu Zhe 		assertTrue(scSheetsList.getItemsText()[0].contains("4"));
94b4d2d410SLiu Zhe 		assertTrue(scSheetsList.getItemsText()[1].contains("1"));
95b4d2d410SLiu Zhe 		assertTrue(scSheetsList.getItemsText()[2].contains("2"));
96b4d2d410SLiu Zhe 		assertTrue(scSheetsList.getItemsText()[3].contains("3"));
97b4d2d410SLiu Zhe 		scSelectSheetsDlg.ok();
985d495d4bSLiu Zhe 	}
995d495d4bSLiu Zhe }
100