1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package ifc.drawing; 25 26 import lib.MultiMethodTest; 27 import lib.Status; 28 import lib.StatusException; 29 30 import com.sun.star.drawing.ConnectionType; 31 import com.sun.star.drawing.XConnectableShape; 32 import com.sun.star.drawing.XConnectorShape; 33 import com.sun.star.drawing.XShape; 34 import com.sun.star.uno.UnoRuntime; 35 36 /** 37 * Testing <code>com.sun.star.drawing.XConnectorShape</code> 38 * interface methods : 39 * <ul> 40 * <li><code> connectStart()</code></li> 41 * <li><code> connectEnd()</code></li> 42 * <li><code> disconnectBegin()</code></li> 43 * <li><code> disconnectEnd()</code></li> 44 * </ul> <p> 45 * This test needs the following object relations : 46 * <ul> 47 * <li> <code>'XConnectorShape.Shapes'</code> 48 * (of type <code>com.sun.star.drawing.XShape[]</code>): 49 * an array of two shapes which <b>must</b> implement 50 * <code>com.sun.star.drawing.XConnectableShape</code> 51 * interface and are used for being connected by 52 * connector shape.</li> 53 * <ul> <p> 54 * Test is <b> NOT </b> multithread compilant. <p> 55 * @see com.sun.star.drawing.XConnectorShape 56 */ 57 public class _XConnectorShape extends MultiMethodTest { 58 59 public XConnectorShape oObj = null; //oObj filled by MultiMethodTest 60 private XConnectableShape shape1 = null, 61 shape2 = null ; 62 63 /** 64 * Retrieves object relation. 65 * @throw StatusException If the relation is not found or shapes don't 66 * support <code>XConnectableShape</code> interface. 67 */ before()68 public void before() { 69 log.println("No shapes implementing XConnectableShape still found."); 70 XShape[] shapes = (XShape[]) 71 tEnv.getObjRelation("XConnectorShape.Shapes") ; 72 if (shapes == null) throw new StatusException(Status.failed 73 ("Relation not found.")) ; 74 shape1 = (XConnectableShape) UnoRuntime.queryInterface 75 (XConnectableShape.class, shapes[0]) ; 76 shape2 = (XConnectableShape) UnoRuntime.queryInterface 77 (XConnectableShape.class, shapes[1]) ; 78 if (shape1 == null || shape2 == null) throw new StatusException 79 (Status.failed("Shapes don't implement XConnectableShape"+ 80 " interface.")) ; 81 } 82 83 84 /** 85 * Test calls the method. <p> 86 * Has <b> OK </b> status if the method successfully returns 87 * and no exceptions were thrown. <p> 88 */ _connectStart()89 public void _connectStart() { 90 oObj.connectStart(shape1, ConnectionType.AUTO); 91 92 tRes.tested("connectStart()", true) ; 93 } 94 95 /** 96 * Test calls the method. <p> 97 * Has <b> OK </b> status if the method successfully returns 98 * and no exceptions were thrown. <p> 99 */ _connectEnd()100 public void _connectEnd() { 101 oObj.connectEnd(shape2, ConnectionType.AUTO); 102 103 tRes.tested("connectEnd()", true) ; 104 } 105 106 /** 107 * Test calls the method. <p> 108 * Has <b> OK </b> status if the method successfully returns 109 * and no exceptions were thrown. <p> 110 * The following method tests are to be completed successfully before : 111 * <ul> 112 * <li> <code> connectStart() </code> : first shape needs to be 113 * connected. </li> 114 * </ul> 115 */ _disconnectBegin()116 public void _disconnectBegin() { 117 requiredMethod("connectStart()"); 118 119 oObj.disconnectBegin(shape1); 120 121 tRes.tested("disconnectBegin()", true) ; 122 } 123 124 /** 125 * Test calls the method. <p> 126 * Has <b> OK </b> status if the method successfully returns 127 * and no exceptions were thrown. <p> 128 * The following method tests are to be completed successfully before : 129 * <ul> 130 * <li> <code> connectEnd() </code> : first shape needs to be 131 * connected. </li> 132 * </ul> 133 */ _disconnectEnd()134 public void _disconnectEnd() { 135 requiredMethod("connectEnd()"); 136 137 oObj.disconnectEnd(shape2); 138 139 tRes.tested("disconnectEnd()", true) ; 140 } 141 } 142 143 144