Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / chart / _LineDiagram.java
blob9037590a8a6132f8ce58b76565db3140384d35e1
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: _LineDiagram.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.chart;
33 import lib.MultiPropertyTest;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.beans.XPropertySet;
38 import com.sun.star.chart.XChartDocument;
39 import com.sun.star.chart.XDiagram;
40 import com.sun.star.uno.UnoRuntime;
42 /**
43 * Testing <code>com.sun.star.chart.LineDiagram</code>
44 * service properties :
45 * <ul>
46 * <li><code> SymbolType</code></li>
47 * <li><code> SymbolSize</code></li>
48 * <li><code> SymbolBitmapURL</code></li>
49 * <li><code> Lines</code></li>
50 * <li><code> SplineType</code></li>
51 * </ul> <p>
52 * The following predefined files needed to complete the test:
53 * <ul>
54 * <li> <code>poliball.gif</code> :
55 * for test of property 'SymbolBitmapURL' </li>
56 * <li> <code>crazy-blue.jpg</code> :
57 * for test of property 'SymbolBitmapURL' </li>
58 * <ul> <p>
59 * This test needs the following object relations :
60 * <ul>
61 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
62 * to have reference to chart document </li>
63 * <li> <code>'LINE'</code> (of type <code>XDiagram</code>):
64 * relation that use as parameter for method setDiagram of chart document </li>
65 * </ul> <p>
66 * @see com.sun.star.chart.LineDiagram
68 public class _LineDiagram extends MultiPropertyTest {
70 XChartDocument doc = null;
71 XDiagram oldDiagram = null;
73 /**
74 * Retrieves object relations.
75 * @throws StatusException If one of relations not found.
77 protected void before() {
78 log.println("Setting Diagram type to LineDiagram");
79 doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC");
80 if (doc == null) throw new StatusException(Status.failed
81 ("Relation 'CHARTDOC' not found"));
83 XDiagram Line = (XDiagram) tEnv.getObjRelation("LINE");
84 if (Line == null) throw new StatusException(Status.failed
85 ("Relation 'LINE' not found"));
87 oldDiagram = doc.getDiagram();
88 doc.setDiagram(Line);
89 oObj = (XPropertySet)
90 UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() );
93 /**
94 * Sets the old diagram for a chart document.
96 protected void after() {
97 doc.setDiagram(oldDiagram);
100 protected PropertyTester URLTester = new PropertyTester() {
101 protected Object getNewValue(String propName, Object oldValue)
102 throws java.lang.IllegalArgumentException {
103 if (oldValue.equals(util.utils.getFullTestURL("poliball.gif")))
104 return util.utils.getFullTestURL("crazy-blue.jpg"); else
105 return util.utils.getFullTestURL("poliball.gif");
109 protected PropertyTester SymbolTester = new PropertyTester() {
110 protected Object getNewValue(String propName, Object oldValue)
111 throws java.lang.IllegalArgumentException {
113 int a = com.sun.star.chart.ChartSymbolType.AUTO;
114 int b = com.sun.star.chart.ChartSymbolType.NONE;
115 if ( ((Integer) oldValue).intValue() == a)
116 return new Integer(b); else
117 return new Integer(a);
121 protected PropertyTester SplineTester = new PropertyTester() {
122 protected Object getNewValue(String propName, Object oldValue)
123 throws java.lang.IllegalArgumentException {
125 int a = 0;
126 int b = 2;
127 if ( ((Integer) oldValue).intValue() == a)
128 return new Integer(b); else
129 return new Integer(a);
134 * Tests property 'SymbolType'.
136 public void _SymbolType() {
137 log.println("Testing with custom Property tester") ;
138 testProperty("SymbolType", SymbolTester) ;
139 try {
140 oObj.setPropertyValue("SymbolType",new Integer(-2));
141 } catch(com.sun.star.lang.WrappedTargetException e) {
142 log.println("Exception while set property value");
143 e.printStackTrace(log);
144 throw new StatusException("Exception while set property value", e);
145 } catch(com.sun.star.lang.IllegalArgumentException e) {
146 log.println("Exception while set property value");
147 e.printStackTrace(log);
148 throw new StatusException("Exception while set property value", e);
149 } catch(com.sun.star.beans.PropertyVetoException e) {
150 log.println("Exception while set property value");
151 e.printStackTrace(log);
152 throw new StatusException("Exception while set property value", e);
153 } catch(com.sun.star.beans.UnknownPropertyException e) {
154 log.println("Exception while set property value");
155 e.printStackTrace(log);
156 throw new StatusException("Exception while set property value", e);
161 * Tests property 'SplineType'.
163 public void _SplineType() {
164 log.println("Testing with custom Property tester") ;
165 testProperty("SplineType", SplineTester) ;
169 * Tests property 'SymbolBitmapURL'.
171 public void _SymbolBitmapURL() {
172 log.println("Testing with custom Property tester") ;
173 try {
174 oObj.setPropertyValue("SymbolType",
175 new Integer(com.sun.star.chart.ChartSymbolType.BITMAPURL));
176 } catch(com.sun.star.lang.WrappedTargetException e) {
177 log.println("Exception while set property value");
178 e.printStackTrace(log);
179 throw new StatusException("Exception while set property value", e);
180 } catch(com.sun.star.lang.IllegalArgumentException e) {
181 log.println("Exception while set property value");
182 e.printStackTrace(log);
183 throw new StatusException("Exception while set property value", e);
184 } catch(com.sun.star.beans.PropertyVetoException e) {
185 log.println("Exception while set property value");
186 e.printStackTrace(log);
187 throw new StatusException("Exception while set property value", e);
188 } catch(com.sun.star.beans.UnknownPropertyException e) {
189 log.println("Exception while set property value");
190 e.printStackTrace(log);
191 throw new StatusException("Exception while set property value", e);
194 testProperty("SymbolBitmapURL", URLTester) ;
196 } // EOF LineDiagram