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 .
20 import com
.sun
.star
.accessibility
.AccessibleRole
;
21 import com
.sun
.star
.accessibility
.XAccessible
;
22 import com
.sun
.star
.accessibility
.XAccessibleComponent
;
23 import com
.sun
.star
.awt
.XWindow
;
24 import com
.sun
.star
.frame
.XModel
;
25 import com
.sun
.star
.text
.XTextDocument
;
26 import com
.sun
.star
.uno
.UnoRuntime
;
27 import com
.sun
.star
.uno
.XInterface
;
29 import java
.io
.PrintWriter
;
31 import lib
.StatusException
;
33 import lib
.TestEnvironment
;
34 import lib
.TestParameters
;
36 import util
.AccessibilityTools
;
37 import util
.SOfficeFactory
;
42 * Test for object which is represented accessible component of
43 * menu bar of a document. <p>
45 * Object implements the following interfaces :
47 * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li>
48 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
49 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
50 * <li> <code>::com::sun::star::accessibility::XAccessibleSelection</code></li>
51 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
54 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
55 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
56 * @see com.sun.star.accessibility.XAccessibleComponent
57 * @see com.sun.star.accessibility.XAccessibleSelection
58 * @see com.sun.star.accessibility.XAccessibleContext
59 * @see ifc.accessibility._XAccessibleExtendedComponent
60 * @see ifc.accessibility._XAccessibleEventBroadcaster
61 * @see ifc.accessibility._XAccessibleComponent
62 * @see ifc.accessibility._XAccessibleSelection
63 * @see ifc.accessibility._XAccessibleContext
65 public class AccessibleMenuBar
extends TestCase
{
66 private static XTextDocument xTextDoc
= null;
68 * Finds accessible component with role <code>MENUBAR</code>
69 * walking through the accessible component tree of a document.
72 protected TestEnvironment
createTestEnvironment(TestParameters Param
,
74 util
.utils
.pause(500);
76 XWindow xWindow
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
).
77 getCurrentController().getFrame().getContainerWindow();
79 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
82 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
83 XInterface oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.MENU_BAR
);
85 log
.println("ImplementationName " + utils
.getImplName(oObj
));
87 TestEnvironment tEnv
= new TestEnvironment(oObj
);
89 final XAccessibleComponent acomp
= UnoRuntime
.queryInterface(
90 XAccessibleComponent
.class,
93 tEnv
.addObjRelation("EventProducer",
94 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
95 public void fireEvent() {
96 System
.out
.println("Grabbing focus ... ");
101 tEnv
.addObjRelation("XAccessibleSelection.OneAlwaysSelected",
104 tEnv
.addObjRelation("XAccessibleSelection.multiSelection",
111 * Creates writer document.
114 protected void initialize(TestParameters Param
, PrintWriter log
) {
116 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
118 xTextDoc
= SOF
.createTextDoc(null);
119 } catch (com
.sun
.star
.uno
.Exception e
) {
120 throw new StatusException("Can't create document", e
);
128 protected void cleanup(TestParameters Param
, PrintWriter log
) {
129 util
.DesktopTools
.closeDoc(xTextDoc
);