tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sd / AccessibleSlideView.java
blobea42567afe30c68e44ee992ae44a441e6ac6c346
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.AccessibilityTools;
27 import util.SOfficeFactory;
28 import util.utils;
30 import com.sun.star.accessibility.AccessibleRole;
31 import com.sun.star.accessibility.XAccessible;
32 import com.sun.star.awt.XWindow;
33 import com.sun.star.drawing.XDrawPages;
34 import com.sun.star.drawing.XDrawPagesSupplier;
35 import com.sun.star.frame.XDispatch;
36 import com.sun.star.frame.XDispatchProvider;
37 import com.sun.star.frame.XModel;
38 import com.sun.star.lang.XComponent;
39 import com.sun.star.uno.UnoRuntime;
40 import com.sun.star.uno.XInterface;
41 import com.sun.star.util.URL;
42 import com.sun.star.util.XURLTransformer;
44 public class AccessibleSlideView extends TestCase {
46 XModel aModel = null;
47 XComponent xImpressDoc = null;
49 /**
50 * Called to create an instance of <code>TestEnvironment</code> with an
51 * object to test and related objects. Subclasses should implement this
52 * method to provide the implementation and related objects. The method is
53 * called from <code>getTestEnvironment()</code>.
55 * @param Param test parameters
56 * @param log writer to log information while testing
58 * @see TestEnvironment
59 * @see #getTestEnvironment
61 @Override
62 protected TestEnvironment createTestEnvironment
63 (TestParameters Param, PrintWriter log) {
64 XInterface oObj = null;
66 XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, aModel);
67 XDrawPages oDPn = oDPS.getDrawPages();
69 oDPn.insertNewByIndex(0);
71 util.utils.waitForEventIdle(Param.getMSF());
73 XWindow xWindow = AccessibilityTools.getCurrentWindow (
74 aModel);
75 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
77 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
79 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT);
81 System.out.println("ImplementationName "+utils.getImplName(oObj));
83 TestEnvironment tEnv = new TestEnvironment(oObj);
85 //util.dbg.printInterfaces(oObj);
86 log.println("Implementationname: "+util.utils.getImplName(oObj));
88 final XDrawPages DrawPages = oDPn;
90 tEnv.addObjRelation("EventProducer",
91 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
92 public void fireEvent() {
93 DrawPages.insertNewByIndex(2);
95 });
97 return tEnv;
102 * Called while disposing a <code>TestEnvironment</code>.
103 * Disposes Impress documents.
104 * @param Param test parameters
105 * @param log writer to log information while testing
107 @Override
108 protected void cleanup( TestParameters Param, PrintWriter log ) {
109 log.println("disposing impress document");
110 util.DesktopTools.closeDoc(xImpressDoc);
114 * Called while the <code>TestCase</code> initialization. In the
115 * implementation does nothing. Subclasses can override to initialize
116 * objects shared among all <code>TestEnvironment</code>s.
118 * @param Param test parameters
119 * @param log writer to log information while testing
121 * @see #initializeTestCase
123 @Override
124 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
125 // get a soffice factory object
126 SOfficeFactory SOF = SOfficeFactory.getFactory(
127 Param.getMSF());
129 log.println( "creating an impress document" );
130 xImpressDoc = SOF.createImpressDoc(null);
132 util.utils.waitForEventIdle(Param.getMSF());
134 aModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc);
136 //Change to Outline view
137 try {
138 String aSlotID = "slot:27011";
139 XDispatchProvider xDispProv = UnoRuntime.queryInterface( XDispatchProvider.class,
140 aModel.getCurrentController() );
141 XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class,
142 Param.getMSF().
143 createInstance("com.sun.star.util.URLTransformer"));
144 // Because it's an in/out parameter we must use an array of URL objects.
145 URL[] aParseURL = new URL[1];
146 aParseURL[0] = new URL();
147 aParseURL[0].Complete = aSlotID;
148 xParser.parseStrict(aParseURL);
149 URL aURL = aParseURL[0];
150 XDispatch xDispatcher = xDispProv.queryDispatch( aURL,"",0);
151 if( xDispatcher != null )
152 xDispatcher.dispatch( aURL, null );
153 } catch (com.sun.star.uno.Exception e) {
154 log.println("Couldn't change mode");
157 util.utils.waitForEventIdle(Param.getMSF());