bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sch / ChXChartDocument.java
blobc5c1e13b6b6d72b56ebc0f09fbde06970d81c106
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 .
18 package mod._sch;
20 import com.sun.star.chart.XChartData;
21 import com.sun.star.chart.XChartDocument;
22 import com.sun.star.frame.XController;
23 import com.sun.star.lang.XMultiServiceFactory;
24 import com.sun.star.uno.UnoRuntime;
25 import com.sun.star.uno.XInterface;
26 import com.sun.star.view.XSelectionSupplier;
28 import java.io.PrintWriter;
30 import lib.StatusException;
31 import lib.TestCase;
32 import lib.TestEnvironment;
33 import lib.TestParameters;
35 import util.SOfficeFactory;
38 /**
39 * Test for object which is represented by service
40 * <code>com.sun.star.chart.ChartDocument</code>. <p>
41 * Object implements the following interfaces :
42 * <ul>
43 * <li> <code>com::sun::star::lang::XComponent</code></li>
44 * <li> <code>com::sun::star::frame::XModel</code></li>
45 * <li> <code>com::sun::star::chart::XChartDocument</code></li>
46 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
47 * <li> <code>com::sun::star::chart::ChartTableAddressSupplier</code></li>
48 * <li> <code>com::sun::star::chart::ChartDocument</code></li>
49 * </ul>
50 * @see com.sun.star.lang.XComponent
51 * @see com.sun.star.frame.XModel
52 * @see com.sun.star.chart.XChartDocument
53 * @see com.sun.star.beans.XPropertySet
54 * @see com.sun.star.chart.ChartTableAddressSupplier
55 * @see com.sun.star.chart.ChartDocument
56 * @see ifc.lang._XComponent
57 * @see ifc.frame._XModel
58 * @see ifc.chart._XChartDocument
59 * @see ifc.beans._XPropertySet
60 * @see ifc.chart._ChartTableAddressSupplier
61 * @see ifc.chart._ChartDocument
63 public class ChXChartDocument extends TestCase {
64 XChartDocument xChartDoc = null;
65 XChartDocument doc2 = null;
67 /**
68 * Disposes Chart documents.
70 protected void cleanup(TestParameters Param, PrintWriter log) {
71 if( xChartDoc!=null ) {
72 log.println( " closing xChartDoc" );
73 util.DesktopTools.closeDoc(xChartDoc);
74 xChartDoc = null;
76 if( doc2!=null ) {
77 log.println( " closing xChartDoc2" );
78 util.DesktopTools.closeDoc(doc2);
79 doc2 = null;
83 /**
84 * Creating a Testenvironment for the interfaces to be tested.
85 * Creates two chart documents and retrieves current controllers from them
86 * using the interface <code>XChartDocument</code>. The created documents
87 * is the instances of the service <code>com.sun.star.chart.ChartDocument</code>.
88 * Obtains the data source of the second created chart and creates
89 * a pie diagram.
90 * Object relations created :
91 * <ul>
92 * <li> <code>'SELSUPP'</code> for
93 * {@link ifc.frame._XModel}(the controller of the first created chart
94 * document)</li>
95 * <li> <code>'TOSELECT'</code> for
96 * {@link ifc.frame._XModel}(the shape of the main title of
97 * the first created chart document)</li>
98 * <li> <code>'CONT2'</code> for
99 * {@link ifc.frame._XModel}(the second created chart document)</li>
100 * <li> <code>'DIAGRAM'</code> for
101 * {@link ifc.chart._XChartDocument}(the created pie diagram)</li>
102 * <li> <code>'CHARTDATA'</code> for
103 * {@link ifc.chart._XChartDocument}(the data source of the second
104 * created chart)</li>
105 * </ul>
106 * @see com.sun.star.chart.XChartData
107 * @see com.sun.star.chart.ChartDocument
109 protected synchronized TestEnvironment createTestEnvironment(TestParameters tParam,
110 PrintWriter log) {
111 // get a soffice factory object
112 SOfficeFactory SOF = SOfficeFactory.getFactory(
113 (XMultiServiceFactory) tParam.getMSF());
115 try {
116 log.println("creating a chartdocument");
117 xChartDoc = SOF.createChartDoc(null);
118 log.println("Waiting before opening second document");
119 doc2 = SOF.createChartDoc(null);
120 } catch (com.sun.star.uno.Exception e) {
121 // Some exception occurs.FAILED
122 e.printStackTrace(log);
123 throw new StatusException("Couldn't create document", e);
127 // get the chartdocument
128 log.println("getting ChartDocument");
130 XInterface oObj = xChartDoc;
132 XController cont1 = xChartDoc.getCurrentController();
133 XController cont2 = doc2.getCurrentController();
135 cont1.getFrame().setName("cont1");
136 cont2.getFrame().setName("cont2");
138 XSelectionSupplier sel = UnoRuntime.queryInterface(
139 XSelectionSupplier.class, cont1);
141 log.println("creating a new environment for chartdocument object");
143 TestEnvironment tEnv = new TestEnvironment(oObj);
145 log.println("Adding SelectionSupplier and Shape to select for XModel");
146 tEnv.addObjRelation("SELSUPP", sel);
147 tEnv.addObjRelation("TOSELECT", xChartDoc.getTitle());
149 log.println("adding Controller as ObjRelation for XModel");
150 tEnv.addObjRelation("CONT2", cont2);
152 log.println("adding another Diagram as mod relation to environment");
153 tEnv.addObjRelation("DIAGRAM",
154 SOF.createDiagram(xChartDoc, "PieDiagram"));
156 log.println("adding another ChartData as mod relation to environment");
158 XChartData ChartData = doc2.getData();
159 tEnv.addObjRelation("CHARTDATA", ChartData);
161 return tEnv;
162 } // finish method getTestEnvironment
163 } // finish class ChXChartDocument