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 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import com
.sun
.star
.drawing
.XDrawPage
;
33 import com
.sun
.star
.drawing
.XShape
;
34 import com
.sun
.star
.drawing
.XShapeBinder
;
35 import com
.sun
.star
.drawing
.XShapes
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
39 * Testing <code>com.sun.star.drawing.XShapeBinder</code>
42 * <li><code> bind()</code></li>
43 * <li><code> unbind()</code></li>
45 * This test needs the following object relations :
47 * <li> <code>'DrawPage'</code> (must implement <code>XShapes</code>):
48 * the collection of shapes in a document which used to create a group.</li>
50 * Test is <b> NOT </b> multithread compilant. <p>
51 * @see com.sun.star.drawing.XShapeBinder
53 public class _XShapeBinder
extends MultiMethodTest
{
55 public XShapeBinder oObj
= null;
57 int countBeforeBind
= 0;
58 XShapes oShapes
= null;
61 * Retrieves draw page collection from relation and binds them. <p>
63 * Has <b> OK </b> status if the shape group returned is not null
64 * number of shapes in collection is 1 (shapes are binded into a single
67 public void _bind () {
68 XDrawPage dp
= (XDrawPage
) tEnv
.getObjRelation("DrawPage");
69 oShapes
= (XShapes
)UnoRuntime
.queryInterface( XShapes
.class, dp
);
70 boolean result
= false;
71 log
.println("testing bind() ... ");
72 countBeforeBind
= oShapes
.getCount();
73 log
.println("Count before bind:" + countBeforeBind
);
74 group
= oObj
.bind(oShapes
);
75 int countAfterBind
= oShapes
.getCount();
76 log
.println("Count after bind:" + countAfterBind
);
77 result
= group
!= null && countAfterBind
== 1;
79 tRes
.tested("bind()", result
);
84 * Unbinds the group created before. <p>
86 * Has <b> OK </b> status if number of shapes in collection
87 * increases after the method call. <p>
89 * The following method tests are to be completed successfully before :
91 * <li> <code> bind() </code> : to create a shape group </li>
94 public void _unbind () {
95 requiredMethod("bind()");
96 boolean result
= false;
98 // get the current thread's holder
99 log
.println("unbinding the shape...");
102 int countAfterUnbind
= oShapes
.getCount();
103 log
.println("Count after unbind:" + countAfterUnbind
);
104 result
= countAfterUnbind
>= countBeforeBind
;
106 tRes
.tested("unbind()", result
);