tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sd / SdUnoOutlineView.java
blobee4aa536d582b88b39d9d44bb73eddf2882d742e
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._sd;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.DesktopTools;
27 import util.SOfficeFactory;
28 import util.utils;
30 import com.sun.star.awt.XWindow;
31 import com.sun.star.container.XIndexAccess;
32 import com.sun.star.drawing.XDrawPages;
33 import com.sun.star.drawing.XDrawPagesSupplier;
34 import com.sun.star.frame.XController;
35 import com.sun.star.frame.XDesktop;
36 import com.sun.star.frame.XDispatch;
37 import com.sun.star.frame.XDispatchProvider;
38 import com.sun.star.frame.XFrame;
39 import com.sun.star.frame.XModel;
40 import com.sun.star.lang.XComponent;
41 import com.sun.star.uno.UnoRuntime;
42 import com.sun.star.uno.XInterface;
43 import com.sun.star.util.URL;
44 import com.sun.star.util.XURLTransformer;
45 /**
46 * Test for object which is represented by service
47 * <code>com.sun.star.present.OutlineView</code>. <p>
48 * Object implements the following interfaces :
49 * <ul>
50 * <li> <code>com::sun::star::lang::XComponent</code></li>
51 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
52 * <li> <code>com::sun::star::frame::XController</code></li>
53 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
54 * <li> <code>com::sun::star::presentation::OutlineView</code></li>
55 * <li> <code>com::sun::star::frame::XDispatchProvider</code></li>
56 * <li> <code>com::sun::star::awt::XWindow</code></li>
57 * </ul>
58 * @see com.sun.star.lang.XComponent
59 * @see com.sun.star.lang.XServiceInfo
60 * @see com.sun.star.frame.XController
61 * @see com.sun.star.beans.XPropertySet
62 * @see com.sun.star.presentation.OutlineView
63 * @see com.sun.star.awt.XWindow
64 * @see com.sun.star.frame.XDispatchProvider
65 * @see ifc.lang._XComponent
66 * @see ifc.lang._XServiceInfo
67 * @see ifc.frame._XController
68 * @see ifc.beans._XPropertySet
69 * @see ifc.awt._XWindow
70 * @see ifc.presentation._OutlineView
71 * @see ifc.frame._XDispatchProvider
73 public class SdUnoOutlineView extends TestCase {
74 XDesktop xDesktop;
75 XComponent xImpressDoc;
76 XComponent xSecondDrawDoc;
78 /**
79 * Creates the instance of the service <code>com.sun.star.frame.Desktop</code>.
80 * @see com.sun.star.frame.Desktop
82 @Override
83 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
84 xDesktop = DesktopTools.createDesktop(Param.getMSF());
87 /**
88 * Called while disposing a <code>TestEnvironment</code>.
89 * Disposes Impress documents.
90 * @param Param test parameters
91 * @param log writer to log information while testing
93 @Override
94 protected void cleanup( TestParameters Param, PrintWriter log) {
95 log.println("disposing impress documents");
96 util.DesktopTools.closeDoc(xImpressDoc);
97 util.DesktopTools.closeDoc(xSecondDrawDoc);
101 * Creating a TestEnvironment for the interfaces to be tested.
102 * Creates two impress documents. After creating of the documents makes short
103 * wait to allow frames to be loaded. Retrieves the collection of the draw pages
104 * from the first document and takes one of them. Inserts some shapes to the
105 * retrieved draw page. Obtains a current controller from the first document
106 * using the interface <code>XModel</code>. The obtained controller is the
107 * instance of the service <code>com.sun.star.presentation.OutlineView</code>.
108 * Object relations created :
109 * <ul>
110 * <li> <code>'FirstModel'</code> for
111 * {@link ifc.frame._XController}(the interface <code>XModel</code> of
112 * the first created document) </li>
113 * <li> <code>'Frame'</code> for
114 * {@link ifc.frame._XController}(the frame of the created
115 * document) </li>
116 * <li> <code>'SecondModel'</code> for
117 * {@link ifc.frame._XController}(the interface <code>XModel</code> of
118 * the second created document) </li>
119 * <li> <code>'SecondController'</code> for
120 * {@link ifc.frame._XController}(the current controller of the second
121 * created document) </li>
122 * </ul>
123 * @see com.sun.star.frame.XModel
125 @Override
126 protected TestEnvironment createTestEnvironment
127 (TestParameters Param, PrintWriter log) throws Exception {
129 log.println( "creating a test environment" );
131 // get a soffice factory object
132 SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF());
134 log.println( "creating an impress document" );
135 xImpressDoc = SOF.createImpressDoc(null);
136 util.utils.waitForEventIdle(Param.getMSF());
138 XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc);
139 XDrawPages the_pages = oDPS.getDrawPages();
140 UnoRuntime.queryInterface(XIndexAccess.class,the_pages);
142 XModel aModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc);
144 XInterface oObj = aModel.getCurrentController();
146 //Change to Outline view
147 try {
148 String aSlotID = "slot:27010";
149 XDispatchProvider xDispProv = UnoRuntime.queryInterface( XDispatchProvider.class, oObj );
150 XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class,
151 Param.getMSF().createInstance("com.sun.star.util.URLTransformer"));
152 // Because it's an in/out parameter we must use an array of URL objects.
153 URL[] aParseURL = new URL[1];
154 aParseURL[0] = new URL();
155 aParseURL[0].Complete = aSlotID;
156 xParser.parseStrict(aParseURL);
157 URL aURL = aParseURL[0];
158 XDispatch xDispatcher = xDispProv.queryDispatch( aURL,"",0);
159 if( xDispatcher != null )
160 xDispatcher.dispatch( aURL, null );
161 } catch (com.sun.star.uno.Exception e) {
162 log.println("Couldn't change mode");
165 log.println( "creating a second impress document" );
166 xSecondDrawDoc = SOF.createImpressDoc(null);
167 util.utils.waitForEventIdle(Param.getMSF());
169 XModel aModel2 = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc);
171 XWindow anotherWindow = UnoRuntime.queryInterface(
172 XWindow.class,aModel2.getCurrentController());
174 oObj = aModel.getCurrentController();
177 log.println( "creating a new environment for impress view object" );
178 TestEnvironment tEnv = new TestEnvironment( oObj );
180 if (anotherWindow != null) {
181 tEnv.addObjRelation("XWindow.AnotherWindow", anotherWindow);
184 //Adding ObjRelations for XController
185 tEnv.addObjRelation("FirstModel", aModel);
187 tEnv.addObjRelation("XUserInputInterception.XModel", aModel);
189 XFrame the_frame = xDesktop.getCurrentFrame();
190 tEnv.addObjRelation("Frame", the_frame);
192 aModel = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc);
193 //Adding ObjRelations for XController
194 tEnv.addObjRelation("SecondModel", aModel);
196 XController secondController = aModel.getCurrentController();
197 tEnv.addObjRelation("SecondController", secondController);
198 tEnv.addObjRelation("XDispatchProvider.URL",
199 "slot:27069");
201 log.println("Implementation Name: " + utils.getImplName(oObj));
203 return tEnv;
205 } // finish method getTestEnvironment
208 } // finish class SdUnoOutlineView