bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sch / ChXChartView.java
blob3b1edb11ab592211aace1e4ee77f8368bf9ef751
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;
22 import java.util.Comparator;
24 import lib.StatusException;
25 import lib.TestCase;
26 import lib.TestEnvironment;
27 import lib.TestParameters;
28 import util.SOfficeFactory;
30 import com.sun.star.chart.XChartDocument;
31 import com.sun.star.drawing.XShapeDescriptor;
32 import com.sun.star.frame.XController;
33 import com.sun.star.frame.XModel;
34 import com.sun.star.uno.UnoRuntime;
36 /**
37 * Test for object which is represented by service
38 * <code>com.sun.star.view.OfficeDocumentView</code>. <p>
39 * Object implements the following interfaces :
40 * <ul>
41 * <li> <code>com::sun::star::view::XViewSettingsSupplier</code></li>
42 * <li> <code>com::sun::star::view::XControlAccess</code></li>
43 * <li> <code>com::sun::star::view::XSelectionSupplier</code></li>
44 * </ul>
45 * @see com.sun.star.view.OfficeDocumentView
46 * @see com.sun.star.view.XViewSettingsSupplier
47 * @see com.sun.star.view.XControlAccess
48 * @see com.sun.star.view.XSelectionSupplier
49 * @see ifc.view._XViewSettingsSupplier
50 * @see ifc.view._XControlAccess
51 * @see ifc.view._XSelectionSupplier
53 public class ChXChartView extends TestCase {
54 XChartDocument xChartDoc = null;
56 /**
57 * Creates Chart document.
59 @Override
60 protected void initialize( TestParameters tParam, PrintWriter log ) {
61 // get a soffice factory object
62 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
64 try {
65 log.println( "creating a chartdocument" );
66 xChartDoc = SOF.createChartDoc();
67 } catch (com.sun.star.uno.Exception e) {
68 // Some exception occurs.FAILED
69 e.printStackTrace( log );
70 throw new StatusException( "Couldn't create document", e );
74 /**
75 * Disposes Chart document.
77 @Override
78 protected void cleanup( TestParameters tParam, PrintWriter log ) {
79 if( xChartDoc!=null ) {
80 log.println( " closing xChartDoc" );
81 util.DesktopTools.closeDoc(xChartDoc);
82 xChartDoc = null;
86 /**
87 * Creating a Testenvironment for the interfaces to be tested.
88 * Retrieves the current controller of the chart document using
89 * the interface <code>XModel</code>.The retrieved controller is the instance
90 * of the service <code>com.sun.star.view.OfficeDocumentView</code>.
91 * Obtains the main title and the legend of the chart document.
92 * Object relations created :
93 * <ul>
95 * </ul>
96 * @see com.sun.star.frame.XModel
98 @Override
99 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
101 XController oObj = null;
102 XModel oModel = null;
104 // get the ChartView
105 log.println( "getting ChartView" );
106 oModel = UnoRuntime.queryInterface(XModel.class, xChartDoc);
107 oObj = oModel.getCurrentController();
109 log.println( "creating a new environment for chartdocument object" );
110 TestEnvironment tEnv = new TestEnvironment( oObj );
112 tEnv.addObjRelation("Selections", new Object[]
113 {xChartDoc.getArea(), xChartDoc.getDiagram(), xChartDoc.getTitle(),
114 xChartDoc.getLegend()} );
116 tEnv.addObjRelation("Comparer", new Comparator<Object>() {
117 public int compare(Object o1, Object o2) {
118 XShapeDescriptor descr1 = UnoRuntime.queryInterface(XShapeDescriptor.class, o1);
119 XShapeDescriptor descr2 = UnoRuntime.queryInterface(XShapeDescriptor.class, o2);
120 if (descr1 == null || descr2 == null) {
121 return -1;
123 if (descr1.getShapeType().equals(descr2.getShapeType())) {
124 return 0;
126 return 1;
128 } );
130 return tEnv;
131 } // finish method getTestEnvironment
134 } // finish class ChXChartView