Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _svtools / AccessibleBrowseBoxTableCell.java
blob94627bb96bf4e0e5c5bd64924c652296df348393
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._svtools;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.AccessibilityTools;
28 import util.DesktopTools;
29 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.beans.PropertyValue;
35 import com.sun.star.frame.XController;
36 import com.sun.star.frame.XDesktop;
37 import com.sun.star.frame.XDispatch;
38 import com.sun.star.frame.XDispatchProvider;
39 import com.sun.star.frame.XFrame;
40 import com.sun.star.frame.XModel;
41 import com.sun.star.lang.XInitialization;
42 import com.sun.star.text.XTextDocument;
43 import com.sun.star.uno.UnoRuntime;
44 import com.sun.star.uno.XInterface;
45 import com.sun.star.util.URL;
47 /**
48 * Test for object that implements the following interfaces :
49 * <ul>
50 * <li>
51 * <code>::com::sun::star::accessibility::XAccessibleContext
52 * </code></li>
53 * <li>
54 * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
55 * </code></li>
56 * </ul> <p>
58 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
59 * @see com.sun.star.accessibility.XAccessibleContext
60 * @see ifc.accessibility._XAccessibleEventBroadcaster
61 * @see ifc.accessibility._XAccessibleContext
63 public class AccessibleBrowseBoxTableCell extends TestCase {
65 static XDesktop the_Desk;
66 static XTextDocument xTextDoc;
68 /**
69 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
71 @Override
72 protected void initialize(TestParameters Param, PrintWriter log) {
73 the_Desk = UnoRuntime.queryInterface(
74 XDesktop.class, DesktopTools.createDesktop(Param.getMSF()) );
77 /**
78 * Disposes the document, if exists, created in
79 * <code>createTestEnvironment</code> method.
81 @Override
82 protected void cleanup( TestParameters Param, PrintWriter log) {
84 log.println("disposing xTextDoc");
86 if (xTextDoc != null) {
87 xTextDoc.dispose();
91 /**
92 * Creates a text document. Opens the DataSource browser and loads
93 * the table. Creates an instance of the service
94 * <code>com.sun.star.awt.Toolkit</code> and gets active top window.
95 * Then obtains an accessible object with the role
96 * <code>AccessibleRole.TABLE_CELL</code>.
97 * Object relations created :
98 * <ul>
99 * <li> <code>'EventProducer'</code> for
100 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
101 * method <code>fireEvent()</code> is empty because object is transient
102 * </li>
103 * </ul>
105 * @param tParam test parameters
106 * @param log writer to log information while testing
108 * @see com.sun.star.awt.Toolkit
109 * @see com.sun.star.accessibility.AccessibleRole
110 * @see ifc.accessibility._XAccessibleEventBroadcaster
111 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
113 @Override
114 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
116 log.println( "creating a test environment" );
118 if (xTextDoc != null) xTextDoc.dispose();
120 // get a soffice factory object
121 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
123 try {
124 log.println( "creating a text document" );
125 xTextDoc = SOF.createTextDoc(null);
126 } catch ( com.sun.star.uno.Exception e ) {
127 // Some exception occurs.FAILED
128 e.printStackTrace( log );
129 throw new StatusException( "Couldn't create document", e );
132 util.utils.pause(5000);
134 XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc);
136 XController secondController = aModel1.getCurrentController();
139 XDispatchProvider aProv = UnoRuntime.queryInterface(XDispatchProvider.class,secondController);
141 XDispatch getting = null;
143 log.println( "opening DatasourceBrowser" );
144 URL the_url = new URL();
145 the_url.Complete = ".component:DB/DataSourceBrowser";
146 getting = aProv.queryDispatch(the_url,"_beamer",12);
147 PropertyValue[] noArgs = new PropertyValue[0];
148 getting.dispatch(the_url,noArgs);
150 util.utils.pause(5000);
152 XFrame the_frame1 = the_Desk.getCurrentFrame();
154 if (the_frame1 == null) {
155 log.println("Current frame was not found !!!");
158 XFrame the_frame2 = the_frame1.findFrame("_beamer",4);
160 the_frame2.setName("DatasourceBrowser");
162 XInterface oObj = null;
164 UnoRuntime.queryInterface(
165 XInitialization.class, the_frame2.getController());
167 Object[] params = new Object[3];
168 PropertyValue param1 = new PropertyValue();
169 param1.Name = "DataSourceName";
170 param1.Value = "Bibliography";
171 params[0] = param1;
172 PropertyValue param2 = new PropertyValue();
173 param2.Name = "CommandType";
174 param2.Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE);
175 params[1] = param2;
176 PropertyValue param3 = new PropertyValue();
177 param3.Name = "Command";
178 param3.Value = "biblio";
179 params[2] = param3;
181 util.utils.pause(5000);
183 XWindow xWindow = secondController.getFrame().getContainerWindow();
185 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
187 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE_CELL);
189 log.println("ImplementationName: "+util.utils.getImplName(oObj));
191 TestEnvironment tEnv = new TestEnvironment( oObj );
193 tEnv.addObjRelation("EventProducer",
194 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){
195 public void fireEvent() {
199 return tEnv;