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 com
.sun
.star
.beans
.PropertyValue
;
24 import com
.sun
.star
.sheet
.ConditionOperator
;
25 import com
.sun
.star
.sheet
.XSheetConditionalEntries
;
26 import com
.sun
.star
.table
.CellAddress
;
29 * Testing <code>com.sun.star.sheet.XSheetConditionalEntries</code>
32 * <li><code> addNew()</code></li>
33 * <li><code> removeByIndex()</code></li>
34 * <li><code> clear()</code></li>
36 * @see com.sun.star.sheet.XSheetConditionalEntries
38 public class _XSheetConditionalEntries
extends MultiMethodTest
{
39 public XSheetConditionalEntries oObj
= null;
43 * Test adds a conditional entry to the format. <p>
44 * Has <b> OK </b> status if the method successfully returns. <p>
46 public void _addNew() {
47 nNum
= oObj
.getCount();
48 oObj
.addNew( Conditions(4) );
49 boolean res
= (nNum
+ 1) == oObj
.getCount();
51 tRes
.tested("addNew()", res
);
55 * Test calls the method and checks number of conditional entries in
57 * Has <b> OK </b> status if number of conditional entries in co0llection
58 * after method call is equal zero. <p>
59 * The following method tests are to be completed successfully before :
61 * <li> <code> addNew() </code> : to have one conditional entry in
62 * collection at least </li>
65 public void _clear() {
66 requiredMethod("removeByIndex()");
68 int anz
= oObj
.getCount();
69 tRes
.tested("clear()", anz
== 0);
73 * Test adds a conditional entry, removes entry with index 0
74 * and compares number of entries after adding to number of entries after
76 * Has <b> OK </b> status if number of entries after adding is greater
77 * than number of entries after removing. <p>
78 * The following method tests are to be completed successfully before :
80 * <li> <code> clear() </code> : to be sure that collection hasn't
84 public void _removeByIndex() {
85 requiredMethod("addNew()");
86 oObj
.removeByIndex(0);
87 int pastNum
= oObj
.getCount();
88 tRes
.tested("removeByIndex()", pastNum
== nNum
);
92 * Method creates array of property value for conditional entry using
93 * passed parameter <code>nr</code>.
94 * @param nr number of row for conditional entry
96 protected PropertyValue
[] Conditions(int nr
) {
97 PropertyValue
[] con
= new PropertyValue
[5];
98 CellAddress ca
= new CellAddress();
102 con
[0] = new PropertyValue();
103 con
[0].Name
= "StyleName";
104 con
[0].Value
= "Result2";
105 con
[1] = new PropertyValue();
106 con
[1].Name
= "Formula1";
107 con
[1].Value
= "$Sheet1.$B$"+nr
;
108 con
[2] = new PropertyValue();
109 con
[2].Name
= "Formula2";
111 con
[3] = new PropertyValue();
112 con
[3].Name
= "Operator";
113 con
[3].Value
= ConditionOperator
.EQUAL
;
114 con
[4] = new PropertyValue();
115 con
[4].Name
= "SourcePosition";
121 * Forces object environment recreation.
124 protected void after() {
125 this.disposeEnvironment();
127 } // finish class _XSheetConditionalEntries