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 ************************************************************************/
29 import com
.sun
.star
.beans
.XPropertySetInfo
;
30 import lib
.MultiPropertyTest
;
32 import com
.sun
.star
.awt
.XBitmap
;
33 import com
.sun
.star
.uno
.AnyConverter
;
34 import com
.sun
.star
.uno
.Type
;
37 * Testing <code>com.sun.star.drawing.FillProperties</code>
38 * service properties :
40 * <li><code> FillStyle</code></li>
41 * <li><code> FillColor</code></li>
42 * <li><code> FillTransparence</code></li>
43 * <li><code> FillTransparenceGradientName</code></li>
44 * <li><code> FillTransparenceGradient</code></li>
45 * <li><code> FillGradientName</code></li>
46 * <li><code> FillGradient</code></li>
47 * <li><code> FillHatchName</code></li>
48 * <li><code> FillHatch</code></li>
49 * <li><code> FillBitmapName</code></li>
50 * <li><code> FillBitmap</code></li>
51 * <li><code> FillBitmapURL</code></li>
52 * <li><code> FillBitmapOffsetX</code></li>
53 * <li><code> FillBitmapOffsetY</code></li>
54 * <li><code> FillBitmapPositionOffsetX</code></li>
55 * <li><code> FillBitmapPositionOffsetY</code></li>
56 * <li><code> FillBitmapRectanglePoint</code></li>
57 * <li><code> FillBitmapLogicalSize</code></li>
58 * <li><code> FillBitmapSizeX</code></li>
59 * <li><code> FillBitmapSizeY</code></li>
60 * <li><code> FillBitmapMode</code></li>
61 * <li><code> FillBackground</code></li>
63 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
64 * @see com.sun.star.drawing.FillProperties
66 public class _FillProperties
extends MultiPropertyTest
{
68 XBitmap the_bitmap
= null;
69 XBitmap the_secondBitmap
= null;
71 * Property tester which changes URL.
73 protected PropertyTester URLTester
= new PropertyTester() {
75 protected Object
getNewValue(String propName
, Object oldValue
)
76 throws java
.lang
.IllegalArgumentException
{
77 if (oldValue
.equals(util
.utils
.getFullTestURL("space-metal.jpg"))) {
78 return util
.utils
.getFullTestURL("crazy-blue.jpg");
80 return util
.utils
.getFullTestURL("space-metal.jpg");
85 * Property tester which switches two strings.
87 protected PropertyTester StringTester
= new PropertyTester() {
89 protected Object
getNewValue(String propName
, Object oldValue
)
90 throws java
.lang
.IllegalArgumentException
{
91 if (oldValue
.equals(str1
)) {
99 * Property tester which switches two XBitmap objects.
101 protected PropertyTester BitmapTester
= new PropertyTester() {
103 protected Object
getNewValue(String propName
, Object oldValue
)
104 throws java
.lang
.IllegalArgumentException
{
105 if (util
.ValueComparer
.equalValue(oldValue
, the_bitmap
)) {
106 return the_secondBitmap
;
114 * This property must have an URL format
116 public void _FillBitmapURL() {
117 log
.println("Testing with custom Property tester");
118 testProperty("FillBitmapURL", URLTester
);
120 public String str1
= "";
121 public String str2
= "";
124 * This property must have predefined values
126 public void _FillGradientName() {
127 log
.println("Testing with custom Property tester");
130 testProperty("FillGradientName", StringTester
);
134 * This property must have predefined values
136 public void _FillBitmapName() {
137 log
.println("Testing with custom Property tester");
140 testProperty("FillBitmapName", StringTester
);
144 * This property must have predefined values
146 public void _FillTransparenceGradientName() {
147 log
.println("Testing with custom Property tester");
148 str1
= "Transparency 2";
149 str2
= "Transparency 1";
150 testProperty("FillTransparenceGradientName", StringTester
);
154 * This property must have predefined values
156 public void _FillHatchName() {
157 log
.println("Testing with custom Property tester");
158 str1
= "Black 0 degrees";
159 str2
= "Black 45 degrees";
160 testProperty("FillHatchName", StringTester
);
164 * This property is very interesting. After setting URL of bitmap you get
165 * <code>XBitmap</code> interface of the image file specified.
166 * The method first gets two different bitmaps and then tests the property.
168 public void _FillBitmap() {
170 String propName
= "FillBitmap";
172 XPropertySetInfo info
= oObj
.getPropertySetInfo();
174 if (!info
.hasPropertyByName(propName
)) {
175 if (isOptional(propName
)) {
176 // skipping optional property test
177 log
.println("Property '" + propName
+ "' is optional and not supported");
178 tRes
.tested(propName
, true);
185 oObj
.setPropertyValue("FillBitmapURL", util
.utils
.getFullTestURL("crazy-blue.jpg"));
187 the_bitmap
= (XBitmap
) AnyConverter
.toObject(
188 new Type(XBitmap
.class), oObj
.getPropertyValue("FillBitmap"));
190 oObj
.setPropertyValue("FillBitmapURL", util
.utils
.getFullTestURL("space-metal.jpg"));
192 the_secondBitmap
= (XBitmap
) AnyConverter
.toObject(
193 new Type(XBitmap
.class), oObj
.getPropertyValue("FillBitmap"));
195 testProperty("FillBitmap", BitmapTester
);
197 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
198 log
.println("Couldn't change Bitmap");
199 e
.printStackTrace(log
);
200 tRes
.tested("FillBitmap", false);
202 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
203 log
.println("Couldn't change Bitmap");
204 e
.printStackTrace(log
);
205 tRes
.tested("FillBitmap", false);
207 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
208 log
.println("Couldn't change Bitmap");
209 e
.printStackTrace(log
);
210 tRes
.tested("FillBitmap", false);
212 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
213 log
.println("Couldn't change Bitmap");
214 e
.printStackTrace(log
);
215 tRes
.tested("FillBitmap", false);