180a6f5c5SLiu Zhe /************************************************************** 280a6f5c5SLiu Zhe * 380a6f5c5SLiu Zhe * Licensed to the Apache Software Foundation (ASF) under one 480a6f5c5SLiu Zhe * or more contributor license agreements. See the NOTICE file 580a6f5c5SLiu Zhe * distributed with this work for additional information 680a6f5c5SLiu Zhe * regarding copyright ownership. The ASF licenses this file 780a6f5c5SLiu Zhe * to you under the Apache License, Version 2.0 (the 880a6f5c5SLiu Zhe * "License"); you may not use this file except in compliance 980a6f5c5SLiu Zhe * with the License. You may obtain a copy of the License at 1080a6f5c5SLiu Zhe * 1180a6f5c5SLiu Zhe * http://www.apache.org/licenses/LICENSE-2.0 1280a6f5c5SLiu Zhe * 1380a6f5c5SLiu Zhe * Unless required by applicable law or agreed to in writing, 1480a6f5c5SLiu Zhe * software distributed under the License is distributed on an 1580a6f5c5SLiu Zhe * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1680a6f5c5SLiu Zhe * KIND, either express or implied. See the License for the 1780a6f5c5SLiu Zhe * specific language governing permissions and limitations 1880a6f5c5SLiu Zhe * under the License. 1980a6f5c5SLiu Zhe * 2080a6f5c5SLiu Zhe *************************************************************/ 2180a6f5c5SLiu Zhe 2280a6f5c5SLiu Zhe package fvt.gui; 2380a6f5c5SLiu Zhe 2480a6f5c5SLiu Zhe import static org.junit.Assert.*; 2580a6f5c5SLiu Zhe import static testlib.gui.AppTool.*; 2680a6f5c5SLiu Zhe import static testlib.gui.UIMap.*; 2780a6f5c5SLiu Zhe 2880a6f5c5SLiu Zhe import org.junit.After; 29*daaa1af4Scbmarcum import org.junit.AfterClass; 3080a6f5c5SLiu Zhe import org.junit.Before; 31*daaa1af4Scbmarcum import org.junit.BeforeClass; 3280a6f5c5SLiu Zhe import org.junit.Rule; 3380a6f5c5SLiu Zhe import org.junit.Test; 3480a6f5c5SLiu Zhe import org.openoffice.test.common.Logger; 3580a6f5c5SLiu Zhe 36*daaa1af4Scbmarcum import testlib.gui.AppTool; 3780a6f5c5SLiu Zhe import testlib.gui.SCTool; 3880a6f5c5SLiu Zhe 3980a6f5c5SLiu Zhe /** 4080a6f5c5SLiu Zhe * If AOO is not installed in the default directory, please specify the system 4180a6f5c5SLiu Zhe * property in your command line. <br/> 4280a6f5c5SLiu Zhe * -Dopenoffice.home= 4380a6f5c5SLiu Zhe * "Your OpenOffice installation directory which contains soffice.bin" 4480a6f5c5SLiu Zhe * 4580a6f5c5SLiu Zhe */ 4680a6f5c5SLiu Zhe public class AOOTest { 4780a6f5c5SLiu Zhe 4880a6f5c5SLiu Zhe /** 4980a6f5c5SLiu Zhe * Add Log to enable the following capabilities. 1. Take a screenshot when 5080a6f5c5SLiu Zhe * failure occurs. 2. Log any detail information. 5180a6f5c5SLiu Zhe */ 5280a6f5c5SLiu Zhe @Rule 5380a6f5c5SLiu Zhe public Logger log = Logger.getLogger(this); 5480a6f5c5SLiu Zhe 5580a6f5c5SLiu Zhe /** 56*daaa1af4Scbmarcum * Do some setup task before running class 57*daaa1af4Scbmarcum * 58*daaa1af4Scbmarcum * @throws Exception 59*daaa1af4Scbmarcum */ 60*daaa1af4Scbmarcum @BeforeClass beforeClass()61*daaa1af4Scbmarcum public static void beforeClass() { 62*daaa1af4Scbmarcum app.clean(); 63*daaa1af4Scbmarcum } 64*daaa1af4Scbmarcum 65*daaa1af4Scbmarcum /** 66*daaa1af4Scbmarcum * Clean class after testing 67*daaa1af4Scbmarcum * 68*daaa1af4Scbmarcum * @throws Exception 69*daaa1af4Scbmarcum */ 70*daaa1af4Scbmarcum @AfterClass afterClass()71*daaa1af4Scbmarcum public static void afterClass() { 72*daaa1af4Scbmarcum app.stop(); 73*daaa1af4Scbmarcum } 74*daaa1af4Scbmarcum 75*daaa1af4Scbmarcum /** 7680a6f5c5SLiu Zhe * Do some setup task before running test 7780a6f5c5SLiu Zhe * 7880a6f5c5SLiu Zhe * @throws Exception 7980a6f5c5SLiu Zhe */ 8080a6f5c5SLiu Zhe @Before setUp()8180a6f5c5SLiu Zhe public void setUp() throws Exception { 82*daaa1af4Scbmarcum app.stop(); 83*daaa1af4Scbmarcum app.start(); 8480a6f5c5SLiu Zhe } 8580a6f5c5SLiu Zhe 8680a6f5c5SLiu Zhe /** 8780a6f5c5SLiu Zhe * Clean task after testing 8880a6f5c5SLiu Zhe * 8980a6f5c5SLiu Zhe * @throws Exception 9080a6f5c5SLiu Zhe */ 9180a6f5c5SLiu Zhe @After tearDown()9280a6f5c5SLiu Zhe public void tearDown() throws Exception { 93*daaa1af4Scbmarcum // stopping app here causes a late screenshot 94*daaa1af4Scbmarcum // moved to setUp 9580a6f5c5SLiu Zhe } 9680a6f5c5SLiu Zhe 9780a6f5c5SLiu Zhe /** 9880a6f5c5SLiu Zhe * Implement test steps 9980a6f5c5SLiu Zhe */ 10080a6f5c5SLiu Zhe @Test testHello()10180a6f5c5SLiu Zhe public void testHello() { 102*daaa1af4Scbmarcum AppTool.newSpreadsheet(); 10380a6f5c5SLiu Zhe typeKeys("Hello"); 104*daaa1af4Scbmarcum String result = SCTool.getCellInput("A1"); 105*daaa1af4Scbmarcum assertEquals("assert cell A1 contents", "Hello", result); 10680a6f5c5SLiu Zhe } 10780a6f5c5SLiu Zhe 10880a6f5c5SLiu Zhe } 109