2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
23 import lib
.StatusException
;
25 import com
.sun
.star
.drawing
.ConnectionType
;
26 import com
.sun
.star
.drawing
.XConnectableShape
;
27 import com
.sun
.star
.drawing
.XConnectorShape
;
28 import com
.sun
.star
.drawing
.XShape
;
29 import com
.sun
.star
.uno
.UnoRuntime
;
32 * Testing <code>com.sun.star.drawing.XConnectorShape</code>
35 * <li><code> connectStart()</code></li>
36 * <li><code> connectEnd()</code></li>
37 * <li><code> disconnectBegin()</code></li>
38 * <li><code> disconnectEnd()</code></li>
40 * This test needs the following object relations :
42 * <li> <code>'XConnectorShape.Shapes'</code>
43 * (of type <code>com.sun.star.drawing.XShape[]</code>):
44 * an array of two shapes which <b>must</b> implement
45 * <code>com.sun.star.drawing.XConnectableShape</code>
46 * interface and are used for being connected by
47 * connector shape.</li>
49 * Test is <b> NOT </b> multithread compilant. <p>
50 * @see com.sun.star.drawing.XConnectorShape
52 public class _XConnectorShape
extends MultiMethodTest
{
54 public XConnectorShape oObj
= null; //oObj filled by MultiMethodTest
55 private XConnectableShape shape1
= null,
59 * Retrieves object relation.
60 * @throw StatusException If the relation is not found or shapes don't
61 * support <code>XConnectableShape</code> interface.
63 public void before() {
64 log
.println("No shapes implementing XConnectableShape still found.");
65 XShape
[] shapes
= (XShape
[])
66 tEnv
.getObjRelation("XConnectorShape.Shapes") ;
67 if (shapes
== null) throw new StatusException(Status
.failed
68 ("Relation not found.")) ;
69 shape1
= UnoRuntime
.queryInterface
70 (XConnectableShape
.class, shapes
[0]) ;
71 shape2
= UnoRuntime
.queryInterface
72 (XConnectableShape
.class, shapes
[1]) ;
73 if (shape1
== null || shape2
== null) throw new StatusException
74 (Status
.failed("Shapes don't implement XConnectableShape"+
80 * Test calls the method. <p>
81 * Has <b> OK </b> status if the method successfully returns
82 * and no exceptions were thrown. <p>
84 public void _connectStart() {
85 oObj
.connectStart(shape1
, ConnectionType
.AUTO
);
87 tRes
.tested("connectStart()", true) ;
91 * Test calls the method. <p>
92 * Has <b> OK </b> status if the method successfully returns
93 * and no exceptions were thrown. <p>
95 public void _connectEnd() {
96 oObj
.connectEnd(shape2
, ConnectionType
.AUTO
);
98 tRes
.tested("connectEnd()", true) ;
102 * Test calls the method. <p>
103 * Has <b> OK </b> status if the method successfully returns
104 * and no exceptions were thrown. <p>
105 * The following method tests are to be completed successfully before :
107 * <li> <code> connectStart() </code> : first shape needs to be
111 public void _disconnectBegin() {
112 requiredMethod("connectStart()");
114 oObj
.disconnectBegin(shape1
);
116 tRes
.tested("disconnectBegin()", true) ;
120 * Test calls the method. <p>
121 * Has <b> OK </b> status if the method successfully returns
122 * and no exceptions were thrown. <p>
123 * The following method tests are to be completed successfully before :
125 * <li> <code> connectEnd() </code> : first shape needs to be
129 public void _disconnectEnd() {
130 requiredMethod("connectEnd()");
132 oObj
.disconnectEnd(shape2
);
134 tRes
.tested("disconnectEnd()", true) ;