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 22 23 24 package ifc.sheet; 25 26 import lib.MultiMethodTest; 27 import lib.Status; 28 import lib.StatusException; 29 30 import com.sun.star.sheet.XScenarios; 31 import com.sun.star.table.CellRangeAddress; 32 33 /** 34 * Testing <code>com.sun.star.sheet.XScenarios</code> 35 * interface methods : 36 * <ul> 37 * <li><code> addNewByName()</code></li> 38 * <li><code> removeByName()</code></li> 39 * </ul> <p> 40 * This test needs the following object relations : 41 * <ul> 42 * <li> <code>'ADDR'</code> (of type <code>CellRangeAddress[]</code>): 43 * the array of cell range addresses for adding new scenario </li> 44 * <ul> <p> 45 * @see com.sun.star.sheet.XScenarios 46 */ 47 public class _XScenarios extends MultiMethodTest { 48 49 public XScenarios oObj = null; 50 51 /** 52 * Test adds new scenario, stores name of this scenario and checks that 53 * scenario with this name is present in collection. <p> 54 * Has <b> OK </b> status if the new scenario is present in collection. <p> 55 */ _addNewByName()56 public void _addNewByName() { 57 CellRangeAddress[] oAddr = (CellRangeAddress[]) 58 tEnv.getObjRelation("ADDR"); 59 if (oAddr == null) throw new StatusException(Status.failed 60 ("Relation 'ADDR' not found")); 61 62 oObj.addNewByName("XScenarios", oAddr, "new"); 63 tRes.tested("addNewByName()",oObj.hasByName("XScenarios")); 64 } 65 66 /** 67 * Test removes the scenario with stored name and checks that scenario 68 * with this name isn't present in collection. <p> 69 * Has <b> OK </b> status if the scenario with stored name isn't present in 70 * collection after it was removed. <p> 71 * The following method tests are to be completed successfully before : 72 * <ul> 73 * <li> <code> addNewByName() </code> : to have name of the scenario </li> 74 * </ul> 75 */ _removeByName()76 public void _removeByName() { 77 requiredMethod("addNewByName()"); 78 oObj.removeByName("XScenarios"); 79 tRes.tested("removeByName()",!oObj.hasByName("XScenarios")); 80 } 81 82 83 } // EOC _XScenarios 84 85