xref: /AOO41X/main/qadevOOo/tests/java/ifc/drawing/_XConnectorShape.java (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 package ifc.drawing;
29 
30 import lib.MultiMethodTest;
31 import lib.Status;
32 import lib.StatusException;
33 
34 import com.sun.star.drawing.ConnectionType;
35 import com.sun.star.drawing.XConnectableShape;
36 import com.sun.star.drawing.XConnectorShape;
37 import com.sun.star.drawing.XShape;
38 import com.sun.star.uno.UnoRuntime;
39 
40 /**
41 * Testing <code>com.sun.star.drawing.XConnectorShape</code>
42 * interface methods :
43 * <ul>
44 *  <li><code> connectStart()</code></li>
45 *  <li><code> connectEnd()</code></li>
46 *  <li><code> disconnectBegin()</code></li>
47 *  <li><code> disconnectEnd()</code></li>
48 * </ul> <p>
49 * This test needs the following object relations :
50 * <ul>
51 *  <li> <code>'XConnectorShape.Shapes'</code>
52 *  (of type <code>com.sun.star.drawing.XShape[]</code>):
53 *   an array of two shapes which <b>must</b> implement
54 *   <code>com.sun.star.drawing.XConnectableShape</code>
55 *   interface and are used for being connected by
56 *   connector shape.</li>
57 * <ul> <p>
58 * Test is <b> NOT </b> multithread compilant. <p>
59 * @see com.sun.star.drawing.XConnectorShape
60 */
61 public class _XConnectorShape extends MultiMethodTest {
62 
63     public XConnectorShape oObj = null;        //oObj filled by MultiMethodTest
64     private XConnectableShape shape1 = null,
65         shape2 = null ;
66 
67     /**
68      * Retrieves object relation.
69      * @throw StatusException If the relation is not found or shapes don't
70      * support <code>XConnectableShape</code> interface.
71      */
72     public void before() {
73         log.println("No shapes implementing XConnectableShape still found.");
74         XShape[] shapes = (XShape[])
75             tEnv.getObjRelation("XConnectorShape.Shapes") ;
76         if (shapes == null) throw new StatusException(Status.failed
77             ("Relation not found.")) ;
78         shape1 = (XConnectableShape) UnoRuntime.queryInterface
79             (XConnectableShape.class, shapes[0]) ;
80         shape2 = (XConnectableShape) UnoRuntime.queryInterface
81             (XConnectableShape.class, shapes[1]) ;
82         if (shape1 == null || shape2 == null) throw new StatusException
83             (Status.failed("Shapes don't implement XConnectableShape"+
84                 " interface.")) ;
85     }
86 
87 
88     /**
89     * Test calls the method. <p>
90     * Has <b> OK </b> status if the method successfully returns
91     * and no exceptions were thrown. <p>
92     */
93     public void _connectStart() {
94         oObj.connectStart(shape1, ConnectionType.AUTO);
95 
96         tRes.tested("connectStart()", true) ;
97     }
98 
99     /**
100     * Test calls the method. <p>
101     * Has <b> OK </b> status if the method successfully returns
102     * and no exceptions were thrown. <p>
103     */
104     public void _connectEnd() {
105         oObj.connectEnd(shape2, ConnectionType.AUTO);
106 
107         tRes.tested("connectEnd()", true) ;
108     }
109 
110     /**
111     * Test calls the method. <p>
112     * Has <b> OK </b> status if the method successfully returns
113     * and no exceptions were thrown. <p>
114     * The following method tests are to be completed successfully before :
115     * <ul>
116     *  <li> <code> connectStart() </code> : first shape needs to be
117     *    connected. </li>
118     * </ul>
119     */
120     public void _disconnectBegin() {
121         requiredMethod("connectStart()");
122 
123         oObj.disconnectBegin(shape1);
124 
125         tRes.tested("disconnectBegin()", true) ;
126     }
127 
128     /**
129     * Test calls the method. <p>
130     * Has <b> OK </b> status if the method successfully returns
131     * and no exceptions were thrown. <p>
132     * The following method tests are to be completed successfully before :
133     * <ul>
134     *  <li> <code> connectEnd() </code> : first shape needs to be
135     *    connected. </li>
136     * </ul>
137     */
138     public void _disconnectEnd() {
139         requiredMethod("connectEnd()");
140 
141         oObj.disconnectEnd(shape2);
142 
143         tRes.tested("disconnectEnd()", true) ;
144     }
145 }
146 
147 
148