1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package ifc.sheet; 29 30 import lib.MultiMethodTest; 31 import lib.Status; 32 import lib.StatusException; 33 34 import com.sun.star.sheet.XScenarios; 35 import com.sun.star.table.CellRangeAddress; 36 37 /** 38 * Testing <code>com.sun.star.sheet.XScenarios</code> 39 * interface methods : 40 * <ul> 41 * <li><code> addNewByName()</code></li> 42 * <li><code> removeByName()</code></li> 43 * </ul> <p> 44 * This test needs the following object relations : 45 * <ul> 46 * <li> <code>'ADDR'</code> (of type <code>CellRangeAddress[]</code>): 47 * the array of cell range addresses for adding new scenario </li> 48 * <ul> <p> 49 * @see com.sun.star.sheet.XScenarios 50 */ 51 public class _XScenarios extends MultiMethodTest { 52 53 public XScenarios oObj = null; 54 55 /** 56 * Test adds new scenario, stores name of this scenario and checks that 57 * scenario with this name is present in collection. <p> 58 * Has <b> OK </b> status if the new scenario is present in collection. <p> 59 */ 60 public void _addNewByName() { 61 CellRangeAddress[] oAddr = (CellRangeAddress[]) 62 tEnv.getObjRelation("ADDR"); 63 if (oAddr == null) throw new StatusException(Status.failed 64 ("Relation 'ADDR' not found")); 65 66 oObj.addNewByName("XScenarios", oAddr, "new"); 67 tRes.tested("addNewByName()",oObj.hasByName("XScenarios")); 68 } 69 70 /** 71 * Test removes the scenario with stored name and checks that scenario 72 * with this name isn't present in collection. <p> 73 * Has <b> OK </b> status if the scenario with stored name isn't present in 74 * collection after it was removed. <p> 75 * The following method tests are to be completed successfully before : 76 * <ul> 77 * <li> <code> addNewByName() </code> : to have name of the scenario </li> 78 * </ul> 79 */ 80 public void _removeByName() { 81 requiredMethod("addNewByName()"); 82 oObj.removeByName("XScenarios"); 83 tRes.tested("removeByName()",!oObj.hasByName("XScenarios")); 84 } 85 86 87 } // EOC _XScenarios 88 89