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