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: _XConnectorShape.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 lib
.StatusException
;
37 import com
.sun
.star
.drawing
.ConnectionType
;
38 import com
.sun
.star
.drawing
.XConnectableShape
;
39 import com
.sun
.star
.drawing
.XConnectorShape
;
40 import com
.sun
.star
.drawing
.XShape
;
41 import com
.sun
.star
.uno
.UnoRuntime
;
44 * Testing <code>com.sun.star.drawing.XConnectorShape</code>
47 * <li><code> connectStart()</code></li>
48 * <li><code> connectEnd()</code></li>
49 * <li><code> disconnectBegin()</code></li>
50 * <li><code> disconnectEnd()</code></li>
52 * This test needs the following object relations :
54 * <li> <code>'XConnectorShape.Shapes'</code>
55 * (of type <code>com.sun.star.drawing.XShape[]</code>):
56 * an array of two shapes which <b>must</b> implement
57 * <code>com.sun.star.drawing.XConnectableShape</code>
58 * interface and are used for being connected by
59 * connector shape.</li>
61 * Test is <b> NOT </b> multithread compilant. <p>
62 * @see com.sun.star.drawing.XConnectorShape
64 public class _XConnectorShape
extends MultiMethodTest
{
66 public XConnectorShape oObj
= null; //oObj filled by MultiMethodTest
67 private XConnectableShape shape1
= null,
71 * Retrieves object relation.
72 * @throw StatusException If the relation is not found or shapes don't
73 * support <code>XConnectableShape</code> interface.
75 public void before() {
76 log
.println("No shapes implementing XConnectableShape still found.");
77 XShape
[] shapes
= (XShape
[])
78 tEnv
.getObjRelation("XConnectorShape.Shapes") ;
79 if (shapes
== null) throw new StatusException(Status
.failed
80 ("Relation not found.")) ;
81 shape1
= (XConnectableShape
) UnoRuntime
.queryInterface
82 (XConnectableShape
.class, shapes
[0]) ;
83 shape2
= (XConnectableShape
) UnoRuntime
.queryInterface
84 (XConnectableShape
.class, shapes
[1]) ;
85 if (shape1
== null || shape2
== null) throw new StatusException
86 (Status
.failed("Shapes don't implement XConnectableShape"+
92 * Test calls the method. <p>
93 * Has <b> OK </b> status if the method successfully returns
94 * and no exceptions were thrown. <p>
96 public void _connectStart() {
97 oObj
.connectStart(shape1
, ConnectionType
.AUTO
);
99 tRes
.tested("connectStart()", true) ;
103 * Test calls the method. <p>
104 * Has <b> OK </b> status if the method successfully returns
105 * and no exceptions were thrown. <p>
107 public void _connectEnd() {
108 oObj
.connectEnd(shape2
, ConnectionType
.AUTO
);
110 tRes
.tested("connectEnd()", true) ;
114 * Test calls the method. <p>
115 * Has <b> OK </b> status if the method successfully returns
116 * and no exceptions were thrown. <p>
117 * The following method tests are to be completed successfully before :
119 * <li> <code> connectStart() </code> : first shape needs to be
123 public void _disconnectBegin() {
124 requiredMethod("connectStart()");
126 oObj
.disconnectBegin(shape1
);
128 tRes
.tested("disconnectBegin()", true) ;
132 * Test calls the method. <p>
133 * Has <b> OK </b> status if the method successfully returns
134 * and no exceptions were thrown. <p>
135 * The following method tests are to be completed successfully before :
137 * <li> <code> connectEnd() </code> : first shape needs to be
141 public void _disconnectEnd() {
142 requiredMethod("connectEnd()");
144 oObj
.disconnectEnd(shape2
);
146 tRes
.tested("disconnectEnd()", true) ;