Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / ifc / drawing / _XConnectorShape.java
blobef9395f33c896d2eabd3de8397701872ed412873
1 /*
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 .
19 package ifc.drawing;
21 import lib.MultiMethodTest;
22 import lib.Status;
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;
31 /**
32 * Testing <code>com.sun.star.drawing.XConnectorShape</code>
33 * interface methods :
34 * <ul>
35 * <li><code> connectStart()</code></li>
36 * <li><code> connectEnd()</code></li>
37 * <li><code> disconnectBegin()</code></li>
38 * <li><code> disconnectEnd()</code></li>
39 * </ul> <p>
40 * This test needs the following object relations :
41 * <ul>
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>
48 * <ul> <p>
49 * Test is <b> NOT </b> multithread compliant. <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,
56 shape2 = null ;
58 /**
59 * Retrieves object relation.
60 * @throw StatusException If the relation is not found or shapes don't
61 * support <code>XConnectableShape</code> interface.
63 @Override
64 public void before() {
65 log.println("No shapes implementing XConnectableShape still found.");
66 XShape[] shapes = (XShape[])
67 tEnv.getObjRelation("XConnectorShape.Shapes") ;
68 if (shapes == null) throw new StatusException(Status.failed
69 ("Relation not found.")) ;
70 shape1 = UnoRuntime.queryInterface
71 (XConnectableShape.class, shapes[0]) ;
72 shape2 = UnoRuntime.queryInterface
73 (XConnectableShape.class, shapes[1]) ;
74 if (shape1 == null || shape2 == null) throw new StatusException
75 (Status.failed("Shapes don't implement XConnectableShape"+
76 " interface.")) ;
80 /**
81 * Test calls the method. <p>
82 * Has <b> OK </b> status if the method successfully returns
83 * and no exceptions were thrown. <p>
85 public void _connectStart() {
86 oObj.connectStart(shape1, ConnectionType.AUTO);
88 tRes.tested("connectStart()", true) ;
91 /**
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 _connectEnd() {
97 oObj.connectEnd(shape2, ConnectionType.AUTO);
99 tRes.tested("connectEnd()", 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>
106 * The following method tests are to be completed successfully before :
107 * <ul>
108 * <li> <code> connectStart() </code> : first shape needs to be
109 * connected. </li>
110 * </ul>
112 public void _disconnectBegin() {
113 requiredMethod("connectStart()");
115 oObj.disconnectBegin(shape1);
117 tRes.tested("disconnectBegin()", true) ;
121 * Test calls the method. <p>
122 * Has <b> OK </b> status if the method successfully returns
123 * and no exceptions were thrown. <p>
124 * The following method tests are to be completed successfully before :
125 * <ul>
126 * <li> <code> connectEnd() </code> : first shape needs to be
127 * connected. </li>
128 * </ul>
130 public void _disconnectEnd() {
131 requiredMethod("connectEnd()");
133 oObj.disconnectEnd(shape2);
135 tRes.tested("disconnectEnd()", true) ;