Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / drawing / _FillProperties.java
blobe2d887752ce1f2c2a374f4aa654b93f16c5fb40e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _FillProperties.java,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package ifc.drawing;
32 import com.sun.star.beans.XPropertySetInfo;
33 import lib.MultiPropertyTest;
35 import com.sun.star.awt.XBitmap;
36 import com.sun.star.uno.AnyConverter;
37 import com.sun.star.uno.Type;
39 /**
40 * Testing <code>com.sun.star.drawing.FillProperties</code>
41 * service properties :
42 * <ul>
43 * <li><code> FillStyle</code></li>
44 * <li><code> FillColor</code></li>
45 * <li><code> FillTransparence</code></li>
46 * <li><code> FillTransparenceGradientName</code></li>
47 * <li><code> FillTransparenceGradient</code></li>
48 * <li><code> FillGradientName</code></li>
49 * <li><code> FillGradient</code></li>
50 * <li><code> FillHatchName</code></li>
51 * <li><code> FillHatch</code></li>
52 * <li><code> FillBitmapName</code></li>
53 * <li><code> FillBitmap</code></li>
54 * <li><code> FillBitmapURL</code></li>
55 * <li><code> FillBitmapOffsetX</code></li>
56 * <li><code> FillBitmapOffsetY</code></li>
57 * <li><code> FillBitmapPositionOffsetX</code></li>
58 * <li><code> FillBitmapPositionOffsetY</code></li>
59 * <li><code> FillBitmapRectanglePoint</code></li>
60 * <li><code> FillBitmapLogicalSize</code></li>
61 * <li><code> FillBitmapSizeX</code></li>
62 * <li><code> FillBitmapSizeY</code></li>
63 * <li><code> FillBitmapMode</code></li>
64 * <li><code> FillBackground</code></li>
65 * </ul> <p>
66 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
67 * @see com.sun.star.drawing.FillProperties
69 public class _FillProperties extends MultiPropertyTest {
71 XBitmap the_bitmap = null;
72 XBitmap the_secondBitmap = null;
73 /**
74 * Property tester which changes URL.
76 protected PropertyTester URLTester = new PropertyTester() {
78 protected Object getNewValue(String propName, Object oldValue)
79 throws java.lang.IllegalArgumentException {
80 if (oldValue.equals(util.utils.getFullTestURL("space-metal.jpg"))) {
81 return util.utils.getFullTestURL("crazy-blue.jpg");
82 } else {
83 return util.utils.getFullTestURL("space-metal.jpg");
87 /**
88 * Property tester which switches two strings.
90 protected PropertyTester StringTester = new PropertyTester() {
92 protected Object getNewValue(String propName, Object oldValue)
93 throws java.lang.IllegalArgumentException {
94 if (oldValue.equals(str1)) {
95 return str2;
96 } else {
97 return str1;
102 * Property tester which switches two XBitmap objects.
104 protected PropertyTester BitmapTester = new PropertyTester() {
106 protected Object getNewValue(String propName, Object oldValue)
107 throws java.lang.IllegalArgumentException {
108 if (util.ValueComparer.equalValue(oldValue, the_bitmap)) {
109 return the_secondBitmap;
110 } else {
111 return the_bitmap;
117 * This property must have an URL format
119 public void _FillBitmapURL() {
120 log.println("Testing with custom Property tester");
121 testProperty("FillBitmapURL", URLTester);
123 public String str1 = "";
124 public String str2 = "";
127 * This property must have predefined values
129 public void _FillGradientName() {
130 log.println("Testing with custom Property tester");
131 str1 = "Gradient 1";
132 str2 = "Gradient 3";
133 testProperty("FillGradientName", StringTester);
137 * This property must have predefined values
139 public void _FillBitmapName() {
140 log.println("Testing with custom Property tester");
141 str1 = "Sky";
142 str2 = "Blank";
143 testProperty("FillBitmapName", StringTester);
147 * This property must have predefined values
149 public void _FillTransparenceGradientName() {
150 log.println("Testing with custom Property tester");
151 str1 = "Transparency 2";
152 str2 = "Transparency 1";
153 testProperty("FillTransparenceGradientName", StringTester);
157 * This property must have predefined values
159 public void _FillHatchName() {
160 log.println("Testing with custom Property tester");
161 str1 = "Black 0 degrees";
162 str2 = "Black 45 degrees";
163 testProperty("FillHatchName", StringTester);
167 * This property is very interesting. After setting URL of bitmap you get
168 * <code>XBitmap</code> interface of the image file specified.
169 * The method first gets two different bitmaps and then tests the property.
171 public void _FillBitmap() {
173 String propName = "FillBitmap";
175 XPropertySetInfo info = oObj.getPropertySetInfo();
177 if (!info.hasPropertyByName(propName)) {
178 if (isOptional(propName)) {
179 // skipping optional property test
180 log.println("Property '" + propName + "' is optional and not supported");
181 tRes.tested(propName, true);
182 return;
184 } else {
186 try {
188 oObj.setPropertyValue("FillBitmapURL", util.utils.getFullTestURL("crazy-blue.jpg"));
190 the_bitmap = (XBitmap) AnyConverter.toObject(
191 new Type(XBitmap.class), oObj.getPropertyValue("FillBitmap"));
193 oObj.setPropertyValue("FillBitmapURL", util.utils.getFullTestURL("space-metal.jpg"));
195 the_secondBitmap = (XBitmap) AnyConverter.toObject(
196 new Type(XBitmap.class), oObj.getPropertyValue("FillBitmap"));
198 testProperty("FillBitmap", BitmapTester);
200 } catch (com.sun.star.beans.PropertyVetoException e) {
201 log.println("Couldn't change Bitmap");
202 e.printStackTrace(log);
203 tRes.tested("FillBitmap", false);
205 } catch (com.sun.star.beans.UnknownPropertyException e) {
206 log.println("Couldn't change Bitmap");
207 e.printStackTrace(log);
208 tRes.tested("FillBitmap", false);
210 } catch (com.sun.star.lang.WrappedTargetException e) {
211 log.println("Couldn't change Bitmap");
212 e.printStackTrace(log);
213 tRes.tested("FillBitmap", false);
215 } catch (com.sun.star.lang.IllegalArgumentException e) {
216 log.println("Couldn't change Bitmap");
217 e.printStackTrace(log);
218 tRes.tested("FillBitmap", false);