1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package mod._sch;
25 import java.io.PrintWriter;
26 
27 import lib.StatusException;
28 import lib.TestCase;
29 import lib.TestEnvironment;
30 import lib.TestParameters;
31 import util.SOfficeFactory;
32 
33 import com.sun.star.chart.XChartData;
34 import com.sun.star.chart.XChartDocument;
35 import com.sun.star.lang.XMultiServiceFactory;
36 
37 /**
38 * Test for object which is represented by service
39 * <code>com.sun.star.chart.ChartDataArray</code>. <p>
40 * Object implements the following interfaces :
41 * <ul>
42 *  <li> <code>com::sun::star::chart::XChartData</code></li>
43 *  <li> <code>com::sun::star::chart::XChartDataArray</code></li>
44 * </ul>
45 * @see com.sun.star.chart.ChartDataArray
46 * @see com.sun.star.chart.XChartData
47 * @see com.sun.star.chart.XChartDataArray
48 * @see ifc.chart._XChartData
49 * @see ifc.chart._XChartDataArray
50 */
51 public class ChXChartDataArray extends TestCase {
52     XChartDocument xChartDoc = null;
53 
54     /**
55     * Creates Chart document.
56     */
57     protected void initialize( TestParameters tParam, PrintWriter log ) {
58         // get a soffice factory object
59         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
60 
61         try {
62             log.println( "creating a chartdocument" );
63             xChartDoc = SOF.createChartDoc(null);;
64         } catch (com.sun.star.uno.Exception e) {
65             // Some exception occures.FAILED
66             e.printStackTrace( log );
67             throw new StatusException( "Couldn't create document", e );
68         }
69     }
70 
71     /**
72     * Disposes Chart document.
73     */
74     protected void cleanup( TestParameters tParam, PrintWriter log ) {
75         if( xChartDoc!=null ) {
76             log.println( "    closing xChartDoc" );
77             util.DesktopTools.closeDoc(xChartDoc);
78             xChartDoc = null;
79         }
80     }
81 
82     /**
83     * Creating a Testenvironment for the interfaces to be tested.
84     * Retrieves the data source of the chart. This data source is the instance
85     * of the service <code>com.sun.star.chart.ChartDataArray</code>.
86     * <code>com.sun.star.chart.ChartDataArray</code>.
87     * @see com.sun.star.chart.ChartDataArray
88     */
89     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
90 
91         // get the Data
92         log.println( "getting Data" );
93         XChartData oObj = (XChartData) xChartDoc.getData();
94 
95         log.println( "creating a new environment for chartdocument object" );
96         TestEnvironment tEnv = new TestEnvironment( oObj );
97 
98         return tEnv;
99     } // finish method getTestEnvironment
100 
101 }    // finish class ChXChartDataArray
102 
103