Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / drawing / _Shape.java
blob5a64f7012b88a6d99312557a42621cb8f3f35bc1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 package ifc.drawing;
30 import lib.MultiPropertyTest;
32 import com.sun.star.style.XStyle;
34 /**
35 * Testing <code>com.sun.star.drawing.Shape</code>
36 * service properties :
37 * <ul>
38 * <li><code> ZOrder</code></li>
39 * <li><code> LayerID</code></li>
40 * <li><code> LayerName</code></li>
41 * <li><code> Printable</code></li>
42 * <li><code> MoveProtect</code></li>
43 * <li><code> Name</code></li>
44 * <li><code> SizeProtect</code></li>
45 * <li><code> Style</code></li>
46 * <li><code> Transformation</code></li>
47 * </ul> <p>
48 * This test needs the following object relations :
49 * <ul>
50 * <li> <code>'Style1', 'Style2'</code>
51 * (of type <code>com.sun.star.style.XStyle</code>):
52 * relations used to change property 'Style'</li>
53 * <ul> <p>
54 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
55 * @see com.sun.star.drawing.Shape
57 public class _Shape extends MultiPropertyTest {
59 XStyle style1 = null;
60 XStyle style2 = null;
62 /**
63 * Custom tester which switches between two styles.
65 protected PropertyTester StyleTester = new PropertyTester() {
66 protected Object getNewValue(String propName, Object oldValue)
67 throws java.lang.IllegalArgumentException {
68 if (util.ValueComparer.equalValue(oldValue,style1))
69 return style2; else
70 return style1;
72 } ;
74 /**
75 * Custom tester for 'LayerName' property which switches two
76 * Strings ('layout' and 'controls').
78 protected PropertyTester StringTester = new PropertyTester() {
79 protected Object getNewValue(String propName, Object oldValue)
80 throws java.lang.IllegalArgumentException {
81 if (util.ValueComparer.equalValue(oldValue,"layout"))
82 return "controls"; else
83 return "layout";
85 } ;
87 /**
88 * Tested with custom StyleTester which switches between two
89 * styles.
91 public void _Style() {
92 log.println("Testing with custom Property tester") ;
93 style1 = (XStyle) tEnv.getObjRelation("Style1");
94 style2 = (XStyle) tEnv.getObjRelation("Style2");
95 testProperty("Style", StyleTester) ;
98 /**
99 * Tested with custom StringTester which switches two
100 * Strings ('layout' and 'controls')
102 public void _LayerName() {
103 if (tEnv.getTestCase().getObjectName().equals("SwXShape")) {
104 log.println("There is only one Layer for SwXShape");
105 log.println("Therefore this property can't be changed");
106 tRes.tested("LayerName",true);
107 } else if (tEnv.getTestCase().getObjectName().equals("ScShapeObj")) {
108 log.println("There is only one Layer for ScShapeObj");
109 log.println("Therefore this property can't be changed");
110 tRes.tested("LayerName",true);
111 } else if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
112 log.println("There is only one Layer for ScAnnotationShapeObj");
113 log.println("Therefore this property can't be changed");
114 String aName = null;
115 try {
116 aName = (String) oObj.getPropertyValue ("LayerName");
117 log.println("LayerName: '"+aName+"'");
118 } catch (Exception e) {
119 e.printStackTrace (log);
121 tRes.tested("LayerName",aName != null);
122 } else {
123 log.println("Testing with custom Property tester") ;
124 testProperty("LayerName", StringTester) ;
128 public void _ZOrder() {
129 if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
130 log.println("There is only one Layer for ScAnnotationShapeObj");
131 log.println("Therefore this property can't be changed");
132 tRes.tested("ZOrder",true);
133 } else {
134 testProperty("ZOrder", new Integer(0), new Integer(1));
138 public void _LayerID() {
139 if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
140 log.println("There is only one Layer for ScAnnotationShapeObj");
141 log.println("Therefore this property can't be changed");
142 Short aID = null;
143 try {
144 aID = (Short) oObj.getPropertyValue ("LayerID");
145 log.println("LayerID: '"+aID.intValue ()+"'");
146 } catch (Exception e) {
147 e.printStackTrace (log);
149 tRes.tested("LayerID",aID != null);
150 } else {
151 log.println("Testing with custom Property tester") ;
152 testProperty("LayerID");