bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sch / ChXDataRow.java
blob5c20ae6b77537801f1ac0fbb27d011b5e756faca
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.ChartDataRowProperties</code>. <p>
40 * Object implements the following interfaces :
41 * <ul>
42 * <li> <code>com::sun::star::drawing::FillProperties</code></li>
43 * <li> <code>com::sun::star::chart::ChartStatistics</code></li>
44 * <li> <code>com::sun::star::chart::ChartDataRowProperties</code></li>
45 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
46 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
47 * <li> <code>com::sun::star::chart::ChartDataPointProperties</code></li>
48 * <li> <code>com::sun::star::chart::Chart3DBarProperties</code></li>
49 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
50 * </ul>
51 * The following files used by this test :
52 * <ul>
53 * <li><b> TransparencyChart.sxs </b> : to load predefined chart
54 * document where two 'automatic' transparency styles exists :
55 * 'Transparency 1' and 'Transparency 2'.</li>
56 * </ul> <p>
57 * @see com.sun.star.drawing.FillProperties
58 * @see com.sun.star.chart.ChartStatistics
59 * @see com.sun.star.chart.ChartDataRowProperties
60 * @see com.sun.star.drawing.LineProperties
61 * @see com.sun.star.beans.XPropertySet
62 * @see com.sun.star.chart.ChartDataPointProperties
63 * @see com.sun.star.chart.Chart3DBarProperties
64 * @see com.sun.star.style.CharacterProperties
65 * @see ifc.drawing._FillProperties
66 * @see ifc.chart._ChartStatistics
67 * @see ifc.chart._ChartDataRowProperties
68 * @see ifc.drawing._LineProperties
69 * @see ifc.beans._XPropertySet
70 * @see ifc.chart._ChartDataPointProperties
71 * @see ifc.chart._Chart3DBarProperties
72 * @see ifc.style._CharacterProperties
74 public class ChXDataRow extends TestCase {
75 XChartDocument xChartDoc = null;
77 /**
78 * Creates Chart document.
80 protected void initialize( TestParameters tParam, PrintWriter log ) {
81 // get a soffice factory object
82 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
84 try {
85 log.println( "creating a chartdocument" );
86 XComponent xComp = SOF.loadDocument(
87 utils.getFullTestURL("TransparencyChart.sxs"));
88 xChartDoc = UnoRuntime.queryInterface(XChartDocument.class,xComp);
89 } catch (com.sun.star.uno.Exception e) {
90 // Some exception occurs.FAILED
91 e.printStackTrace( log );
92 throw new StatusException( "Couldn't create document", e );
96 /**
97 * Disposes Chart document.
99 protected synchronized void cleanup( TestParameters tParam, PrintWriter log ) {
100 if( xChartDoc!=null ) {
101 log.println( " closing xChartDoc" );
102 util.DesktopTools.closeDoc(xChartDoc);
103 xChartDoc = null;
109 * Creating a Testenvironment for the interfaces to be tested.
110 * Retrieves the diagram of the chart document. Obtains the properties of
111 * the specified data row. The obtained properties is the instance of
112 * the service <code>com.sun.star.chart.ChartDataRowProperties</code>.
113 * Creates a XY-diagram and bar-diagram also.
114 * Object relations created :
115 * <ul>
116 * <li> <code>'LINE'</code> for
117 * {@link ifc.chart._ChartDataPointProperties}(the created XY-diagram)</li>
118 * <li> <code>'CHARTDOC'</code> for
119 * {@link ifc.chart._ChartDataPointProperties},
120 * {@link ifc.chart._Chart3DBarProperties}(the chart document)</li>
121 * <li> <code>'BAR'</code> for
122 * {@link ifc.chart._Chart3DBarProperties}(the created bar-diagram)</li>
123 * </ul>
125 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
127 XPropertySet oObj = null;
128 XDiagram oDiagram = null;
129 // get the ChXDataRowPoint_Row
130 try {
131 log.println( "getting ChXDataRowPoint_Row" );
132 oDiagram = xChartDoc.getDiagram();
133 oObj = oDiagram.getDataRowProperties(1);
134 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
135 // Some exception occurs.FAILED
136 e.printStackTrace( log );
137 throw new StatusException( "Couldn't get ChXDataRowPoint_Row", e );
140 log.println( "creating a new environment for chartdocument object" );
141 TestEnvironment tEnv = new TestEnvironment( oObj );
143 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
145 Object line = SOF.createDiagram(xChartDoc,"XYDiagram");
146 tEnv.addObjRelation("LINE",line);
148 Object bar = SOF.createDiagram(xChartDoc,"BarDiagram");
149 tEnv.addObjRelation("BAR",bar);
151 log.println( "adding ChartDocument as mod relation to environment" );
152 tEnv.addObjRelation("CHARTDOC", xChartDoc);
154 return tEnv;
155 } // finish method getTestEnvironment
158 } // finish class ChXDataRow