bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / chart / _BarDiagram.java
blob601b6e0e570a8e48fe94950ec019d77c296da5a1
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.BarDiagram</code>
32 * service properties:
33 * <ul>
34 * <li><code>'Vertical'</code></li>
35 * <li><code>'Deep'</code></li>
36 * <li><code>'StackedBarsConnected'</code></li>
37 * <li><code>'NumberOfLines'</code></li>
38 * </ul>
39 * Properties testing is automated
40 * by <code>lib.MultiPropertyTest</code> except property
41 * <code>'NumberOfLines'</code>. <p>
42 * This test needs the following object relations :
43 * <ul>
44 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
45 * to have reference to chart document </li>
46 * <li> <code>'BAR'</code> (of type <code>XDiagram</code>):
47 * relation that use as parameter for method setDiagram of chart document </li>
48 * <ul> <p>
49 * @see com.sun.star.chart.BarDiagram
50 * @see com.sun.star.chart.XChartDocument
51 * @see com.sun.star.chart.XDiagram
52 * @see lib.MultiPropertyTest
54 public class _BarDiagram extends MultiPropertyTest {
56 XChartDocument doc = null;
57 XDiagram oldDiagram = null;
59 /**
60 * Retrieves object relations and prepares a chart document.
61 * @throws StatusException if one of relations not found.
63 protected void before() {
64 log.println("Setting Diagram type to BarDiagram");
65 doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC");
66 if (doc == null) throw new StatusException(Status.failed
67 ("Relation 'CHARTDOC' not found"));
69 XDiagram bar = (XDiagram) tEnv.getObjRelation("BAR");
70 if (bar == null) throw new StatusException(Status.failed
71 ("Relation 'BAR' not found"));
73 oldDiagram = doc.getDiagram();
74 doc.setDiagram(bar);
75 oObj = UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() );
76 log.println("Set it to 3D");
77 try {
78 oObj.setPropertyValue("Dim3D", new Boolean(true));
79 } catch(com.sun.star.lang.WrappedTargetException e) {
80 log.println("Exception while set property value");
81 e.printStackTrace(log);
82 throw new StatusException("Exception while set property value", e);
83 } catch(com.sun.star.lang.IllegalArgumentException e) {
84 log.println("Exception while set property value");
85 e.printStackTrace(log);
86 throw new StatusException("Exception while set property value", e);
87 } catch(com.sun.star.beans.PropertyVetoException e) {
88 log.println("Exception while set property value");
89 e.printStackTrace(log);
90 throw new StatusException("Exception while set property value", e);
91 } catch(com.sun.star.beans.UnknownPropertyException e) {
92 log.println("Exception while set property value");
93 e.printStackTrace(log);
94 throw new StatusException("Exception while set property value", e);
98 /**
99 * Sets the old diagram for a chart document.
101 protected void after() {
102 doc.setDiagram(oldDiagram);
105 protected PropertyTester LineTester = new PropertyTester() {
106 protected Object getNewValue(String propName, Object oldValue)
107 throws java.lang.IllegalArgumentException {
108 int a = 0;
109 int b = 2;
110 if ( ((Integer) oldValue).intValue() == a)
111 return new Integer(b); else
112 return new Integer(a);
117 * Tests property 'NumberOfLines'.
118 * This property tests when diagram in 2D-mode only
119 * except all other properties. This property is currently supported by
120 * two dimensional vertical bar charts only.
122 public void _NumberOfLines() {
123 log.println("Set it to 2D");
124 try {
125 oObj.setPropertyValue("Dim3D", new Boolean(false));
126 oObj.setPropertyValue("Vertical", new Boolean(false));
127 } catch(com.sun.star.lang.WrappedTargetException e) {
128 log.println("Exception while set property value");
129 e.printStackTrace(log);
130 throw new StatusException("Exception while set property value", e);
131 } catch(com.sun.star.lang.IllegalArgumentException e) {
132 log.println("Exception while set property value");
133 e.printStackTrace(log);
134 throw new StatusException("Exception while set property value", e);
135 } catch(com.sun.star.beans.PropertyVetoException e) {
136 log.println("Exception while set property value");
137 e.printStackTrace(log);
138 throw new StatusException("Exception while set property value", e);
139 } catch(com.sun.star.beans.UnknownPropertyException e) {
140 log.println("Exception while set property value");
141 e.printStackTrace(log);
142 throw new StatusException("Exception while set property value", e);
145 log.println("Testing with custom Property tester") ;
146 testProperty("NumberOfLines", LineTester) ;
148 } // EOF BarDiagram