bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _CellProperties.java
blob95247a02be424c0cf3a9b5ee7947c4c40a00213b
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 .
19 package ifc.text;
21 import lib.MultiPropertyTest;
23 import com.sun.star.container.XNameContainer;
24 import com.sun.star.uno.AnyConverter;
25 import com.sun.star.uno.Type;
26 import com.sun.star.xml.AttributeData;
28 /**
29 * Testing <code>com.sun.star.text.CellProperties</code>
30 * service properties :
31 * <ul>
32 * <li><code> BackColor</code></li>
33 * <li><code> BackGraphicURL</code></li>
34 * <li><code> BackGraphicFilter</code></li>
35 * <li><code> BackGraphicLocation</code></li>
36 * <li><code> NumberFormat</code></li>
37 * <li><code> BackTransparent</code></li>
38 * <li><code> LeftBorder</code></li>
39 * <li><code> RightBorder</code></li>
40 * <li><code> TopBorder</code></li>
41 * <li><code> BottomBorder</code></li>
42 * <li><code> LeftBorderDistance</code></li>
43 * <li><code> RightBorderDistance</code></li>
44 * <li><code> TopBorderDistance</code></li>
45 * <li><code> BottomBorderDistance</code></li>
46 * <li><code> UserDefinedAttributes</code></li>
47 * <li><code> TextSection</code></li>
48 * <li><code> IsProtected</code></li>
49 * </ul> <p>
50 * This test needs the following object relations :
51 * <ul>
52 * <li> <code>'CellProperties.TextSection'</code> (of type
53 * <code>XInterface</code>):
54 * instance of <code>com.sun.star.text.TextSection</code></li>
55 * </ul> <p>
56 * The following predefined files needed to complete the test:
57 * <ul>
58 * <li> <code> crazy-blue.jpg </code> : jpeg image used to test
59 * BackGraphicURL()</li>
60 * <li> <code> space-metal.jpg </code> : jpeg image used to test
61 * BackGraphicURL()</li>
62 * </ul> <p>
63 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
64 * @see com.sun.star.text.CellProperties
66 public class _CellProperties extends MultiPropertyTest {
68 /**
69 * This property can be void, so new value must be specified from
70 * corresponding object relation.
72 public void _TextSection() {
73 log.println("Testing with custom Property tester") ;
74 testProperty("TextSection", new PropertyTester() {
75 protected Object getNewValue(String propName, Object oldValue) {
76 return tEnv.getObjRelation("CellProperties.TextSection");
78 });
82 /**
83 * Redefined method returns value, that differs from property value.
85 public void _BackColor() {
86 final Short val1 = new Short( (short) 4 );
87 final Short val2 = new Short( (short) 6 );
88 log.println("Testing with custom Property tester") ;
89 testProperty("BackColor", new PropertyTester() {
90 protected Object getNewValue(String propName, Object oldValue) {
91 if ( oldValue.equals(val1) )
92 return val2;
93 else
94 return val1;
96 });
101 * Redefined method returns value, that differs from property value.
103 public void _BackGraphicURL() {
104 log.println("Testing with custom Property tester") ;
105 testProperty("BackGraphicURL", new PropertyTester() {
106 protected Object getNewValue(String propName, Object oldValue) {
107 if (oldValue.equals(util.utils.getFullTestURL
108 ("space-metal.jpg")))
109 return util.utils.getFullTestURL("crazy-blue.jpg");
110 else
111 return util.utils.getFullTestURL("space-metal.jpg");
118 * Redefined method returns object, that contains changed property value.
120 public void _UserDefinedAttributes() {
121 log.println("Testing with custom property tester");
122 testProperty("UserDefinedAttributes", new PropertyTester() {
123 protected Object getNewValue(String propName, Object oldValue) {
124 XNameContainer NC = null;
125 try {
126 NC = (XNameContainer)
127 AnyConverter.toObject(new Type(XNameContainer.class),oldValue);
128 NC.insertByName("MyAttribute",
129 new AttributeData("","CDATA","Value"));
130 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
131 log.println("Failed to check 'UserDefinedAttributes'");
132 e.printStackTrace(log);
133 } catch ( com.sun.star.lang.WrappedTargetException e ) {
134 log.println("Failed to check 'UserDefinedAttributes'");
135 e.printStackTrace(log);
136 } catch ( com.sun.star.container.ElementExistException e ) {
137 log.println("Failed to check 'UserDefinedAttributes'");
138 e.printStackTrace(log);
140 return NC;
145 } //finish class _CellProperties