Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / chart / _Chart3DBarProperties.java
blob401b1d9bbe8acf7a314d5f14e79017172afa64c2
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 @Override
54 protected void before() {
55 log.println("Setting Diagram type to BarDiagram");
56 XChartDocument doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC");
57 if (doc == null) throw new StatusException(Status.failed
58 ("Relation 'CHARTDOC' not found"));
60 XDiagram bar = (XDiagram) tEnv.getObjRelation("BAR");
61 if (bar == null) throw new StatusException(Status.failed
62 ("Relation 'BAR' not found"));
64 doc.setDiagram(bar);
65 log.println("Change Diagram to 3D");
66 oObj = UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() );
67 try {
68 oObj.setPropertyValue("Dim3D", Boolean.TRUE);
69 } catch(com.sun.star.lang.WrappedTargetException e) {
70 log.println("Couldn't change Diagram to 3D");
71 e.printStackTrace(log);
72 throw new StatusException("Couldn't change Diagram to 3D", e);
73 } catch(com.sun.star.lang.IllegalArgumentException e) {
74 log.println("Couldn't change Diagram to 3D");
75 e.printStackTrace(log);
76 throw new StatusException("Couldn't change Diagram to 3D", e);
77 } catch(com.sun.star.beans.PropertyVetoException e) {
78 log.println("Couldn't change Diagram to 3D");
79 e.printStackTrace(log);
80 throw new StatusException("Couldn't change Diagram to 3D", e);
81 } catch(com.sun.star.beans.UnknownPropertyException e) {
82 log.println("Couldn't change Diagram to 3D");
83 e.printStackTrace(log);
84 throw new StatusException("Couldn't change Diagram to 3D", e);
88 /**
89 * Sets the diagram back to 2D as 2D rendering is much faster for the following tests.
91 @Override
92 protected void after() {
93 log.println("Setting Diagram back to 2D");
94 XChartDocument doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC");
95 if (doc == null) throw new StatusException(Status.failed
96 ("Relation 'CHARTDOC' not found"));
98 log.println("Change Diagram to 3D");
99 oObj = UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() );
100 try {
101 oObj.setPropertyValue("Dim3D", Boolean.FALSE);
102 } catch(com.sun.star.lang.WrappedTargetException e) {
103 log.println("Couldn't change Diagram back to 2D");
104 e.printStackTrace(log);
105 throw new StatusException("Couldn't change Diagram back to 2D", e);
106 } catch(com.sun.star.lang.IllegalArgumentException e) {
107 log.println("Couldn't change Diagram back to 2D");
108 e.printStackTrace(log);
109 throw new StatusException("Couldn't change Diagram back to 2D", e);
110 } catch(com.sun.star.beans.PropertyVetoException e) {
111 log.println("Couldn't change Diagram back to 2D");
112 e.printStackTrace(log);
113 throw new StatusException("Couldn't change Diagram back to 2D", e);
114 } catch(com.sun.star.beans.UnknownPropertyException e) {
115 log.println("Couldn't change Diagram back to 2D");
116 e.printStackTrace(log);
117 throw new StatusException("Couldn't change Diagram back to 2D", e);
121 } // finish class _Chart3DBarProperties