bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sch / ChXDataPoint.java
blob2ca46dcf8254386d804d69b3b683396df83fbdb6
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 mod._sch;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
28 import util.utils;
30 import com.sun.star.beans.XPropertySet;
31 import com.sun.star.chart.XChartDocument;
32 import com.sun.star.chart.XDiagram;
33 import com.sun.star.lang.XComponent;
34 import com.sun.star.lang.XMultiServiceFactory;
35 import com.sun.star.uno.UnoRuntime;
37 /**
38 * Test for object which is represented by service
39 * <code>com.sun.star.chart.ChartDataPointProperties</code>. <p>
40 * Object implements the following interfaces
41 * <ul>
42 * <li> <code>com::sun::star::chart::ChartDataPointProperties</code></li>
43 * <li> <code>com::sun::star::drawing::FillProperties</code></li>
44 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
45 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
46 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
47 * <li> <code>com::sun::star::chart::Chart3DBarProperties</code></li>
48 * </ul>
49 * The following files used by this test :
50 * <ul>
51 * <li><b> TransparencyChart.sxs </b> : to load predefined chart
52 * document where two 'automatic' transparency styles exists :
53 * 'Transparency 1' and 'Transparency 2'.</li>
54 * </ul> <p>
55 * @see com.sun.star.chart.ChartDataPointProperties
56 * @see com.sun.star.drawing.FillProperties
57 * @see com.sun.star.drawing.LineProperties
58 * @see com.sun.star.style.CharacterProperties
59 * @see com.sun.star.beans.XPropertySet
60 * @see com.sun.star.chart.Chart3DBarProperties
61 * @see ifc.chart._ChartDataPointProperties
62 * @see ifc.drawing._FillProperties
63 * @see ifc.drawing._LineProperties
64 * @see ifc.style._CharacterProperties
65 * @see ifc.beans._XPropertySet
66 * @see ifc.chart._Chart3DBarProperties
68 public class ChXDataPoint extends TestCase {
69 XChartDocument xChartDoc = null;
71 /**
72 * Creates Chart document.
74 protected void initialize( TestParameters tParam, PrintWriter log ) {
75 // get a soffice factory object
76 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
78 try {
79 log.println( "creating a chartdocument" );
80 XComponent xComp = SOF.loadDocument(
81 utils.getFullTestURL("TransparencyChart.sxs"));
82 xChartDoc = UnoRuntime.queryInterface(XChartDocument.class,xComp);
83 } catch (com.sun.star.uno.Exception e) {
84 // Some exception occurs.FAILED
85 e.printStackTrace( log );
86 throw new StatusException( "Couldn't create document", e );
90 /**
91 * Disposes Chart document.
93 protected void cleanup( TestParameters tParam, PrintWriter log ) {
94 if( xChartDoc!=null ) {
95 log.println( " closing xChartDoc" );
96 util.DesktopTools.closeDoc(xChartDoc);
97 xChartDoc = null;
102 * Creating a Testenvironment for the interfaces to be tested.
103 * Retrieves the diagram of the chart document. Obtains the properties of
104 * the specified data point. The obtained properties is the instance of
105 * the service <code>com.sun.star.chart.ChartDataPointProperties</code>.
106 * Creates a XY-diagram and bar-diagram also.
107 * Object relations created :
108 * <ul>
109 * <li> <code>'LINE'</code> for
110 * {@link ifc.chart._ChartDataPointProperties}(the created XY-diagram)</li>
111 * <li> <code>'CHARTDOC'</code> for
112 * {@link ifc.chart._ChartDataPointProperties},
113 * {@link ifc.chart._Chart3DBarProperties}(the chart document)</li>
114 * <li> <code>'BAR'</code> for
115 * {@link ifc.chart._Chart3DBarProperties}(the created bar-diagram)</li>
116 * </ul>
118 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
120 XPropertySet oObj = null;
121 XDiagram oDiagram = null;
123 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
125 // get the DataRowPoint_Point
126 try {
127 log.println( "getting ChXDataRowPoint_Point" );
128 oDiagram = xChartDoc.getDiagram();
129 oObj = oDiagram.getDataPointProperties(1,1);
130 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
131 // Some exception occurs.FAILED
132 e.printStackTrace( log );
133 throw new StatusException( "Couldn't get ChXDataRowPoint_Point", e );
136 log.println( "creating a new environment for chartdocument object" );
137 TestEnvironment tEnv = new TestEnvironment( oObj );
139 Object line = SOF.createDiagram(xChartDoc,"XYDiagram");
140 tEnv.addObjRelation("LINE",line);
142 Object bar = SOF.createDiagram(xChartDoc,"BarDiagram");
143 tEnv.addObjRelation("BAR",bar);
145 log.println( "adding ChartDocument as mod relation to environment" );
146 tEnv.addObjRelation("CHARTDOC", xChartDoc);
148 return tEnv;
149 } // finish method getTestEnvironment
151 } // finish class ChXDataPoint