tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sch / ChXChartView.java
blob89873574de646d56d60441b093ba19947655cc85
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.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
29 import com.sun.star.chart.XChartDocument;
30 import com.sun.star.drawing.XShapeDescriptor;
31 import com.sun.star.frame.XController;
32 import com.sun.star.frame.XModel;
33 import com.sun.star.uno.UnoRuntime;
35 /**
36 * Test for object which is represented by service
37 * <code>com.sun.star.view.OfficeDocumentView</code>. <p>
38 * Object implements the following interfaces :
39 * <ul>
40 * <li> <code>com::sun::star::view::XViewSettingsSupplier</code></li>
41 * <li> <code>com::sun::star::view::XControlAccess</code></li>
42 * <li> <code>com::sun::star::view::XSelectionSupplier</code></li>
43 * </ul>
44 * @see com.sun.star.view.OfficeDocumentView
45 * @see com.sun.star.view.XViewSettingsSupplier
46 * @see com.sun.star.view.XControlAccess
47 * @see com.sun.star.view.XSelectionSupplier
48 * @see ifc.view._XViewSettingsSupplier
49 * @see ifc.view._XControlAccess
50 * @see ifc.view._XSelectionSupplier
52 public class ChXChartView extends TestCase {
53 XChartDocument xChartDoc = null;
55 /**
56 * Creates Chart document.
58 @Override
59 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
60 // get a soffice factory object
61 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
62 log.println( "creating a chartdocument" );
63 xChartDoc = SOF.createChartDoc();
66 /**
67 * Disposes Chart document.
69 @Override
70 protected void cleanup( TestParameters tParam, PrintWriter log ) {
71 if( xChartDoc!=null ) {
72 log.println( " closing xChartDoc" );
73 util.DesktopTools.closeDoc(xChartDoc);
74 xChartDoc = null;
78 /**
79 * Creating a TestEnvironment for the interfaces to be tested.
80 * Retrieves the current controller of the chart document using
81 * the interface <code>XModel</code>.The retrieved controller is the instance
82 * of the service <code>com.sun.star.view.OfficeDocumentView</code>.
83 * Obtains the main title and the legend of the chart document.
84 * Object relations created :
85 * <ul>
87 * </ul>
88 * @see com.sun.star.frame.XModel
90 @Override
91 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
93 XController oObj = null;
94 XModel oModel = null;
96 // get the ChartView
97 log.println( "getting ChartView" );
98 oModel = UnoRuntime.queryInterface(XModel.class, xChartDoc);
99 oObj = oModel.getCurrentController();
101 log.println( "creating a new environment for chartdocument object" );
102 TestEnvironment tEnv = new TestEnvironment( oObj );
104 tEnv.addObjRelation("Selections", new Object[]
105 {xChartDoc.getArea(), xChartDoc.getDiagram(), xChartDoc.getTitle(),
106 xChartDoc.getLegend()} );
108 tEnv.addObjRelation("Comparer", new Comparator<Object>() {
109 public int compare(Object o1, Object o2) {
110 XShapeDescriptor descr1 = UnoRuntime.queryInterface(XShapeDescriptor.class, o1);
111 XShapeDescriptor descr2 = UnoRuntime.queryInterface(XShapeDescriptor.class, o2);
112 if (descr1 == null || descr2 == null) {
113 return -1;
115 if (descr1.getShapeType().equals(descr2.getShapeType())) {
116 return 0;
118 return 1;
120 } );
122 return tEnv;
123 } // finish method getTestEnvironment
126 } // finish class ChXChartView