bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleMenuSeparator.java
blobf7833598117526a0044f4ba999d34f82cfbbb2a8
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 .
18 package mod._toolkit;
20 import com.sun.star.accessibility.AccessibleRole;
21 import com.sun.star.accessibility.XAccessible;
22 import com.sun.star.accessibility.XAccessibleAction;
23 import com.sun.star.accessibility.XAccessibleContext;
24 import com.sun.star.awt.XWindow;
25 import com.sun.star.frame.XModel;
26 import com.sun.star.lang.XMultiServiceFactory;
27 import com.sun.star.text.XTextDocument;
28 import com.sun.star.uno.UnoRuntime;
29 import com.sun.star.uno.XInterface;
31 import java.io.PrintWriter;
33 import lib.StatusException;
34 import lib.TestCase;
35 import lib.TestEnvironment;
36 import lib.TestParameters;
38 import util.AccessibilityTools;
39 import util.SOfficeFactory;
40 import util.utils;
43 /**
44 * Test for object which is represented by accessible component
45 * of a menu separator in main menu of a document. <p>
47 * Object implements the following interfaces :
48 * <ul>
49 * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li>
50 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
51 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
52 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
53 * </ul> <p>
55 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
56 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
57 * @see com.sun.star.accessibility.XAccessibleComponent
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._XAccessibleContext
64 public class AccessibleMenuSeparator extends TestCase {
65 private static XTextDocument xTextDoc = null;
66 private static XMultiServiceFactory msf = null;
68 /**
69 * Finds first accessible component with role <code>SEPARATOR</code>
70 * and implementation name <code>AccessibleMenuSeparator</code>
71 * walking through the accessible component tree of a document.
73 @Override
74 protected TestEnvironment createTestEnvironment(TestParameters Param,
75 PrintWriter log) {
76 util.utils.pause(500);
78 XWindow xWindow = UnoRuntime.queryInterface(XModel.class, xTextDoc).
79 getCurrentController().getFrame().getContainerWindow();
81 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
83 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
84 XAccessibleContext MenuBar = AccessibilityTools.getAccessibleObjectForRole(xRoot,
85 AccessibleRole.MENU_BAR);
86 XAccessibleAction act = null;
87 XInterface oObj = null;
89 try {
90 //activate Edit-Menu
91 XAccessible Menu = MenuBar.getAccessibleChild(1);
92 act = UnoRuntime.queryInterface(
93 XAccessibleAction.class, Menu);
94 act.doAccessibleAction(0);
96 util.utils.pause(500);
99 //get a menue-separator
100 oObj = Menu.getAccessibleContext().getAccessibleChild(3);
101 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
102 e.printStackTrace(log);
105 log.println("ImplementationName " + utils.getImplName(oObj));
107 TestEnvironment tEnv = new TestEnvironment(oObj);
109 final XAccessibleAction aAct = act;
111 tEnv.addObjRelation("EventProducer",
112 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
113 public void fireEvent() {
114 try {
115 aAct.doAccessibleAction(0);
116 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
117 e.printStackTrace();
122 return tEnv;
126 * Creates writer document.
128 @Override
129 protected void initialize(TestParameters Param, PrintWriter log) {
130 try {
131 msf = Param.getMSF();
133 SOfficeFactory SOF = SOfficeFactory.getFactory(msf);
134 xTextDoc = SOF.createTextDoc(null);
135 } catch (com.sun.star.uno.Exception e) {
136 throw new StatusException("Can't create document", e);
141 * Disposes document.
143 @Override
144 protected void cleanup(TestParameters Param, PrintWriter log) {
145 util.DesktopTools.closeDoc(xTextDoc);