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.ChartData</code>. <p> 40 * Object implements the following interfaces : 41 * <ul> 42 * <li> <code>com::sun::star::chart::XChartData</code></li> 43 * </ul> 44 * @see com.sun.star.chart.ChartData 45 * @see com.sun.star.chart.XChartData 46 * @see ifc.chart._XChartData 47 */ 48 public class ChXChartData extends TestCase { 49 XChartDocument xChartDoc = null; 50 51 /** 52 * Creates Chart document. 53 */ initialize( TestParameters tParam, PrintWriter log )54 protected void initialize( TestParameters tParam, PrintWriter log ) { 55 // get a soffice factory object 56 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 57 58 try { 59 log.println( "creating a chartdocument" ); 60 xChartDoc = SOF.createChartDoc(null); 61 } catch (com.sun.star.uno.Exception e) { 62 // Some exception occures.FAILED 63 e.printStackTrace( log ); 64 throw new StatusException( "Couldn't create document", e ); 65 } 66 } 67 68 /** 69 * Disposes Chart document. 70 */ cleanup( TestParameters tParam, PrintWriter log )71 protected void cleanup( TestParameters tParam, PrintWriter log ) { 72 if( xChartDoc!=null ) { 73 log.println( " closing xChartDoc" ); 74 util.DesktopTools.closeDoc(xChartDoc); 75 xChartDoc = null; 76 } 77 } 78 79 /** 80 * Creating a Testenvironment for the interfaces to be tested. 81 * Retrieves the data source of the chart. This data source is the instance 82 * of the service <code>com.sun.star.chart.ChartData</code>. 83 * @see com.sun.star.chart.ChartData 84 */ createTestEnvironment(TestParameters Param, PrintWriter log)85 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 86 87 // get the Data 88 log.println( "getting Data" ); 89 XChartData oObj = (XChartData) xChartDoc.getData(); 90 91 log.println( "creating a new environment for chartdocument object" ); 92 TestEnvironment tEnv = new TestEnvironment( oObj ); 93 94 return tEnv; 95 } // finish method getTestEnvironment 96 97 } // finish class ChXChartData 98 99