2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiPropertyTest
;
23 import com
.sun
.star
.style
.XStyle
;
26 * Testing <code>com.sun.star.drawing.Shape</code>
27 * service properties :
29 * <li><code> ZOrder</code></li>
30 * <li><code> LayerID</code></li>
31 * <li><code> LayerName</code></li>
32 * <li><code> Printable</code></li>
33 * <li><code> MoveProtect</code></li>
34 * <li><code> Name</code></li>
35 * <li><code> SizeProtect</code></li>
36 * <li><code> Style</code></li>
37 * <li><code> Transformation</code></li>
39 * This test needs the following object relations :
41 * <li> <code>'Style1', 'Style2'</code>
42 * (of type <code>com.sun.star.style.XStyle</code>):
43 * relations used to change property 'Style'</li>
45 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
46 * @see com.sun.star.drawing.Shape
48 public class _Shape
extends MultiPropertyTest
{
54 * Custom tester which switches between two styles.
56 protected PropertyTester StyleTester
= new PropertyTester() {
57 protected Object
getNewValue(String propName
, Object oldValue
)
58 throws java
.lang
.IllegalArgumentException
{
59 if (util
.ValueComparer
.equalValue(oldValue
,style1
))
66 * Custom tester for 'LayerName' property which switches two
67 * Strings ('layout' and 'controls').
69 protected PropertyTester StringTester
= new PropertyTester() {
70 protected Object
getNewValue(String propName
, Object oldValue
)
71 throws java
.lang
.IllegalArgumentException
{
72 if (util
.ValueComparer
.equalValue(oldValue
,"layout"))
73 return "controls"; else
79 * Tested with custom StyleTester which switches between two
82 public void _Style() {
83 log
.println("Testing with custom Property tester") ;
84 style1
= (XStyle
) tEnv
.getObjRelation("Style1");
85 style2
= (XStyle
) tEnv
.getObjRelation("Style2");
86 testProperty("Style", StyleTester
) ;
90 * Tested with custom StringTester which switches two
91 * Strings ('layout' and 'controls')
93 public void _LayerName() {
94 if (tEnv
.getTestCase().getObjectName().equals("SwXShape")) {
95 log
.println("There is only one Layer for SwXShape");
96 log
.println("Therefore this property can't be changed");
97 tRes
.tested("LayerName",true);
98 } else if (tEnv
.getTestCase().getObjectName().equals("ScShapeObj")) {
99 log
.println("There is only one Layer for ScShapeObj");
100 log
.println("Therefore this property can't be changed");
101 tRes
.tested("LayerName",true);
102 } else if (tEnv
.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
103 log
.println("There is only one Layer for ScAnnotationShapeObj");
104 log
.println("Therefore this property can't be changed");
107 aName
= (String
) oObj
.getPropertyValue ("LayerName");
108 log
.println("LayerName: '"+aName
+"'");
109 } catch (Exception e
) {
110 e
.printStackTrace (log
);
112 tRes
.tested("LayerName",aName
!= null);
114 log
.println("Testing with custom Property tester") ;
115 testProperty("LayerName", StringTester
) ;
119 public void _ZOrder() {
120 if (tEnv
.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
121 log
.println("There is only one Layer for ScAnnotationShapeObj");
122 log
.println("Therefore this property can't be changed");
123 tRes
.tested("ZOrder",true);
125 testProperty("ZOrder", new Integer(0), new Integer(1));
129 public void _LayerID() {
130 if (tEnv
.getTestCase().getObjectName().equals("ScAnnotationShapeObj")) {
131 log
.println("There is only one Layer for ScAnnotationShapeObj");
132 log
.println("Therefore this property can't be changed");
135 aID
= (Short
) oObj
.getPropertyValue ("LayerID");
136 log
.println("LayerID: '"+aID
.intValue ()+"'");
137 } catch (Exception e
) {
138 e
.printStackTrace (log
);
140 tRes
.tested("LayerID",aID
!= null);
142 log
.println("Testing with custom Property tester") ;
143 testProperty("LayerID");