merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / drawing / _Shape.java
blob68d9b4cf1d41c41be6959a51204f6396889f31f9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _Shape.java,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.drawing;
33 import lib.MultiPropertyTest;
35 import com.sun.star.style.XStyle;
37 /**
38 * Testing <code>com.sun.star.drawing.Shape</code>
39 * service properties :
40 * <ul>
41 * <li><code> ZOrder</code></li>
42 * <li><code> LayerID</code></li>
43 * <li><code> LayerName</code></li>
44 * <li><code> Printable</code></li>
45 * <li><code> MoveProtect</code></li>
46 * <li><code> Name</code></li>
47 * <li><code> SizeProtect</code></li>
48 * <li><code> Style</code></li>
49 * <li><code> Transformation</code></li>
50 * </ul> <p>
51 * This test needs the following object relations :
52 * <ul>
53 * <li> <code>'Style1', 'Style2'</code>
54 * (of type <code>com.sun.star.style.XStyle</code>):
55 * relations used to change property 'Style'</li>
56 * <ul> <p>
57 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
58 * @see com.sun.star.drawing.Shape
60 public class _Shape extends MultiPropertyTest {
62 XStyle style1 = null;
63 XStyle style2 = null;
65 /**
66 * Custom tester which switches between two styles.
68 protected PropertyTester StyleTester = new PropertyTester() {
69 protected Object getNewValue(String propName, Object oldValue)
70 throws java.lang.IllegalArgumentException {
71 if (util.ValueComparer.equalValue(oldValue,style1))
72 return style2; else
73 return style1;
75 } ;
77 /**
78 * Custom tester for 'LayerName' property which switches two
79 * Strings ('layout' and 'controls').
81 protected PropertyTester StringTester = new PropertyTester() {
82 protected Object getNewValue(String propName, Object oldValue)
83 throws java.lang.IllegalArgumentException {
84 if (util.ValueComparer.equalValue(oldValue,"layout"))
85 return "controls"; else
86 return "layout";
88 } ;
90 /**
91 * Tested with custom StyleTester which switches between two
92 * styles.
94 public void _Style() {
95 log.println("Testing with custom Property tester") ;
96 style1 = (XStyle) tEnv.getObjRelation("Style1");
97 style2 = (XStyle) tEnv.getObjRelation("Style2");
98 testProperty("Style", StyleTester) ;
102 * Tested with custom StringTester which switches two
103 * Strings ('layout' and 'controls')
105 public void _LayerName() {
106 if (tEnv.getTestCase().getObjectName().equals("SwXShape")) {
107 log.println("There is only one Layer for SwXShape");
108 log.println("Therefore this property can't be changed");
109 tRes.tested("LayerName",true);
110 } else if (tEnv.getTestCase().getObjectName().equals("ScShapeObj")) {
111 log.println("There is only one Layer for ScShapeObj");
112 log.println("Therefore this property can't be changed");
113 tRes.tested("LayerName",true);
114 } else if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
115 log.println("There is only one Layer for ScAnnotationShapeObj");
116 log.println("Therefore this property can't be changed");
117 String aName = null;
118 try {
119 aName = (String) oObj.getPropertyValue ("LayerName");
120 log.println("LayerName: '"+aName+"'");
121 } catch (Exception e) {
122 e.printStackTrace (log);
124 tRes.tested("LayerName",aName != null);
125 } else {
126 log.println("Testing with custom Property tester") ;
127 testProperty("LayerName", StringTester) ;
131 public void _ZOrder() {
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 tRes.tested("ZOrder",true);
136 } else {
137 testProperty("ZOrder", new Integer(0), new Integer(1));
141 public void _LayerID() {
142 if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
143 log.println("There is only one Layer for ScAnnotationShapeObj");
144 log.println("Therefore this property can't be changed");
145 Short aID = null;
146 try {
147 aID = (Short) oObj.getPropertyValue ("LayerID");
148 log.println("LayerID: '"+aID.intValue ()+"'");
149 } catch (Exception e) {
150 e.printStackTrace (log);
152 tRes.tested("LayerID",aID != null);
153 } else {
154 log.println("Testing with custom Property tester") ;
155 testProperty("LayerID");