bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sch / ChXChartDocument.java
blob1b3be1c6bcb443c69b014da02e49d52305bec509
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.uno.UnoRuntime;
24 import com.sun.star.uno.XInterface;
25 import com.sun.star.view.XSelectionSupplier;
27 import java.io.PrintWriter;
29 import lib.StatusException;
30 import lib.TestCase;
31 import lib.TestEnvironment;
32 import lib.TestParameters;
34 import util.SOfficeFactory;
37 /**
38 * Test for object which is represented by service
39 * <code>com.sun.star.chart.ChartDocument</code>. <p>
40 * Object implements the following interfaces :
41 * <ul>
42 * <li> <code>com::sun::star::lang::XComponent</code></li>
43 * <li> <code>com::sun::star::frame::XModel</code></li>
44 * <li> <code>com::sun::star::chart::XChartDocument</code></li>
45 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
46 * <li> <code>com::sun::star::chart::ChartTableAddressSupplier</code></li>
47 * <li> <code>com::sun::star::chart::ChartDocument</code></li>
48 * </ul>
49 * @see com.sun.star.lang.XComponent
50 * @see com.sun.star.frame.XModel
51 * @see com.sun.star.chart.XChartDocument
52 * @see com.sun.star.beans.XPropertySet
53 * @see com.sun.star.chart.ChartTableAddressSupplier
54 * @see com.sun.star.chart.ChartDocument
55 * @see ifc.lang._XComponent
56 * @see ifc.frame._XModel
57 * @see ifc.chart._XChartDocument
58 * @see ifc.beans._XPropertySet
59 * @see ifc.chart._ChartTableAddressSupplier
60 * @see ifc.chart._ChartDocument
62 public class ChXChartDocument extends TestCase {
63 XChartDocument xChartDoc = null;
64 XChartDocument doc2 = null;
66 /**
67 * Disposes Chart documents.
69 @Override
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 @Override
110 protected synchronized TestEnvironment createTestEnvironment(TestParameters tParam,
111 PrintWriter log) {
112 // get a soffice factory object
113 SOfficeFactory SOF = SOfficeFactory.getFactory(
114 tParam.getMSF());
116 try {
117 log.println("creating a chartdocument");
118 xChartDoc = SOF.createChartDoc();
119 log.println("Waiting before opening second document");
120 doc2 = SOF.createChartDoc();
121 } catch (com.sun.star.uno.Exception e) {
122 // Some exception occurs.FAILED
123 e.printStackTrace(log);
124 throw new StatusException("Couldn't create document", e);
128 // get the chartdocument
129 log.println("getting ChartDocument");
131 XInterface oObj = xChartDoc;
133 XController cont1 = xChartDoc.getCurrentController();
134 XController cont2 = doc2.getCurrentController();
136 cont1.getFrame().setName("cont1");
137 cont2.getFrame().setName("cont2");
139 XSelectionSupplier sel = UnoRuntime.queryInterface(
140 XSelectionSupplier.class, cont1);
142 log.println("creating a new environment for chartdocument object");
144 TestEnvironment tEnv = new TestEnvironment(oObj);
146 log.println("Adding SelectionSupplier and Shape to select for XModel");
147 tEnv.addObjRelation("SELSUPP", sel);
148 tEnv.addObjRelation("TOSELECT", xChartDoc.getTitle());
150 log.println("adding Controller as ObjRelation for XModel");
151 tEnv.addObjRelation("CONT2", cont2);
153 log.println("adding another Diagram as mod relation to environment");
154 tEnv.addObjRelation("DIAGRAM",
155 SOF.createDiagram(xChartDoc, "PieDiagram"));
157 log.println("adding another ChartData as mod relation to environment");
159 XChartData ChartData = doc2.getData();
160 tEnv.addObjRelation("CHARTDATA", ChartData);
162 return tEnv;
163 } // finish method getTestEnvironment
164 } // finish class ChXChartDocument