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
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.AccessibilityTools
;
28 import util
.SOfficeFactory
;
31 import com
.sun
.star
.accessibility
.AccessibleRole
;
32 import com
.sun
.star
.accessibility
.XAccessible
;
33 import com
.sun
.star
.awt
.XWindow
;
34 import com
.sun
.star
.drawing
.XDrawPages
;
35 import com
.sun
.star
.drawing
.XDrawPagesSupplier
;
36 import com
.sun
.star
.frame
.XDispatch
;
37 import com
.sun
.star
.frame
.XDispatchProvider
;
38 import com
.sun
.star
.frame
.XModel
;
39 import com
.sun
.star
.lang
.XComponent
;
40 import com
.sun
.star
.lang
.XMultiServiceFactory
;
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
;
46 public class AccessibleSlideView
extends TestCase
{
49 XComponent xImpressDoc
= null;
52 * Called to create an instance of <code>TestEnvironment</code> with an
53 * object to test and related objects. Subclasses should implement this
54 * method to provide the implementation and related objects. The method is
55 * called from <code>getTestEnvironment()</code>.
57 * @param Param test parameters
58 * @param log writer to log information while testing
60 * @see TestEnvironment
61 * @see #getTestEnvironment
63 protected TestEnvironment createTestEnvironment
64 (TestParameters Param
, PrintWriter log
) {
65 XInterface oObj
= null;
67 AccessibilityTools at
= new AccessibilityTools();
69 XDrawPagesSupplier oDPS
= UnoRuntime
.queryInterface(XDrawPagesSupplier
.class, aModel
);
70 XDrawPages oDPn
= oDPS
.getDrawPages();
72 oDPn
.insertNewByIndex(0);
76 XWindow xWindow
= AccessibilityTools
.getCurrentWindow (
77 (XMultiServiceFactory
)Param
.getMSF(),aModel
);
78 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
80 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
82 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.DOCUMENT
);
84 System
.out
.println("ImplementationName "+utils
.getImplName(oObj
));
86 TestEnvironment tEnv
= new TestEnvironment(oObj
);
88 //util.dbg.printInterfaces(oObj);
89 log
.println("Implementationname: "+util
.utils
.getImplName(oObj
));
91 final XDrawPages DrawPages
= oDPn
;
93 tEnv
.addObjRelation("EventProducer",
94 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
95 public void fireEvent() {
96 DrawPages
.insertNewByIndex(2);
105 * Called while disposing a <code>TestEnvironment</code>.
106 * Disposes Impress documents.
107 * @param Param test parameters
108 * @param log writer to log information while testing
110 protected void cleanup( TestParameters Param
, PrintWriter log
) {
111 log
.println("disposing impress document");
112 util
.DesktopTools
.closeDoc(xImpressDoc
);
116 * Called while the <code>TestCase</code> initialization. In the
117 * implementation does nothing. Subclasses can override to initialize
118 * objects shared among all <code>TestEnvironment</code>s.
120 * @param Param test parameters
121 * @param log writer to log information while testing
123 * @see #initializeTestCase
125 protected void initialize(TestParameters Param
, PrintWriter log
) {
126 // get a soffice factory object
127 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
128 (XMultiServiceFactory
)Param
.getMSF());
131 log
.println( "creating a impress document" );
132 xImpressDoc
= SOF
.createImpressDoc(null);
133 } catch (com
.sun
.star
.uno
.Exception e
) {
134 e
.printStackTrace( log
);
135 throw new StatusException("Couldn't create document", e
);
140 aModel
= UnoRuntime
.queryInterface(XModel
.class, xImpressDoc
);
142 //Change to Outline view
144 String aSlotID
= "slot:27011";
145 XDispatchProvider xDispProv
= UnoRuntime
.queryInterface( XDispatchProvider
.class,
146 aModel
.getCurrentController() );
147 XURLTransformer xParser
= UnoRuntime
.queryInterface(XURLTransformer
.class,
148 ((XMultiServiceFactory
)Param
.getMSF()).
149 createInstance("com.sun.star.util.URLTransformer"));
150 // Because it's an in/out parameter we must use an array of URL objects.
151 URL
[] aParseURL
= new URL
[1];
152 aParseURL
[0] = new URL();
153 aParseURL
[0].Complete
= aSlotID
;
154 xParser
.parseStrict(aParseURL
);
155 URL aURL
= aParseURL
[0];
156 XDispatch xDispatcher
= xDispProv
.queryDispatch( aURL
,"",0);
157 if( xDispatcher
!= null )
158 xDispatcher
.dispatch( aURL
, null );
159 } catch (com
.sun
.star
.uno
.Exception e
) {
160 log
.println("Couldn't change mode");
167 private void shortWait() {
170 } catch (InterruptedException e
) {
171 System
.out
.println("While waiting :" + e
) ;