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 	@Before
44 	public void setUp() throws Exception {
45 		app.start(true);
46 		AppTool.newSpreadsheet();
47 	}
48 
49 	@After
50 	public void tearDown() throws Exception {
51 		app.stop();
52 	}
53 
54 	/**
55 	 * Insert one sheet in different place
56 	 *
57 	 * @throws Exception
58 	 */
59 	@Test
60 	public void testInsertMultipleSheet() {
61 		// Open Insert Sheet dialog via main menu Insert-> Sheet
62 		app.dispatch(".uno:Insert");
63 		// Change new sheet number into 3 to insert 3 new sheet one time
64 		scSheetNumber.setText("3");
65 		// Click OK button to create sheet with default setting
66 		scInsertSheetDlg.ok();
67 		// Verify new sheets have been inserted before Sheet1
68 		app.dispatch(".uno:SelectTables");
69 		// To support multi-language, just verify the number in the sheet name
70 		assertTrue("The first sheet name not contain 4",scSheetsList.getItemsText()[0].contains("4"));
71 		assertTrue("The second sheet name not contain 5",scSheetsList.getItemsText()[1].contains("5"));
72 		assertTrue("The third sheet name not contain 6",scSheetsList.getItemsText()[2].contains("6"));
73 		assertTrue("The fourth sheet name not contain 1",scSheetsList.getItemsText()[3].contains("1"));
74 		assertTrue("The fifth sheet name not contain 2",scSheetsList.getItemsText()[4].contains("2"));
75 		assertTrue("The sixth sheet name not contain 3",scSheetsList.getItemsText()[5].contains("3"));
76 		scSelectSheetsDlg.ok();
77 	}
78 
79 	/**
80 	 * Insert one sheet in different place
81 	 *
82 	 * @throws Exception
83 	 */
84 	@Test
85 	public void testInsertOneSheet() {
86 		// Open Insert Sheet dialog via main menu Insert-> Sheet
87 		app.dispatch(".uno:Insert");
88 		// Click OK button to create sheet with default setting
89 		scInsertSheetDlg.ok();
90 		// Verify new sheet has been inserted before Sheet1
91 		app.dispatch(".uno:SelectTables");
92 		// To support multi-language, just verify the number in the sheet name
93 		assertTrue(scSheetsList.getItemsText()[0].contains("4"));
94 		assertTrue(scSheetsList.getItemsText()[1].contains("1"));
95 		assertTrue(scSheetsList.getItemsText()[2].contains("2"));
96 		assertTrue(scSheetsList.getItemsText()[3].contains("3"));
97 		scSelectSheetsDlg.ok();
98 	}
99 }
100