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 .
21 import java
.io
.PrintWriter
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.AccessibilityTools
;
27 import util
.SOfficeFactory
;
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 AccessibleOutlineView
extends TestCase
{
47 XComponent xImpressDoc
= null;
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
62 protected TestEnvironment createTestEnvironment
63 (TestParameters Param
, PrintWriter log
) {
64 XInterface oObj
= null;
66 XWindow xWindow
= AccessibilityTools
.getCurrentWindow (
68 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
70 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.DOCUMENT
);
72 log
.println("ImplementationName "+utils
.getImplName(oObj
));
74 TestEnvironment tEnv
= new TestEnvironment(oObj
);
76 XDrawPagesSupplier oDPS
= UnoRuntime
.queryInterface(XDrawPagesSupplier
.class, aModel
);
77 final XDrawPages oDPn
= oDPS
.getDrawPages();
79 tEnv
.addObjRelation("EventMsg","Inserting a drawpage via API has no "+
80 "effect to the outline view #101050# \r\n"+
81 "Therefore the listener isn't called");
83 tEnv
.addObjRelation("EventProducer",
84 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
85 public void fireEvent() {
86 oDPn
.insertNewByIndex(1);
95 * Called while disposing a <code>TestEnvironment</code>.
96 * Disposes Impress documents.
97 * @param Param test parameters
98 * @param log writer to log information while testing
101 protected void cleanup( TestParameters Param
, PrintWriter log
) {
102 log
.println("disposing Impress document");
103 util
.DesktopTools
.closeDoc(xImpressDoc
);
107 * Called while the <code>TestCase</code> initialization. In the
108 * implementation does nothing. Subclasses can override to initialize
109 * objects shared among all <code>TestEnvironment</code>s.
111 * @param Param test parameters
112 * @param log writer to log information while testing
114 * @see #initializeTestCase
117 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
118 // get a soffice factory object
119 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
122 log
.println( "creating an impress document" );
123 xImpressDoc
= SOF
.createImpressDoc(null);
124 util
.utils
.waitForEventIdle(Param
.getMSF());
126 aModel
= UnoRuntime
.queryInterface(XModel
.class, xImpressDoc
);
128 XInterface oObj
= aModel
.getCurrentController();
130 //Change to Outline view
132 String aSlotID
= "slot:27010";
133 XDispatchProvider xDispProv
= UnoRuntime
.queryInterface( XDispatchProvider
.class, oObj
);
134 XURLTransformer xParser
= UnoRuntime
.queryInterface(XURLTransformer
.class,
136 createInstance("com.sun.star.util.URLTransformer"));
137 // Because it's an in/out parameter we must use an array of URL objects.
138 URL
[] aParseURL
= new URL
[1];
139 aParseURL
[0] = new URL();
140 aParseURL
[0].Complete
= aSlotID
;
141 xParser
.parseStrict(aParseURL
);
142 URL aURL
= aParseURL
[0];
143 XDispatch xDispatcher
= xDispProv
.queryDispatch( aURL
,"",0);
144 if( xDispatcher
!= null )
145 xDispatcher
.dispatch( aURL
, null );
146 } catch (com
.sun
.star
.uno
.Exception e
) {
147 log
.println("Couldn't change mode");
149 util
.utils
.waitForEventIdle(Param
.getMSF());