2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
23 import lib
.StatusException
;
25 import com
.sun
.star
.sheet
.XScenarios
;
26 import com
.sun
.star
.table
.CellRangeAddress
;
29 * Testing <code>com.sun.star.sheet.XScenarios</code>
32 * <li><code> addNewByName()</code></li>
33 * <li><code> removeByName()</code></li>
35 * This test needs the following object relations :
37 * <li> <code>'ADDR'</code> (of type <code>CellRangeAddress[]</code>):
38 * the array of cell range addresses for adding new scenario </li>
40 * @see com.sun.star.sheet.XScenarios
42 public class _XScenarios
extends MultiMethodTest
{
44 public XScenarios oObj
= null;
47 * Test adds new scenario, stores name of this scenario and checks that
48 * scenario with this name is present in collection. <p>
49 * Has <b> OK </b> status if the new scenario is present in collection. <p>
51 public void _addNewByName() {
52 CellRangeAddress
[] oAddr
= (CellRangeAddress
[])
53 tEnv
.getObjRelation("ADDR");
54 if (oAddr
== null) throw new StatusException(Status
.failed
55 ("Relation 'ADDR' not found"));
57 oObj
.addNewByName("XScenarios", oAddr
, "new");
58 tRes
.tested("addNewByName()",oObj
.hasByName("XScenarios"));
62 * Test removes the scenario with stored name and checks that scenario
63 * with this name isn't present in collection. <p>
64 * Has <b> OK </b> status if the scenario with stored name isn't present in
65 * collection after it was removed. <p>
66 * The following method tests are to be completed successfully before :
68 * <li> <code> addNewByName() </code> : to have name of the scenario </li>
71 public void _removeByName() {
72 requiredMethod("addNewByName()");
73 oObj
.removeByName("XScenarios");
74 tRes
.tested("removeByName()",!oObj
.hasByName("XScenarios"));