1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 package fvt.gui.sc.sheet;
22 
23 import static org.junit.Assert.*;
24 import static testlib.gui.UIMap.*;
25 
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Rule;
29 import org.junit.Test;
30 import org.openoffice.test.common.Logger;
31 
32 import testlib.gui.AppTool;
33 
34 /**
35  * Before running the testing class, you need specify the AOO location firstly
36  * with system property openoffice.home.
37  *
38  *
39  */
40 
41 public class Sheets {
42 
43 	@Rule
44 	public Logger log = Logger.getLogger(this);
45 
46 	@Before
setUp()47 	public void setUp() throws Exception {
48 		app.start(true);
49 		AppTool.newSpreadsheet();
50 	}
51 
52 	@After
tearDown()53 	public void tearDown() throws Exception {
54 		app.stop();
55 	}
56 
57 	/**
58 	 * Insert one sheet in different place
59 	 *
60 	 * @throws Exception
61 	 */
62 	@Test
testInsertMultipleSheet()63 	public void testInsertMultipleSheet() {
64 		// Open Insert Sheet dialog via main menu Insert-> Sheet
65 		app.dispatch(".uno:Insert");
66 		// Change new sheet number into 3 to insert 3 new sheet one time
67 		scSheetNumber.setText("3");
68 		// Click OK button to create sheet with default setting
69 		scInsertSheetDlg.ok();
70 		// Verify new sheets have been inserted before Sheet1
71 		app.dispatch(".uno:SelectTables");
72 		// To support multi-language, just verify the number in the sheet name
73 		assertTrue("The first sheet name not contain 4",scSheetsList.getItemsText()[0].contains("4"));
74 		assertTrue("The second sheet name not contain 5",scSheetsList.getItemsText()[1].contains("5"));
75 		assertTrue("The third sheet name not contain 6",scSheetsList.getItemsText()[2].contains("6"));
76 		assertTrue("The fourth sheet name not contain 1",scSheetsList.getItemsText()[3].contains("1"));
77 		assertTrue("The fifth sheet name not contain 2",scSheetsList.getItemsText()[4].contains("2"));
78 		assertTrue("The sixth sheet name not contain 3",scSheetsList.getItemsText()[5].contains("3"));
79 		scSelectSheetsDlg.ok();
80 	}
81 
82 	/**
83 	 * Insert one sheet in different place
84 	 *
85 	 * @throws Exception
86 	 */
87 	@Test
testInsertOneSheet()88 	public void testInsertOneSheet() {
89 		// Open Insert Sheet dialog via main menu Insert-> Sheet
90 		app.dispatch(".uno:Insert");
91 		// Click OK button to create sheet with default setting
92 		scInsertSheetDlg.ok();
93 		// Verify new sheet has been inserted before Sheet1
94 		app.dispatch(".uno:SelectTables");
95 		// To support multi-language, just verify the number in the sheet name
96 		assertTrue(scSheetsList.getItemsText()[0].contains("4"));
97 		assertTrue(scSheetsList.getItemsText()[1].contains("1"));
98 		assertTrue(scSheetsList.getItemsText()[2].contains("2"));
99 		assertTrue(scSheetsList.getItemsText()[3].contains("3"));
100 		scSelectSheetsDlg.ok();
101 	}
102 }
103