1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XShapes.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
34 import util
.XInstCreator
;
36 import com
.sun
.star
.drawing
.XShape
;
37 import com
.sun
.star
.drawing
.XShapes
;
38 import com
.sun
.star
.uno
.XInterface
;
42 * Testing <code>com.sun.star.drawing.XShapes</code>
45 * <li><code> add()</code></li>
46 * <li><code> remove()</code></li>
48 * This test needs the following object relations :
50 * <li> <code>'Shape'</code> (of type <code>XShape</code>):
51 * a shape which can be inserted into shape collection. </li>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.drawing.XShapes
56 public class _XShapes
extends MultiMethodTest
{
58 public XShapes oObj
= null; // oObj filled by MultiMethodTest
59 XInstCreator shape
= null;
60 XInterface oShape
= null;
64 * Retrieves a shape from relation and adds it to the collection.
65 * Number of shapes is checked before and after adding.<p>
66 * Has <b> OK </b> status if after adding number of shapes increases by
71 boolean result
= false;
72 shape
= (XInstCreator
)tEnv
.getObjRelation("Shape");
73 oShape
= shape
.createInstance();
74 XShape oSh
= (XShape
) oShape
;
76 log
.println("testing add() ... ");
78 int cntBefore
= oObj
.getCount();
80 int cntAfter
= oObj
.getCount();
81 result
= cntBefore
+ 1 == cntAfter
;
83 tRes
.tested("add()", result
);
87 * Removes the shape added before from the collection.
88 * Number of shapes is checked before and after removing.<p>
89 * Has <b> OK </b> status if after removing number of shapes decreases by
91 * The following method tests are to be completed successfully before :
93 * <li> <code> add() </code> : a shape added. </li>
96 public void _remove () {
97 requiredMethod("add()");
98 boolean result
= false;
100 log
.println("removing the shape...");
102 int cntBefore
= oObj
.getCount();
103 oObj
.remove((XShape
) oShape
);
104 int cntAfter
= oObj
.getCount();
105 result
= cntBefore
== cntAfter
+ 1;
107 tRes
.tested("remove()", result
);