bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / chart / _Chart3DBarProperties.java
blob99bb00065ddbd6b9fab6fe4d8a6e934d0e166394
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.Chart3DBarProperties</code>
32 * service properties:
33 * <ul>
34 * <li><code> SolidType</code></li>
35 * </ul> <p>
36 * This test needs the following object relations :
37 * <ul>
38 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
39 * to have reference to chart document </li>
40 * <li> <code>'BAR'</code> (of type <code>XDiagram</code>):
41 * relation that use as parameter for method setDiagram of chart document </li>
42 * <ul> <p>
43 * @see com.sun.star.chart.Chart3DBarProperties
44 * @see com.sun.star.chart.XChartDocument
45 * @see com.sun.star.chart.XDiagram
47 public class _Chart3DBarProperties extends MultiPropertyTest {
49 /**
50 * Retrieves object relations and prepares a chart document.
51 * @throws StatusException if one of relations not found.
53 protected void before() {
54 log.println("Setting Diagram type to BarDiagram");
55 XChartDocument doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC");
56 if (doc == null) throw new StatusException(Status.failed
57 ("Relation 'CHARTDOC' not found"));
59 XDiagram bar = (XDiagram) tEnv.getObjRelation("BAR");
60 if (bar == null) throw new StatusException(Status.failed
61 ("Relation 'BAR' not found"));
63 doc.setDiagram(bar);
64 log.println("Change Diagram to 3D");
65 oObj = UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() );
66 try {
67 oObj.setPropertyValue("Dim3D", new Boolean(true));
68 } catch(com.sun.star.lang.WrappedTargetException e) {
69 log.println("Couldn't change Diagram to 3D");
70 e.printStackTrace(log);
71 throw new StatusException("Couldn't change Diagram to 3D", e);
72 } catch(com.sun.star.lang.IllegalArgumentException e) {
73 log.println("Couldn't change Diagram to 3D");
74 e.printStackTrace(log);
75 throw new StatusException("Couldn't change Diagram to 3D", e);
76 } catch(com.sun.star.beans.PropertyVetoException e) {
77 log.println("Couldn't change Diagram to 3D");
78 e.printStackTrace(log);
79 throw new StatusException("Couldn't change Diagram to 3D", e);
80 } catch(com.sun.star.beans.UnknownPropertyException e) {
81 log.println("Couldn't change Diagram to 3D");
82 e.printStackTrace(log);
83 throw new StatusException("Couldn't change Diagram to 3D", e);
87 /**
88 * Sets the diagram back to 2D as 2D rendering is much faster for the following tests.
90 protected void after() {
91 log.println("Setting Diagram back to 2D");
92 XChartDocument doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC");
93 if (doc == null) throw new StatusException(Status.failed
94 ("Relation 'CHARTDOC' not found"));
96 log.println("Change Diagram to 3D");
97 oObj = UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() );
98 try {
99 oObj.setPropertyValue("Dim3D", new Boolean(false));
100 } catch(com.sun.star.lang.WrappedTargetException e) {
101 log.println("Couldn't change Diagram back to 2D");
102 e.printStackTrace(log);
103 throw new StatusException("Couldn't change Diagram back to 2D", e);
104 } catch(com.sun.star.lang.IllegalArgumentException e) {
105 log.println("Couldn't change Diagram back to 2D");
106 e.printStackTrace(log);
107 throw new StatusException("Couldn't change Diagram back to 2D", e);
108 } catch(com.sun.star.beans.PropertyVetoException e) {
109 log.println("Couldn't change Diagram back to 2D");
110 e.printStackTrace(log);
111 throw new StatusException("Couldn't change Diagram back to 2D", e);
112 } catch(com.sun.star.beans.UnknownPropertyException e) {
113 log.println("Couldn't change Diagram back to 2D");
114 e.printStackTrace(log);
115 throw new StatusException("Couldn't change Diagram back to 2D", e);
119 } // finish class _Chart3DBarProperties