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
;
22 import util
.XInstCreator
;
24 import com
.sun
.star
.drawing
.XShape
;
25 import com
.sun
.star
.drawing
.XShapes
;
26 import com
.sun
.star
.uno
.XInterface
;
30 * Testing <code>com.sun.star.drawing.XShapes</code>
33 * <li><code> add()</code></li>
34 * <li><code> remove()</code></li>
36 * This test needs the following object relations :
38 * <li> <code>'Shape'</code> (of type <code>XShape</code>):
39 * a shape which can be inserted into shape collection. </li>
41 * Test is <b> NOT </b> multithread compliant. <p>
42 * @see com.sun.star.drawing.XShapes
44 public class _XShapes
extends MultiMethodTest
{
46 public XShapes oObj
= null; // oObj filled by MultiMethodTest
47 XInstCreator shape
= null;
48 XInterface oShape
= null;
52 * Retrieves a shape from relation and adds it to the collection.
53 * Number of shapes is checked before and after adding.<p>
54 * Has <b> OK </b> status if after adding number of shapes increases by
59 boolean result
= false;
60 shape
= (XInstCreator
)tEnv
.getObjRelation("Shape");
61 oShape
= shape
.createInstance();
62 XShape oSh
= (XShape
) oShape
;
64 log
.println("testing add() ... ");
66 int cntBefore
= oObj
.getCount();
68 int cntAfter
= oObj
.getCount();
69 result
= cntBefore
+ 1 == cntAfter
;
71 tRes
.tested("add()", result
);
75 * Removes the shape added before from the collection.
76 * Number of shapes is checked before and after removing.<p>
77 * Has <b> OK </b> status if after removing number of shapes decreases by
79 * The following method tests are to be completed successfully before :
81 * <li> <code> add() </code> : a shape added. </li>
84 public void _remove () {
85 requiredMethod("add()");
86 boolean result
= false;
88 log
.println("removing the shape...");
90 int cntBefore
= oObj
.getCount();
91 oObj
.remove((XShape
) oShape
);
92 int cntAfter
= oObj
.getCount();
93 result
= cntBefore
== cntAfter
+ 1;
95 tRes
.tested("remove()", result
);