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 ************************************************************************/
30 import lib
.MultiPropertyTest
;
32 import com
.sun
.star
.style
.XStyle
;
35 * Testing <code>com.sun.star.drawing.Shape</code>
36 * service properties :
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>
48 * This test needs the following object relations :
50 * <li> <code>'Style1', 'Style2'</code>
51 * (of type <code>com.sun.star.style.XStyle</code>):
52 * relations used to change property 'Style'</li>
54 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
55 * @see com.sun.star.drawing.Shape
57 public class _Shape
extends MultiPropertyTest
{
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
))
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
88 * Tested with custom StyleTester which switches between two
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
) ;
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");
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);
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);
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");
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);
151 log
.println("Testing with custom Property tester") ;
152 testProperty("LayerID");