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.drawing;
25 
26 import lib.MultiMethodTest;
27 import util.XInstCreator;
28 
29 import com.sun.star.drawing.XShape;
30 import com.sun.star.drawing.XShapes;
31 import com.sun.star.uno.XInterface;
32 
33 
34 /**
35 * Testing <code>com.sun.star.drawing.XShapes</code>
36 * interface methods :
37 * <ul>
38 *  <li><code> add()</code></li>
39 *  <li><code> remove()</code></li>
40 * </ul> <p>
41 * This test needs the following object relations :
42 * <ul>
43 *  <li> <code>'Shape'</code> (of type <code>XShape</code>):
44 *   a shape which can be inserted into shape collection. </li>
45 * <ul> <p>
46 * Test is <b> NOT </b> multithread compilant. <p>
47 * @see com.sun.star.drawing.XShapes
48 */
49 public class _XShapes extends MultiMethodTest {
50 
51     public XShapes oObj = null;                // oObj filled by MultiMethodTest
52     XInstCreator shape = null;
53     XInterface oShape = null;
54 
55 
56     /**
57     * Retrieves a shape from relation and adds it to the collection.
58     * Number of shapes is checked before and after adding.<p>
59     * Has <b> OK </b> status if after adding number of shapes increases by
60     * 1. <p>
61     */
_add()62     public void _add () {
63 
64         boolean result = false;
65         shape = (XInstCreator)tEnv.getObjRelation("Shape");
66         oShape = shape.createInstance();
67         XShape oSh = (XShape) oShape;
68 
69         log.println("testing add() ... ");
70 
71         int cntBefore = oObj.getCount();
72         oObj.add(oSh);
73         int cntAfter = oObj.getCount();
74         result = cntBefore + 1 == cntAfter ;
75 
76         tRes.tested("add()", result);
77     }
78 
79     /**
80     * Removes the shape added before from the collection.
81     * Number of shapes is checked before and after removing.<p>
82     * Has <b> OK </b> status if after removing number of shapes decreases by
83     * 1. <p>
84     * The following method tests are to be completed successfully before :
85     * <ul>
86     *  <li> <code> add() </code> : a shape added. </li>
87     * </ul>
88     */
_remove()89     public void _remove () {
90         requiredMethod("add()");
91         boolean result = false;
92 
93         log.println("removing the shape...");
94 
95         int cntBefore = oObj.getCount();
96         oObj.remove((XShape) oShape);
97         int cntAfter = oObj.getCount();
98         result = cntBefore == cntAfter + 1;
99 
100         tRes.tested("remove()", result);
101     }
102 
103 }
104 
105 
106