bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / chart / _LineDiagram.java
blob4632bc8f9e66c6dbf74e0a3fda585479cfd2b4e9
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.chart;
21 import lib.MultiPropertyTest;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.beans.XPropertySet;
26 import com.sun.star.chart.XChartDocument;
27 import com.sun.star.chart.XDiagram;
28 import com.sun.star.uno.UnoRuntime;
30 /**
31 * Testing <code>com.sun.star.chart.LineDiagram</code>
32 * service properties :
33 * <ul>
34 * <li><code> SymbolType</code></li>
35 * <li><code> SymbolSize</code></li>
36 * <li><code> SymbolBitmapURL</code></li>
37 * <li><code> Lines</code></li>
38 * <li><code> SplineType</code></li>
39 * </ul> <p>
40 * The following predefined files needed to complete the test:
41 * <ul>
42 * <li> <code>space-metal.jpg</code> :
43 * for test of property 'SymbolBitmapURL' </li>
44 * <li> <code>crazy-blue.jpg</code> :
45 * for test of property 'SymbolBitmapURL' </li>
46 * <ul> <p>
47 * This test needs the following object relations :
48 * <ul>
49 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
50 * to have reference to chart document </li>
51 * <li> <code>'LINE'</code> (of type <code>XDiagram</code>):
52 * relation that use as parameter for method setDiagram of chart document </li>
53 * </ul> <p>
54 * @see com.sun.star.chart.LineDiagram
56 public class _LineDiagram extends MultiPropertyTest {
58 XChartDocument doc = null;
59 XDiagram oldDiagram = null;
61 /**
62 * Retrieves object relations.
63 * @throws StatusException If one of relations not found.
65 protected void before() {
66 log.println("Setting Diagram type to LineDiagram");
67 doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC");
68 if (doc == null) throw new StatusException(Status.failed
69 ("Relation 'CHARTDOC' not found"));
71 XDiagram Line = (XDiagram) tEnv.getObjRelation("LINE");
72 if (Line == null) throw new StatusException(Status.failed
73 ("Relation 'LINE' not found"));
75 oldDiagram = doc.getDiagram();
76 doc.setDiagram(Line);
77 oObj = UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() );
80 /**
81 * Sets the old diagram for a chart document.
83 protected void after() {
84 doc.setDiagram(oldDiagram);
87 protected PropertyTester URLTester = new PropertyTester() {
88 protected Object getNewValue(String propName, Object oldValue)
89 throws java.lang.IllegalArgumentException {
90 if (oldValue.equals(util.utils.getFullTestURL("space-metal.jpg")))
91 return util.utils.getFullTestURL("crazy-blue.jpg"); else
92 return util.utils.getFullTestURL("space-metal.jpg");
94 } ;
96 protected PropertyTester SymbolTester = new PropertyTester() {
97 protected Object getNewValue(String propName, Object oldValue)
98 throws java.lang.IllegalArgumentException {
100 int a = com.sun.star.chart.ChartSymbolType.AUTO;
101 int b = com.sun.star.chart.ChartSymbolType.NONE;
102 if ( ((Integer) oldValue).intValue() == a)
103 return new Integer(b); else
104 return new Integer(a);
108 protected PropertyTester SplineTester = new PropertyTester() {
109 protected Object getNewValue(String propName, Object oldValue)
110 throws java.lang.IllegalArgumentException {
112 int a = 0;
113 int b = 2;
114 if ( ((Integer) oldValue).intValue() == a)
115 return new Integer(b); else
116 return new Integer(a);
121 * Tests property 'SymbolType'.
123 public void _SymbolType() {
124 log.println("Testing with custom Property tester") ;
125 testProperty("SymbolType", SymbolTester) ;
126 try {
127 oObj.setPropertyValue("SymbolType",new Integer(-2));
128 } catch(com.sun.star.lang.WrappedTargetException e) {
129 log.println("Exception while set property value");
130 e.printStackTrace(log);
131 throw new StatusException("Exception while set property value", e);
132 } catch(com.sun.star.lang.IllegalArgumentException e) {
133 log.println("Exception while set property value");
134 e.printStackTrace(log);
135 throw new StatusException("Exception while set property value", e);
136 } catch(com.sun.star.beans.PropertyVetoException e) {
137 log.println("Exception while set property value");
138 e.printStackTrace(log);
139 throw new StatusException("Exception while set property value", e);
140 } catch(com.sun.star.beans.UnknownPropertyException e) {
141 log.println("Exception while set property value");
142 e.printStackTrace(log);
143 throw new StatusException("Exception while set property value", e);
148 * Tests property 'SplineType'.
150 public void _SplineType() {
151 log.println("Testing with custom Property tester") ;
152 testProperty("SplineType", SplineTester) ;
156 * Tests property 'SymbolBitmapURL'.
158 public void _SymbolBitmapURL() {
159 log.println("Testing with custom Property tester") ;
160 try {
161 oObj.setPropertyValue("SymbolType",
162 new Integer(com.sun.star.chart.ChartSymbolType.BITMAPURL));
163 } catch(com.sun.star.lang.WrappedTargetException e) {
164 log.println("Exception while set property value");
165 e.printStackTrace(log);
166 throw new StatusException("Exception while set property value", e);
167 } catch(com.sun.star.lang.IllegalArgumentException e) {
168 log.println("Exception while set property value");
169 e.printStackTrace(log);
170 throw new StatusException("Exception while set property value", e);
171 } catch(com.sun.star.beans.PropertyVetoException e) {
172 log.println("Exception while set property value");
173 e.printStackTrace(log);
174 throw new StatusException("Exception while set property value", e);
175 } catch(com.sun.star.beans.UnknownPropertyException e) {
176 log.println("Exception while set property value");
177 e.printStackTrace(log);
178 throw new StatusException("Exception while set property value", e);
181 testProperty("SymbolBitmapURL", URLTester) ;
183 } // EOF LineDiagram