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