1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.drawing;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import lib.MultiPropertyTest;
27cdf0e10cSrcweir 
28cdf0e10cSrcweir import com.sun.star.style.XStyle;
29cdf0e10cSrcweir 
30cdf0e10cSrcweir /**
31cdf0e10cSrcweir * Testing <code>com.sun.star.drawing.Shape</code>
32cdf0e10cSrcweir * service properties :
33cdf0e10cSrcweir * <ul>
34cdf0e10cSrcweir *  <li><code> ZOrder</code></li>
35cdf0e10cSrcweir *  <li><code> LayerID</code></li>
36cdf0e10cSrcweir *  <li><code> LayerName</code></li>
37cdf0e10cSrcweir *  <li><code> Printable</code></li>
38cdf0e10cSrcweir *  <li><code> MoveProtect</code></li>
39cdf0e10cSrcweir *  <li><code> Name</code></li>
40cdf0e10cSrcweir *  <li><code> SizeProtect</code></li>
41cdf0e10cSrcweir *  <li><code> Style</code></li>
42cdf0e10cSrcweir *  <li><code> Transformation</code></li>
43cdf0e10cSrcweir * </ul> <p>
44cdf0e10cSrcweir * This test needs the following object relations :
45cdf0e10cSrcweir * <ul>
46cdf0e10cSrcweir *  <li> <code>'Style1', 'Style2'</code>
47cdf0e10cSrcweir *   (of type <code>com.sun.star.style.XStyle</code>):
48cdf0e10cSrcweir *    relations used to change property 'Style'</li>
49cdf0e10cSrcweir * <ul> <p>
50cdf0e10cSrcweir * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
51cdf0e10cSrcweir * @see com.sun.star.drawing.Shape
52cdf0e10cSrcweir */
53cdf0e10cSrcweir public class _Shape extends MultiPropertyTest {
54cdf0e10cSrcweir 
55cdf0e10cSrcweir     XStyle style1 = null;
56cdf0e10cSrcweir     XStyle style2 = null;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     /**
59cdf0e10cSrcweir      * Custom tester which switches between two styles.
60cdf0e10cSrcweir      */
61cdf0e10cSrcweir     protected PropertyTester StyleTester = new PropertyTester() {
62cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue)
63cdf0e10cSrcweir                 throws java.lang.IllegalArgumentException {
64cdf0e10cSrcweir             if (util.ValueComparer.equalValue(oldValue,style1))
65cdf0e10cSrcweir                 return style2; else
66cdf0e10cSrcweir                 return style1;
67cdf0e10cSrcweir         }
68cdf0e10cSrcweir     } ;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     /**
71cdf0e10cSrcweir      * Custom tester for 'LayerName' property which switches two
72cdf0e10cSrcweir      * Strings ('layout' and 'controls').
73cdf0e10cSrcweir      */
74cdf0e10cSrcweir     protected PropertyTester StringTester = new PropertyTester() {
75cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue)
76cdf0e10cSrcweir                 throws java.lang.IllegalArgumentException {
77cdf0e10cSrcweir             if (util.ValueComparer.equalValue(oldValue,"layout"))
78cdf0e10cSrcweir                 return "controls"; else
79cdf0e10cSrcweir                 return "layout";
80cdf0e10cSrcweir         }
81cdf0e10cSrcweir     } ;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     /**
84cdf0e10cSrcweir      * Tested with custom StyleTester which switches between two
85cdf0e10cSrcweir      * styles.
86cdf0e10cSrcweir      */
_Style()87cdf0e10cSrcweir     public void _Style() {
88cdf0e10cSrcweir         log.println("Testing with custom Property tester") ;
89cdf0e10cSrcweir         style1 = (XStyle) tEnv.getObjRelation("Style1");
90cdf0e10cSrcweir         style2 = (XStyle) tEnv.getObjRelation("Style2");
91cdf0e10cSrcweir         testProperty("Style", StyleTester) ;
92cdf0e10cSrcweir     }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     /**
95cdf0e10cSrcweir      * Tested with custom StringTester which switches two
96cdf0e10cSrcweir      * Strings ('layout' and 'controls')
97cdf0e10cSrcweir      */
_LayerName()98cdf0e10cSrcweir     public void _LayerName() {
99cdf0e10cSrcweir         if (tEnv.getTestCase().getObjectName().equals("SwXShape")) {
100cdf0e10cSrcweir             log.println("There is only one Layer for SwXShape");
101cdf0e10cSrcweir             log.println("Therefore this property can't be changed");
102cdf0e10cSrcweir             tRes.tested("LayerName",true);
103cdf0e10cSrcweir         } else if (tEnv.getTestCase().getObjectName().equals("ScShapeObj")) {
104cdf0e10cSrcweir             log.println("There is only one Layer for ScShapeObj");
105cdf0e10cSrcweir             log.println("Therefore this property can't be changed");
106cdf0e10cSrcweir             tRes.tested("LayerName",true);
107cdf0e10cSrcweir         } else if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
108cdf0e10cSrcweir             log.println("There is only one Layer for ScAnnotationShapeObj");
109cdf0e10cSrcweir             log.println("Therefore this property can't be changed");
110cdf0e10cSrcweir             String aName = null;
111cdf0e10cSrcweir             try {
112cdf0e10cSrcweir                 aName = (String) oObj.getPropertyValue ("LayerName");
113cdf0e10cSrcweir                 log.println("LayerName: '"+aName+"'");
114cdf0e10cSrcweir             } catch (Exception e) {
115cdf0e10cSrcweir                 e.printStackTrace (log);
116cdf0e10cSrcweir             }
117cdf0e10cSrcweir             tRes.tested("LayerName",aName != null);
118cdf0e10cSrcweir         } else {
119cdf0e10cSrcweir             log.println("Testing with custom Property tester") ;
120cdf0e10cSrcweir             testProperty("LayerName", StringTester) ;
121cdf0e10cSrcweir         }
122cdf0e10cSrcweir     }
123cdf0e10cSrcweir 
_ZOrder()124cdf0e10cSrcweir     public void _ZOrder() {
125cdf0e10cSrcweir         if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
126cdf0e10cSrcweir             log.println("There is only one Layer for ScAnnotationShapeObj");
127cdf0e10cSrcweir             log.println("Therefore this property can't be changed");
128cdf0e10cSrcweir             tRes.tested("ZOrder",true);
129cdf0e10cSrcweir         } else {
130cdf0e10cSrcweir             testProperty("ZOrder", new Integer(0), new Integer(1));
131cdf0e10cSrcweir         }
132cdf0e10cSrcweir     }
133cdf0e10cSrcweir 
_LayerID()134cdf0e10cSrcweir     public void _LayerID() {
135cdf0e10cSrcweir         if (tEnv.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
136cdf0e10cSrcweir             log.println("There is only one Layer for ScAnnotationShapeObj");
137cdf0e10cSrcweir             log.println("Therefore this property can't be changed");
138cdf0e10cSrcweir             Short aID = null;
139cdf0e10cSrcweir             try {
140cdf0e10cSrcweir                 aID = (Short) oObj.getPropertyValue ("LayerID");
141cdf0e10cSrcweir                 log.println("LayerID: '"+aID.intValue ()+"'");
142cdf0e10cSrcweir             } catch (Exception e) {
143cdf0e10cSrcweir                 e.printStackTrace (log);
144cdf0e10cSrcweir             }
145cdf0e10cSrcweir             tRes.tested("LayerID",aID != null);
146cdf0e10cSrcweir         } else {
147cdf0e10cSrcweir             log.println("Testing with custom Property tester") ;
148cdf0e10cSrcweir             testProperty("LayerID");
149cdf0e10cSrcweir         }
150cdf0e10cSrcweir     }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
155