Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / drawing / _XShapes.java
bloba28833819e092ccb7d78086a42f09fa91ea2262e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc.drawing;
30 import lib.MultiMethodTest;
31 import util.XInstCreator;
33 import com.sun.star.drawing.XShape;
34 import com.sun.star.drawing.XShapes;
35 import com.sun.star.uno.XInterface;
38 /**
39 * Testing <code>com.sun.star.drawing.XShapes</code>
40 * interface methods :
41 * <ul>
42 * <li><code> add()</code></li>
43 * <li><code> remove()</code></li>
44 * </ul> <p>
45 * This test needs the following object relations :
46 * <ul>
47 * <li> <code>'Shape'</code> (of type <code>XShape</code>):
48 * a shape which can be inserted into shape collection. </li>
49 * <ul> <p>
50 * Test is <b> NOT </b> multithread compilant. <p>
51 * @see com.sun.star.drawing.XShapes
53 public class _XShapes extends MultiMethodTest {
55 public XShapes oObj = null; // oObj filled by MultiMethodTest
56 XInstCreator shape = null;
57 XInterface oShape = null;
60 /**
61 * Retrieves a shape from relation and adds it to the collection.
62 * Number of shapes is checked before and after adding.<p>
63 * Has <b> OK </b> status if after adding number of shapes increases by
64 * 1. <p>
66 public void _add () {
68 boolean result = false;
69 shape = (XInstCreator)tEnv.getObjRelation("Shape");
70 oShape = shape.createInstance();
71 XShape oSh = (XShape) oShape;
73 log.println("testing add() ... ");
75 int cntBefore = oObj.getCount();
76 oObj.add(oSh);
77 int cntAfter = oObj.getCount();
78 result = cntBefore + 1 == cntAfter ;
80 tRes.tested("add()", result);
83 /**
84 * Removes the shape added before from the collection.
85 * Number of shapes is checked before and after removing.<p>
86 * Has <b> OK </b> status if after removing number of shapes decreases by
87 * 1. <p>
88 * The following method tests are to be completed successfully before :
89 * <ul>
90 * <li> <code> add() </code> : a shape added. </li>
91 * </ul>
93 public void _remove () {
94 requiredMethod("add()");
95 boolean result = false;
97 log.println("removing the shape...");
99 int cntBefore = oObj.getCount();
100 oObj.remove((XShape) oShape);
101 int cntAfter = oObj.getCount();
102 result = cntBefore == cntAfter + 1;
104 tRes.tested("remove()", result);