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 
28 import com.sun.star.sheet.XSheetAnnotations;
29 import com.sun.star.table.CellAddress;
30 
31 
32 /**
33 * Testing <code>com.sun.star.sheet.XSheetAnnotations</code>
34 * interface methods :
35 * <ul>
36 *  <li><code> insertNew()</code></li>
37 *  <li><code> removeByIndex()</code></li>
38 * </ul> <p>
39 * Test is <b> NOT </b> multithread compilant. <p>
40 * @see com.sun.star.sheet.XSheetAnnotations
41 */
42 public class _XSheetAnnotations extends MultiMethodTest {
43 
44     public XSheetAnnotations oObj = null;
45 
46     /**
47     * Adds two new annotations into collection. <p>
48     * Has <b>OK</b> status if the number of elements in collection
49     * increased by 2 after method call.
50     */
_insertNew()51     public void _insertNew(){
52         boolean bResult = false;
53 
54         int initialAmount = oObj.getCount();
55         String sAnno = oObj.toString();
56 
57         oObj.insertNew(new CellAddress((short)1, 2, 5), sAnno + "1");
58         oObj.insertNew(new CellAddress((short)1, 1, 1), sAnno + "2");
59 
60         bResult = (oObj.getCount() == 2 + initialAmount);
61         tRes.tested("insertNew()", bResult);
62     }
63 
64     /**
65     * Removes one annotation from collection. <p>
66     * Has <b>OK</b> status if the number of elements in collection
67     * decreased after method call. <p>
68     * The following method tests are to be completed successfully before :
69     * <ul>
70     *  <li> <code> insertNew </code> : to be sure at least two elements
71     *   exist in the collection.</li>
72     * </ul>
73     */
_removeByIndex()74     public void _removeByIndex(){
75         requiredMethod("insertNew()");
76         int tmpCnt = oObj.getCount();
77 
78         oObj.removeByIndex(1);
79         int newCnt = oObj.getCount();
80 
81         tRes.tested("removeByIndex()", newCnt < tmpCnt);
82     }
83 
84 } // EOC _XSheetAnnotations
85 
86 
87