tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XScrollBar.java
bloba298ed0829049d2a4284c2fc6ceb188b28f4bc73
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 ifc.awt;
20 import com.sun.star.accessibility.XAccessible;
21 import com.sun.star.accessibility.XAccessibleComponent;
22 import com.sun.star.awt.Point;
23 import com.sun.star.awt.ScrollBarOrientation;
24 import com.sun.star.awt.XScrollBar;
25 import com.sun.star.text.XTextDocument;
26 import com.sun.star.uno.UnoRuntime;
28 import java.awt.Robot;
29 import java.awt.event.InputEvent;
31 import lib.MultiMethodTest;
34 public class _XScrollBar extends MultiMethodTest {
35 public XScrollBar oObj;
36 public boolean adjusted = false;
37 com.sun.star.awt.XAdjustmentListener listener = new AdjustmentListener();
39 public void _addAdjustmentListener() throws Exception {
40 util.FormTools.switchDesignOf(tParam.getMSF(),
41 (XTextDocument) tEnv.getObjRelation("Document"));
42 oObj.addAdjustmentListener(listener);
43 adjustScrollBar();
45 boolean res = adjusted;
46 oObj.removeAdjustmentListener(listener);
47 adjusted = false;
48 adjustScrollBar();
49 res &= !adjusted;
50 tRes.tested("addAdjustmentListener()", res);
53 public void _removeAdjustmentListener() {
54 //this method is checked in addAdjustmentListener
55 //so that method is required here and if it works
56 //this method is given OK too
57 requiredMethod("addAdjustmentListener()");
58 tRes.tested("removeAdjustmentListener()", true);
61 public void _setBlockIncrement() {
62 oObj.setBlockIncrement(15);
63 oObj.setBlockIncrement(5);
64 int bi = oObj.getBlockIncrement();
65 tRes.tested("setBlockIncrement()",bi==5);
68 public void _getBlockIncrement() {
69 //this method is checked in the corresponding set method
70 //so that method is required here and if it works
71 //this method is given OK too
72 requiredMethod("setBlockIncrement()");
73 tRes.tested("getBlockIncrement()", true);
76 public void _setLineIncrement() {
77 oObj.setLineIncrement(12);
78 oObj.setLineIncrement(2);
79 int li = oObj.getLineIncrement();
80 tRes.tested("setLineIncrement()",li==2);
83 public void _getLineIncrement() {
84 //this method is checked in the corresponding set method
85 //so that method is required here and if it works
86 //this method is given OK too
87 requiredMethod("setLineIncrement()");
88 tRes.tested("getLineIncrement()", true);
91 public void _setMaximum() {
92 oObj.setMaximum(490);
93 oObj.setMaximum(480);
94 int max = oObj.getMaximum();
95 tRes.tested("setMaximum()",max==480);
98 public void _getMaximum() {
99 //this method is checked in the corresponding set method
100 //so that method is required here and if it works
101 //this method is given OK too
102 requiredMethod("setMaximum()");
103 tRes.tested("getMaximum()", true);
106 public void _setOrientation() {
107 oObj.setOrientation(ScrollBarOrientation.HORIZONTAL);
108 oObj.setOrientation(ScrollBarOrientation.VERTICAL);
109 int ori = oObj.getOrientation();
110 tRes.tested("setOrientation()",ori==ScrollBarOrientation.VERTICAL);
113 public void _getOrientation() {
114 //this method is checked in the corresponding set method
115 //so that method is required here and if it works
116 //this method is given OK too
117 requiredMethod("setOrientation()");
118 tRes.tested("getOrientation()", true);
121 public void _setValue() {
122 oObj.setMaximum(600);
123 oObj.setValue(480);
124 oObj.setValue(520);
125 int val = oObj.getValue();
126 tRes.tested("setValue()",val==520);
129 public void _getValue() {
130 //this method is checked in the corresponding set method
131 //so that method is required here and if it works
132 //this method is given OK too
133 requiredMethod("setValue()");
134 tRes.tested("getValue()", true);
137 public void _setVisibleSize() {
138 oObj.setVisibleSize(700);
139 oObj.setVisibleSize(500);
140 int vs = oObj.getVisibleSize();
141 tRes.tested("setVisibleSize()",vs==500);
144 public void _getVisibleSize() {
145 //this method is checked in the corresponding set method
146 //so that method is required here and if it works
147 //this method is given OK too
148 requiredMethod("setVisibleSize()");
149 tRes.tested("getVisibleSize()", true);
152 public void _setValues() {
153 oObj.setValues(80, 200, 300);
154 oObj.setValues(70, 210, 500);
155 int val = oObj.getValue();
156 int vs = oObj.getVisibleSize();
157 int max = oObj.getMaximum();
158 tRes.tested("setValues()",((val==70) && (vs==210) && (max==500)));
161 private void adjustScrollBar() {
164 XScrollBar sc = UnoRuntime.queryInterface(
165 XScrollBar.class, tEnv.getTestObject());
167 sc.setValue(500);
169 waitForEventIdle();
171 XAccessible acc = UnoRuntime.queryInterface(
172 XAccessible.class, tEnv.getTestObject());
174 XAccessibleComponent aCom = UnoRuntime.queryInterface(
175 XAccessibleComponent.class,
176 acc.getAccessibleContext());
178 Point location = aCom.getLocationOnScreen();
179 try {
180 Robot rob = new Robot();
181 rob.mouseMove(location.X + 50, location.Y + 75);
182 rob.mousePress(InputEvent.BUTTON1_MASK);
183 rob.mouseRelease(InputEvent.BUTTON1_MASK);
184 } catch (java.awt.AWTException e) {
185 System.out.println("couldn't adjust scrollbar");
188 waitForEventIdle();
191 public class AdjustmentListener
192 implements com.sun.star.awt.XAdjustmentListener {
193 public void adjustmentValueChanged(com.sun.star.awt.AdjustmentEvent adjustmentEvent) {
194 System.out.println("Adjustment Value changed");
195 System.out.println("AdjustmentEvent: " + adjustmentEvent.Value);
196 adjusted = true;
199 public void disposing(com.sun.star.lang.EventObject eventObject) {
200 System.out.println("Listener disposed");