Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / drawing / _XShapeBinder.java
blobd150aa986815bfc025b4f78cd421cb994255f143
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;
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;
38 /**
39 * Testing <code>com.sun.star.drawing.XShapeBinder</code>
40 * interface methods :
41 * <ul>
42 * <li><code> bind()</code></li>
43 * <li><code> unbind()</code></li>
44 * </ul> <p>
45 * This test needs the following object relations :
46 * <ul>
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>
49 * <ul> <p>
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;
56 XShape group = null;
57 int countBeforeBind = 0;
58 XShapes oShapes = null;
60 /**
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
65 * shape). <p>
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);
83 /**
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 :
90 * <ul>
91 * <li> <code> bind() </code> : to create a shape group </li>
92 * </ul>
94 public void _unbind () {
95 requiredMethod("bind()");
96 boolean result = false;
98 // get the current thread's holder
99 log.println("unbinding the shape...");
101 oObj.unbind(group);
102 int countAfterUnbind = oShapes.getCount();
103 log.println("Count after unbind:" + countAfterUnbind);
104 result = countAfterUnbind >= countBeforeBind;
106 tRes.tested("unbind()", result);