Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / drawing / _XShapeBinder.java
blobc8cee45c14e71e63790a0381e27421604f5ba933
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XShapeBinder.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.drawing;
33 import lib.MultiMethodTest;
35 import com.sun.star.drawing.XDrawPage;
36 import com.sun.star.drawing.XShape;
37 import com.sun.star.drawing.XShapeBinder;
38 import com.sun.star.drawing.XShapes;
39 import com.sun.star.uno.UnoRuntime;
41 /**
42 * Testing <code>com.sun.star.drawing.XShapeBinder</code>
43 * interface methods :
44 * <ul>
45 * <li><code> bind()</code></li>
46 * <li><code> unbind()</code></li>
47 * </ul> <p>
48 * This test needs the following object relations :
49 * <ul>
50 * <li> <code>'DrawPage'</code> (must implement <code>XShapes</code>):
51 * the collection of shapes in a document which used to create a group.</li>
52 * <ul> <p>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.drawing.XShapeBinder
56 public class _XShapeBinder extends MultiMethodTest {
58 public XShapeBinder oObj = null;
59 XShape group = null;
60 int countBeforeBind = 0;
61 XShapes oShapes = null;
63 /**
64 * Retrieves draw page collection from relation and binds them. <p>
66 * Has <b> OK </b> status if the shape group returned is not null
67 * number of shapes in collection is 1 (shapes are binded into a single
68 * shape). <p>
70 public void _bind () {
71 XDrawPage dp = (XDrawPage) tEnv.getObjRelation("DrawPage");
72 oShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, dp );
73 boolean result = false;
74 log.println("testing bind() ... ");
75 countBeforeBind = oShapes.getCount();
76 log.println("Count before bind:" + countBeforeBind);
77 group = oObj.bind(oShapes);
78 int countAfterBind = oShapes.getCount();
79 log.println("Count after bind:" + countAfterBind);
80 result = group != null && countAfterBind == 1;
82 tRes.tested("bind()", result);
86 /**
87 * Unbinds the group created before. <p>
89 * Has <b> OK </b> status if number of shapes in collection
90 * increases after the method call. <p>
92 * The following method tests are to be completed successfully before :
93 * <ul>
94 * <li> <code> bind() </code> : to create a shape group </li>
95 * </ul>
97 public void _unbind () {
98 requiredMethod("bind()");
99 boolean result = false;
101 // get the current thread's holder
102 log.println("unbinding the shape...");
104 oObj.unbind(group);
105 int countAfterUnbind = oShapes.getCount();
106 log.println("Count after unbind:" + countAfterUnbind);
107 result = countAfterUnbind >= countBeforeBind;
109 tRes.tested("unbind()", result);