tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScAccessibleCsvCell.java
blob3e4be0a8fb5dc72d404f559038495867fdec7897
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._sc;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.AccessibilityTools;
27 import util.SOfficeFactory;
28 import util.utils;
30 import com.sun.star.accessibility.AccessibleRole;
31 import com.sun.star.accessibility.XAccessible;
32 import com.sun.star.accessibility.XAccessibleAction;
33 import com.sun.star.accessibility.XAccessibleContext;
34 import com.sun.star.awt.XExtendedToolkit;
35 import com.sun.star.awt.XWindow;
36 import com.sun.star.beans.PropertyValue;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
40 public class ScAccessibleCsvCell extends TestCase {
42 static XAccessibleAction accAction = null;
44 /**
45 * Called to create an instance of <code>TestEnvironment</code> with an
46 * object to test and related objects. Subclasses should implement this
47 * method to provide the implementation and related objects. The method is
48 * called from <code>getTestEnvironment()</code>.
50 * @param tParam test parameters
51 * @param log writer to log information while testing
53 * @see TestEnvironment
54 * @see #getTestEnvironment
56 @Override
57 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception {
59 XInterface oObj = (XInterface) tParam.getMSF().createInstance
60 ("com.sun.star.awt.Toolkit") ;
62 XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class,oObj);
64 XWindow xWindow = UnoRuntime.queryInterface(XWindow.class,tk.getActiveTopWindow());
66 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
68 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
69 oObj = AccessibilityTools.getAccessibleObjectForRole
70 (xRoot, AccessibleRole.PUSH_BUTTON, "Cancel");
72 accAction = UnoRuntime.queryInterface(XAccessibleAction.class, oObj);
74 oObj = AccessibilityTools.getAccessibleObjectForRole
75 (xRoot, AccessibleRole.TABLE, true);
77 XAccessibleContext cont = UnoRuntime.queryInterface(XAccessibleContext.class, oObj);
79 String name = "";
80 try {
81 XAccessible acc = cont.getAccessibleChild(3);
82 name = acc.getAccessibleContext().getAccessibleName();
83 log.println("Child: "+ name);
84 log.println("ImplementationName " + utils.getImplName(acc));
85 oObj = acc;
87 catch(com.sun.star.lang.IndexOutOfBoundsException e) {}
89 TestEnvironment tEnv = new TestEnvironment(oObj);
91 tEnv.addObjRelation("EditOnly",
92 "This method isn't supported in this dialog");
94 tEnv.addObjRelation("XAccessibleText.Text", name);
96 return tEnv;
99 /**
100 * Called while disposing a <code>TestEnvironment</code>.
101 * Disposes calc document.
102 * @param Param test parameters
103 * @param log writer to log information while testing
105 @Override
106 protected void cleanup( TestParameters Param, PrintWriter log) {
107 log.println( " closing Dialog " );
108 try {
109 accAction.doAccessibleAction(0);
110 } catch (com.sun.star.lang.IndexOutOfBoundsException iae) {
111 log.println("Couldn't close dialog");
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 @Override
126 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
127 // get a soffice factory object
128 SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF());
130 log.println("opening dialog");
132 PropertyValue[] args = new PropertyValue[1];
133 try {
134 args[0] = new PropertyValue();
135 args[0].Name = "InteractionHandler";
136 args[0].Value = Param.getMSF().createInstance(
137 "com.sun.star.comp.uui.UUIInteractionHandler");
138 } catch(com.sun.star.uno.Exception e) {
141 String url= utils.getFullTestURL("10test.csv");
142 log.println("loading "+url);
143 SOF.loadDocument(url,args);