tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScAccessibleCsvRuler.java
blobd3cd924643bff25f37159f1a203e12de7f7af84b
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.accessibility.XAccessibleText;
35 import com.sun.star.awt.XExtendedToolkit;
36 import com.sun.star.awt.XWindow;
37 import com.sun.star.beans.PropertyValue;
38 import com.sun.star.lang.XMultiServiceFactory;
39 import com.sun.star.uno.UnoRuntime;
40 import com.sun.star.uno.XInterface;
42 public class ScAccessibleCsvRuler extends TestCase {
44 static XAccessibleAction accAction = null;
46 /**
47 * Called to create an instance of <code>TestEnvironment</code> with an
48 * object to test and related objects. Subclasses should implement this
49 * method to provide the implementation and related objects. The method is
50 * called from <code>getTestEnvironment()</code>.
52 * @param Param test parameters
53 * @param log writer to log information while testing
55 * @see TestEnvironment
56 * @see #getTestEnvironment
58 @Override
59 protected TestEnvironment createTestEnvironment(TestParameters Param,
60 PrintWriter log) throws Exception {
61 XMultiServiceFactory msf = Param.getMSF();
63 XInterface oObj = (XInterface) msf.createInstance("com.sun.star.awt.Toolkit");
65 XExtendedToolkit tk = UnoRuntime.queryInterface(
66 XExtendedToolkit.class, oObj);
68 XWindow xWindow = UnoRuntime.queryInterface(XWindow.class,
69 tk.getActiveTopWindow());
71 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
73 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON,
74 "Cancel");
76 accAction = UnoRuntime.queryInterface(
77 XAccessibleAction.class, oObj);
79 XAccessibleContext acc = AccessibilityTools.getAccessibleObjectForRole(xRoot,
80 AccessibleRole.RADIO_BUTTON);
82 log.println("Click on: " + acc.getAccessibleName());
84 XAccessibleAction accAction2 = UnoRuntime.queryInterface(
85 XAccessibleAction.class, acc);
87 try {
88 accAction2.doAccessibleAction(0);
89 } catch (com.sun.star.lang.IndexOutOfBoundsException iae) {
93 AccessibilityTools.printAccessibleTree(log, xRoot);
94 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT,
95 "Ruler", true);
97 log.println("ImplementationName " + utils.getImplName(oObj));
99 TestEnvironment tEnv = new TestEnvironment(oObj);
101 tEnv.addObjRelation("EditOnly",
102 "This method isn't supported in this dialog");
104 XAccessibleText text = UnoRuntime.queryInterface(
105 XAccessibleText.class, oObj);
107 int lastone = 100;
109 for (int i = 0; i < 1000; i++) {
110 try {
111 text.getCharacterBounds(i);
112 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
113 lastone = i - 1;
115 break;
119 tEnv.addObjRelation("LimitedBounds", Integer.valueOf(lastone));
120 tEnv.addObjRelation("PreviousUsed",new int[]{11,22,33,44,55,66,77,88,99});
122 return tEnv;
126 * Called while disposing a <code>TestEnvironment</code>.
127 * Disposes calc document.
128 * @param Param test parameters
129 * @param log writer to log information while testing
131 @Override
132 protected void cleanup( TestParameters Param, PrintWriter log) {
136 * Called while the <code>TestCase</code> initialization. In the
137 * implementation does nothing. Subclasses can override to initialize
138 * objects shared among all <code>TestEnvironment</code>s.
140 * @param Param test parameters
141 * @param log writer to log information while testing
143 * @see #initializeTestCase
145 @Override
146 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
147 // get a soffice factory object
148 SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF());
150 log.println("opening dialog");
152 PropertyValue[] args = new PropertyValue[1];
153 try {
154 args[0] = new PropertyValue();
155 args[0].Name = "InteractionHandler";
156 args[0].Value = Param.getMSF().createInstance(
157 "com.sun.star.comp.uui.UUIInteractionHandler");
158 } catch(com.sun.star.uno.Exception e) {
161 String url= utils.getFullTestURL("10test.csv");
162 log.println("loading "+url);
163 SOF.loadDocument(url,args);