Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _CellProperties.java
blob25b739cc71e79b96863a360125bcb5a9f8d408ae
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 @Override
76 protected Object getNewValue(String propName, Object oldValue) {
77 return tEnv.getObjRelation("CellProperties.TextSection");
79 });
83 /**
84 * Redefined method returns value, that differs from property value.
86 public void _BackColor() {
87 final Short val1 = Short.valueOf( (short) 4 );
88 final Short val2 = Short.valueOf( (short) 6 );
89 log.println("Testing with custom Property tester") ;
90 testProperty("BackColor", new PropertyTester() {
91 @Override
92 protected Object getNewValue(String propName, Object oldValue) {
93 if ( oldValue.equals(val1) )
94 return val2;
95 else
96 return val1;
98 });
103 * Redefined method returns value, that differs from property value.
105 public void _BackGraphicURL() {
106 log.println("Testing with custom Property tester") ;
107 testProperty("BackGraphicURL", new PropertyTester() {
108 @Override
109 protected Object getNewValue(String propName, Object oldValue) {
110 if (oldValue.equals(util.utils.getFullTestURL
111 ("space-metal.jpg")))
112 return util.utils.getFullTestURL("crazy-blue.jpg");
113 else
114 return util.utils.getFullTestURL("space-metal.jpg");
121 * Redefined method returns object, that contains changed property value.
123 public void _UserDefinedAttributes() {
124 log.println("Testing with custom property tester");
125 testProperty("UserDefinedAttributes", new PropertyTester() {
126 @Override
127 protected Object getNewValue(String propName, Object oldValue) {
128 XNameContainer NC = null;
129 try {
130 NC = (XNameContainer)
131 AnyConverter.toObject(new Type(XNameContainer.class),oldValue);
132 NC.insertByName("MyAttribute",
133 new AttributeData("","CDATA","Value"));
134 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
135 log.println("Failed to check 'UserDefinedAttributes'");
136 e.printStackTrace(log);
137 } catch ( com.sun.star.lang.WrappedTargetException e ) {
138 log.println("Failed to check 'UserDefinedAttributes'");
139 e.printStackTrace(log);
140 } catch ( com.sun.star.container.ElementExistException e ) {
141 log.println("Failed to check 'UserDefinedAttributes'");
142 e.printStackTrace(log);
144 return NC;
149 } //finish class _CellProperties