tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XSpinValue.java
bloba8a65e2db30580319c04b44160e648600598c26d
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 ifc.awt;
21 import com.sun.star.accessibility.XAccessible;
22 import com.sun.star.accessibility.XAccessibleComponent;
23 import com.sun.star.awt.Point;
24 import com.sun.star.awt.ScrollBarOrientation;
25 import com.sun.star.awt.XSpinValue;
26 import com.sun.star.text.XTextDocument;
27 import com.sun.star.uno.UnoRuntime;
28 import java.awt.Robot;
29 import java.awt.event.InputEvent;
30 import lib.MultiMethodTest;
32 public class _XSpinValue extends MultiMethodTest {
34 public XSpinValue oObj;
35 public boolean adjusted = false;
36 com.sun.star.awt.XAdjustmentListener listener = new AdjustmentListener();
38 public void _addAdjustmentListener() throws Exception {
39 util.FormTools.switchDesignOf(tParam.getMSF(),
40 (XTextDocument) tEnv.getObjRelation("Document"));
41 oObj.addAdjustmentListener(listener);
42 adjustScrollBar();
44 boolean res = adjusted;
45 oObj.removeAdjustmentListener(listener);
46 adjusted = false;
47 adjustScrollBar();
48 res &= !adjusted;
49 tRes.tested("addAdjustmentListener()", res);
52 public void _removeAdjustmentListener() {
53 //this method is checked in addAdjustmentListener
54 //so that method is required here and if it works
55 //this method is given OK too
56 requiredMethod("addAdjustmentListener()");
57 tRes.tested("removeAdjustmentListener()", true);
60 public void _setSpinIncrement() {
61 oObj.setSpinIncrement(15);
62 oObj.setSpinIncrement(5);
63 int bi = oObj.getSpinIncrement();
64 tRes.tested("setSpinIncrement()",bi==5);
67 public void _getSpinIncrement() {
68 //this method is checked in the corresponding set method
69 //so that method is required here and if it works
70 //this method is given OK too
71 requiredMethod("setSpinIncrement()");
72 tRes.tested("getSpinIncrement()", true);
76 public void _setMaximum() {
77 oObj.setMaximum(490);
78 oObj.setMaximum(480);
79 int max = oObj.getMaximum();
80 tRes.tested("setMaximum()",max==480);
83 public void _getMaximum() {
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("setMaximum()");
88 tRes.tested("getMaximum()", true);
91 public void _setMinimum() {
92 oObj.setMinimum(90);
93 oObj.setMinimum(80);
94 int max = oObj.getMinimum();
95 tRes.tested("setMinimum()",max==80);
98 public void _getMinimum() {
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("setMinimum()");
103 tRes.tested("getMinimum()", true);
106 public void _setOrientation() {
107 boolean res = true;
108 try {
109 oObj.setOrientation(ScrollBarOrientation.HORIZONTAL);
110 oObj.setOrientation(ScrollBarOrientation.VERTICAL);
111 } catch (com.sun.star.lang.NoSupportException e) {
112 log.println("Couldn't set Orientation");
114 int ori = oObj.getOrientation();
115 res &= (ori==ScrollBarOrientation.VERTICAL);
116 tRes.tested("setOrientation()",res );
119 public void _getOrientation() {
120 //this method is checked in the corresponding set method
121 //so that method is required here and if it works
122 //this method is given OK too
123 requiredMethod("setOrientation()");
124 tRes.tested("getOrientation()", true);
127 public void _setValue() {
128 oObj.setMaximum(600);
129 oObj.setValue(480);
130 oObj.setValue(520);
131 int val = oObj.getValue();
132 tRes.tested("setValue()",val==520);
135 public void _getValue() {
136 //this method is checked in the corresponding set method
137 //so that method is required here and if it works
138 //this method is given OK too
139 requiredMethod("setValue()");
140 tRes.tested("getValue()", true);
143 public void _setValues() {
144 oObj.setValues(80, 200, 180);
145 oObj.setValues(70, 210, 200);
146 int val = oObj.getValue();
147 int min = oObj.getMinimum();
148 int max = oObj.getMaximum();
149 tRes.tested("setValues()",((min==70) && (max==210) && (val==200)));
152 private void adjustScrollBar() {
155 XSpinValue sv = UnoRuntime.queryInterface(
156 XSpinValue.class, tEnv.getTestObject());
158 sv.setValue(500);
160 waitForEventIdle();
162 XAccessible acc = UnoRuntime.queryInterface(
163 XAccessible.class, tEnv.getTestObject());
165 XAccessibleComponent aCom = UnoRuntime.queryInterface(
166 XAccessibleComponent.class,
167 acc.getAccessibleContext());
169 Point location = aCom.getLocationOnScreen();
170 try {
171 Robot rob = new Robot();
172 rob.mouseMove(location.X + 20, location.Y + 10);
173 rob.mousePress(InputEvent.BUTTON1_MASK);
174 rob.mouseRelease(InputEvent.BUTTON1_MASK);
175 } catch (java.awt.AWTException e) {
176 System.out.println("couldn't adjust scrollbar");
179 waitForEventIdle();
182 public class AdjustmentListener
183 implements com.sun.star.awt.XAdjustmentListener {
184 public void adjustmentValueChanged(com.sun.star.awt.AdjustmentEvent adjustmentEvent) {
185 System.out.println("Adjustment Value changed");
186 System.out.println("AdjustmentEvent: " + adjustmentEvent.Value);
187 adjusted = true;
190 public void disposing(com.sun.star.lang.EventObject eventObject) {
191 System.out.println("Listener disposed");