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: _XShapeBinder.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
;
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
;
42 * Testing <code>com.sun.star.drawing.XShapeBinder</code>
45 * <li><code> bind()</code></li>
46 * <li><code> unbind()</code></li>
48 * This test needs the following object relations :
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>
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;
60 int countBeforeBind
= 0;
61 XShapes oShapes
= null;
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
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
);
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 :
94 * <li> <code> bind() </code> : to create a shape group </li>
97 public void _unbind () {
98 requiredMethod("bind()");
99 boolean result
= false;
101 // get the current thread's holder
102 log
.println("unbinding the shape...");
105 int countAfterUnbind
= oShapes
.getCount();
106 log
.println("Count after unbind:" + countAfterUnbind
);
107 result
= countAfterUnbind
>= countBeforeBind
;
109 tRes
.tested("unbind()", result
);