tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / drawing / _FillProperties.java
blobf4e64d7b558323c3bcb70ee25327aa1465c73f0b
1 /*
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 .
18 package ifc.drawing;
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;
27 /**
28 * Testing <code>com.sun.star.drawing.FillProperties</code>
29 * service properties :
30 * <ul>
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>
53 * </ul> <p>
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;
61 /**
62 * Property tester which changes URL.
64 protected PropertyTester URLTester = new PropertyTester() {
66 @Override
67 protected Object getNewValue(String propName, Object oldValue)
68 throws java.lang.IllegalArgumentException {
69 if (oldValue.equals(util.utils.getFullTestURL("space-metal.jpg"))) {
70 return util.utils.getFullTestURL("crazy-blue.jpg");
71 } else {
72 return util.utils.getFullTestURL("space-metal.jpg");
76 /**
77 * Property tester which switches two strings.
79 protected PropertyTester StringTester = new PropertyTester() {
81 @Override
82 protected Object getNewValue(String propName, Object oldValue)
83 throws java.lang.IllegalArgumentException {
84 if (oldValue.equals(str1)) {
85 return str2;
86 } else {
87 return str1;
91 /**
92 * Property tester which switches two XBitmap objects.
94 protected PropertyTester BitmapTester = new PropertyTester() {
96 @Override
97 protected Object getNewValue(String propName, Object oldValue)
98 throws java.lang.IllegalArgumentException {
99 if (util.ValueComparer.equalValue(oldValue, the_bitmap)) {
100 return the_secondBitmap;
101 } else {
102 return the_bitmap;
108 * This property must have a URL format
110 public void _FillBitmapURL() {
111 log.println("Testing with custom Property tester");
112 testProperty("FillBitmapURL", URLTester);
114 public String str1 = "";
115 public String str2 = "";
118 * This property must have predefined values
120 public void _FillGradientName() {
121 log.println("Testing with custom Property tester");
122 str1 = "Gradient 1";
123 str2 = "Gradient 3";
124 testProperty("FillGradientName", StringTester);
128 * This property must have predefined values
130 public void _FillBitmapName() {
131 log.println("Testing with custom Property tester");
132 str1 = "Sky";
133 str2 = "Blank";
134 testProperty("FillBitmapName", StringTester);
138 * This property must have predefined values
140 public void _FillTransparenceGradientName() {
141 log.println("Testing with custom Property tester");
142 str1 = "Transparency 2";
143 str2 = "Transparency 1";
144 testProperty("FillTransparenceGradientName", StringTester);
148 * This property must have predefined values
150 public void _FillHatchName() {
151 log.println("Testing with custom Property tester");
152 str1 = "Black 0 degrees";
153 str2 = "Black 45 degrees";
154 testProperty("FillHatchName", StringTester);
158 * This property is very interesting. After setting URL of bitmap you get
159 * <code>XBitmap</code> interface of the image file specified.
160 * The method first gets two different bitmaps and then tests the property.
162 public void _FillBitmap() {
164 String propName = "FillBitmap";
166 XPropertySetInfo info = oObj.getPropertySetInfo();
168 if (!info.hasPropertyByName(propName)) {
169 if (isOptional(propName)) {
170 // skipping optional property test
171 log.println("Property '" + propName + "' is optional and not supported");
172 tRes.tested(propName, true);
173 return;
175 } else {
177 try {
179 oObj.setPropertyValue("FillBitmapURL", util.utils.getFullTestURL("crazy-blue.jpg"));
181 the_bitmap = (XBitmap) AnyConverter.toObject(
182 new Type(XBitmap.class), oObj.getPropertyValue("FillBitmap"));
184 oObj.setPropertyValue("FillBitmapURL", util.utils.getFullTestURL("space-metal.jpg"));
186 the_secondBitmap = (XBitmap) AnyConverter.toObject(
187 new Type(XBitmap.class), oObj.getPropertyValue("FillBitmap"));
189 testProperty("FillBitmap", BitmapTester);
191 } catch (com.sun.star.beans.PropertyVetoException e) {
192 log.println("Couldn't change Bitmap");
193 e.printStackTrace(log);
194 tRes.tested("FillBitmap", false);
196 } catch (com.sun.star.beans.UnknownPropertyException e) {
197 log.println("Couldn't change Bitmap");
198 e.printStackTrace(log);
199 tRes.tested("FillBitmap", false);
201 } catch (com.sun.star.lang.WrappedTargetException e) {
202 log.println("Couldn't change Bitmap");
203 e.printStackTrace(log);
204 tRes.tested("FillBitmap", false);
206 } catch (com.sun.star.lang.IllegalArgumentException e) {
207 log.println("Couldn't change Bitmap");
208 e.printStackTrace(log);
209 tRes.tested("FillBitmap", false);