Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / ifc / drawing / _Shape.java
blob9ef654283b864b34967df15919efc27debee21dd
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.MultiPropertyTest;
23 import com.sun.star.style.XStyle;
25 /**
26 * Testing <code>com.sun.star.drawing.Shape</code>
27 * service properties :
28 * <ul>
29 * <li><code> ZOrder</code></li>
30 * <li><code> LayerID</code></li>
31 * <li><code> LayerName</code></li>
32 * <li><code> Printable</code></li>
33 * <li><code> MoveProtect</code></li>
34 * <li><code> Name</code></li>
35 * <li><code> SizeProtect</code></li>
36 * <li><code> Style</code></li>
37 * <li><code> Transformation</code></li>
38 * </ul> <p>
39 * This test needs the following object relations :
40 * <ul>
41 * <li> <code>'Style1', 'Style2'</code>
42 * (of type <code>com.sun.star.style.XStyle</code>):
43 * relations used to change property 'Style'</li>
44 * <ul> <p>
45 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
46 * @see com.sun.star.drawing.Shape
48 public class _Shape extends MultiPropertyTest {
50 XStyle style1 = null;
51 XStyle style2 = null;
53 /**
54 * Custom tester which switches between two styles.
56 protected PropertyTester StyleTester = new PropertyTester() {
57 @Override
58 protected Object getNewValue(String propName, Object oldValue)
59 throws java.lang.IllegalArgumentException {
60 if (util.ValueComparer.equalValue(oldValue,style1))
61 return style2; else
62 return style1;
64 } ;
66 /**
67 * Custom tester for 'LayerName' property which switches two
68 * Strings ('layout' and 'controls').
70 protected PropertyTester StringTester = new PropertyTester() {
71 @Override
72 protected Object getNewValue(String propName, Object oldValue)
73 throws java.lang.IllegalArgumentException {
74 if (util.ValueComparer.equalValue(oldValue,"layout"))
75 return "controls"; else
76 return "layout";
78 } ;
80 /**
81 * Tested with custom StyleTester which switches between two
82 * styles.
84 public void _Style() {
85 log.println("Testing with custom Property tester") ;
86 style1 = (XStyle) tEnv.getObjRelation("Style1");
87 style2 = (XStyle) tEnv.getObjRelation("Style2");
88 testProperty("Style", StyleTester) ;
91 /**
92 * Tested with custom StringTester which switches two
93 * Strings ('layout' and 'controls')
95 public void _LayerName() {
96 if (tEnv.getTestCase().getObjectName().equals("SwXShape")) {
97 log.println("There is only one Layer for SwXShape");
98 log.println("Therefore this property can't be changed");
99 tRes.tested("LayerName",true);
100 } else if (tEnv.getTestCase().getObjectName().equals("ScShapeObj")) {
101 log.println("There is only one Layer for ScShapeObj");
102 log.println("Therefore this property can't be changed");
103 tRes.tested("LayerName",true);
104 } else if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
105 log.println("There is only one Layer for ScAnnotationShapeObj");
106 log.println("Therefore this property can't be changed");
107 String aName = null;
108 try {
109 aName = (String) oObj.getPropertyValue ("LayerName");
110 log.println("LayerName: '"+aName+"'");
111 } catch (Exception e) {
112 e.printStackTrace (log);
114 tRes.tested("LayerName",aName != null);
115 } else {
116 log.println("Testing with custom Property tester") ;
117 testProperty("LayerName", StringTester) ;
121 public void _ZOrder() {
122 if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
123 log.println("There is only one Layer for ScAnnotationShapeObj");
124 log.println("Therefore this property can't be changed");
125 tRes.tested("ZOrder",true);
126 } else {
127 testProperty("ZOrder", Integer.valueOf(0), Integer.valueOf(1));
131 public void _LayerID() {
132 if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
133 log.println("There is only one Layer for ScAnnotationShapeObj");
134 log.println("Therefore this property can't be changed");
135 Short aID = null;
136 try {
137 aID = (Short) oObj.getPropertyValue ("LayerID");
138 log.println("LayerID: '"+aID.intValue ()+"'");
139 } catch (Exception e) {
140 e.printStackTrace (log);
142 tRes.tested("LayerID",aID != null);
143 } else {
144 log.println("Testing with custom Property tester") ;
145 testProperty("LayerID");