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