Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XSpinValue.java
blobebf5aa75182ab7f8204f5458d7cabe2f7308ad64
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() {
39 util.FormTools.switchDesignOf(tParam.getMSF(),
40 (XTextDocument) tEnv.getObjRelation("Document"));
41 util.utils.shortWait();
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 addAjustmentListener
55 //so that method is requiered here and if it works
56 //this method is given OK too
57 requiredMethod("addAdjustmentListener()");
58 tRes.tested("removeAdjustmentListener()", true);
61 public void _setSpinIncrement() {
62 oObj.setSpinIncrement(15);
63 oObj.setSpinIncrement(5);
64 int bi = oObj.getSpinIncrement();
65 tRes.tested("setSpinIncrement()",bi==5);
68 public void _getSpinIncrement() {
69 //this method is checked in the corresponding set method
70 //so that method is requiered here and if it works
71 //this method is given OK too
72 requiredMethod("setSpinIncrement()");
73 tRes.tested("getSpinIncrement()", true);
77 public void _setMaximum() {
78 oObj.setMaximum(490);
79 oObj.setMaximum(480);
80 int max = oObj.getMaximum();
81 tRes.tested("setMaximum()",max==480);
84 public void _getMaximum() {
85 //this method is checked in the corresponding set method
86 //so that method is requiered here and if it works
87 //this method is given OK too
88 requiredMethod("setMaximum()");
89 tRes.tested("getMaximum()", true);
92 public void _setMinimum() {
93 oObj.setMinimum(90);
94 oObj.setMinimum(80);
95 int max = oObj.getMinimum();
96 tRes.tested("setMinimum()",max==80);
99 public void _getMinimum() {
100 //this method is checked in the corresponding set method
101 //so that method is requiered here and if it works
102 //this method is given OK too
103 requiredMethod("setMinimum()");
104 tRes.tested("getMinimum()", true);
107 public void _setOrientation() {
108 boolean res = true;
109 try {
110 oObj.setOrientation(ScrollBarOrientation.HORIZONTAL);
111 oObj.setOrientation(ScrollBarOrientation.VERTICAL);
112 } catch (com.sun.star.lang.NoSupportException e) {
113 log.println("Couldn't set Orientation");
115 int ori = oObj.getOrientation();
116 res &= (ori==ScrollBarOrientation.VERTICAL);
117 tRes.tested("setOrientation()",res );
120 public void _getOrientation() {
121 //this method is checked in the corresponding set method
122 //so that method is requiered here and if it works
123 //this method is given OK too
124 requiredMethod("setOrientation()");
125 tRes.tested("getOrientation()", true);
128 public void _setValue() {
129 oObj.setMaximum(600);
130 oObj.setValue(480);
131 oObj.setValue(520);
132 int val = oObj.getValue();
133 tRes.tested("setValue()",val==520);
136 public void _getValue() {
137 //this method is checked in the corresponding set method
138 //so that method is requiered here and if it works
139 //this method is given OK too
140 requiredMethod("setValue()");
141 tRes.tested("getValue()", true);
144 public void _setValues() {
145 oObj.setValues(80, 200, 180);
146 oObj.setValues(70, 210, 200);
147 int val = oObj.getValue();
148 int min = oObj.getMinimum();
149 int max = oObj.getMaximum();
150 tRes.tested("setValues()",((min==70) && (max==210) && (val==200)));
153 private void adjustScrollBar() {
156 XSpinValue sv = UnoRuntime.queryInterface(
157 XSpinValue.class, tEnv.getTestObject());
159 sv.setValue(500);
161 util.utils.shortWait();
163 XAccessible acc = UnoRuntime.queryInterface(
164 XAccessible.class, tEnv.getTestObject());
166 XAccessibleComponent aCom = UnoRuntime.queryInterface(
167 XAccessibleComponent.class,
168 acc.getAccessibleContext());
170 Point location = aCom.getLocationOnScreen();
171 try {
172 Robot rob = new Robot();
173 rob.mouseMove(location.X + 20, location.Y + 10);
174 rob.mousePress(InputEvent.BUTTON1_MASK);
175 rob.mouseRelease(InputEvent.BUTTON1_MASK);
176 } catch (java.awt.AWTException e) {
177 System.out.println("couldn't adjust scrollbar");
180 util.utils.shortWait();
183 public class AdjustmentListener
184 implements com.sun.star.awt.XAdjustmentListener {
185 public void adjustmentValueChanged(com.sun.star.awt.AdjustmentEvent adjustmentEvent) {
186 System.out.println("Adjustment Value changed");
187 System.out.println("AdjustmentEvent: " + adjustmentEvent.Value);
188 adjusted = true;
191 public void disposing(com.sun.star.lang.EventObject eventObject) {
192 System.out.println("Listener disposed");