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 .
20 import com
.sun
.star
.beans
.XPropertySetInfo
;
21 import lib
.MultiPropertyTest
;
23 import com
.sun
.star
.awt
.XBitmap
;
24 import com
.sun
.star
.uno
.AnyConverter
;
25 import com
.sun
.star
.uno
.Type
;
28 * Testing <code>com.sun.star.drawing.FillProperties</code>
29 * service properties :
31 * <li><code> FillStyle</code></li>
32 * <li><code> FillColor</code></li>
33 * <li><code> FillTransparence</code></li>
34 * <li><code> FillTransparenceGradientName</code></li>
35 * <li><code> FillTransparenceGradient</code></li>
36 * <li><code> FillGradientName</code></li>
37 * <li><code> FillGradient</code></li>
38 * <li><code> FillHatchName</code></li>
39 * <li><code> FillHatch</code></li>
40 * <li><code> FillBitmapName</code></li>
41 * <li><code> FillBitmap</code></li>
42 * <li><code> FillBitmapURL</code></li>
43 * <li><code> FillBitmapOffsetX</code></li>
44 * <li><code> FillBitmapOffsetY</code></li>
45 * <li><code> FillBitmapPositionOffsetX</code></li>
46 * <li><code> FillBitmapPositionOffsetY</code></li>
47 * <li><code> FillBitmapRectanglePoint</code></li>
48 * <li><code> FillBitmapLogicalSize</code></li>
49 * <li><code> FillBitmapSizeX</code></li>
50 * <li><code> FillBitmapSizeY</code></li>
51 * <li><code> FillBitmapMode</code></li>
52 * <li><code> FillBackground</code></li>
54 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
55 * @see com.sun.star.drawing.FillProperties
57 public class _FillProperties
extends MultiPropertyTest
{
59 XBitmap the_bitmap
= null;
60 XBitmap the_secondBitmap
= null;
62 * Property tester which changes URL.
64 protected PropertyTester URLTester
= new PropertyTester() {
66 protected Object
getNewValue(String propName
, Object oldValue
)
67 throws java
.lang
.IllegalArgumentException
{
68 if (oldValue
.equals(util
.utils
.getFullTestURL("space-metal.jpg"))) {
69 return util
.utils
.getFullTestURL("crazy-blue.jpg");
71 return util
.utils
.getFullTestURL("space-metal.jpg");
76 * Property tester which switches two strings.
78 protected PropertyTester StringTester
= new PropertyTester() {
80 protected Object
getNewValue(String propName
, Object oldValue
)
81 throws java
.lang
.IllegalArgumentException
{
82 if (oldValue
.equals(str1
)) {
90 * Property tester which switches two XBitmap objects.
92 protected PropertyTester BitmapTester
= new PropertyTester() {
94 protected Object
getNewValue(String propName
, Object oldValue
)
95 throws java
.lang
.IllegalArgumentException
{
96 if (util
.ValueComparer
.equalValue(oldValue
, the_bitmap
)) {
97 return the_secondBitmap
;
105 * This property must have an URL format
107 public void _FillBitmapURL() {
108 log
.println("Testing with custom Property tester");
109 testProperty("FillBitmapURL", URLTester
);
111 public String str1
= "";
112 public String str2
= "";
115 * This property must have predefined values
117 public void _FillGradientName() {
118 log
.println("Testing with custom Property tester");
121 testProperty("FillGradientName", StringTester
);
125 * This property must have predefined values
127 public void _FillBitmapName() {
128 log
.println("Testing with custom Property tester");
131 testProperty("FillBitmapName", StringTester
);
135 * This property must have predefined values
137 public void _FillTransparenceGradientName() {
138 log
.println("Testing with custom Property tester");
139 str1
= "Transparency 2";
140 str2
= "Transparency 1";
141 testProperty("FillTransparenceGradientName", StringTester
);
145 * This property must have predefined values
147 public void _FillHatchName() {
148 log
.println("Testing with custom Property tester");
149 str1
= "Black 0 degrees";
150 str2
= "Black 45 degrees";
151 testProperty("FillHatchName", StringTester
);
155 * This property is very interesting. After setting URL of bitmap you get
156 * <code>XBitmap</code> interface of the image file specified.
157 * The method first gets two different bitmaps and then tests the property.
159 public void _FillBitmap() {
161 String propName
= "FillBitmap";
163 XPropertySetInfo info
= oObj
.getPropertySetInfo();
165 if (!info
.hasPropertyByName(propName
)) {
166 if (isOptional(propName
)) {
167 // skipping optional property test
168 log
.println("Property '" + propName
+ "' is optional and not supported");
169 tRes
.tested(propName
, true);
176 oObj
.setPropertyValue("FillBitmapURL", util
.utils
.getFullTestURL("crazy-blue.jpg"));
178 the_bitmap
= (XBitmap
) AnyConverter
.toObject(
179 new Type(XBitmap
.class), oObj
.getPropertyValue("FillBitmap"));
181 oObj
.setPropertyValue("FillBitmapURL", util
.utils
.getFullTestURL("space-metal.jpg"));
183 the_secondBitmap
= (XBitmap
) AnyConverter
.toObject(
184 new Type(XBitmap
.class), oObj
.getPropertyValue("FillBitmap"));
186 testProperty("FillBitmap", BitmapTester
);
188 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
189 log
.println("Couldn't change Bitmap");
190 e
.printStackTrace(log
);
191 tRes
.tested("FillBitmap", false);
193 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
194 log
.println("Couldn't change Bitmap");
195 e
.printStackTrace(log
);
196 tRes
.tested("FillBitmap", false);
198 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
199 log
.println("Couldn't change Bitmap");
200 e
.printStackTrace(log
);
201 tRes
.tested("FillBitmap", false);
203 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
204 log
.println("Couldn't change Bitmap");
205 e
.printStackTrace(log
);
206 tRes
.tested("FillBitmap", false);