Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XScrollBar.java
blob9c78eec7ff9bf66158d9889bc69ea7548c33e776
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() {
40 util.FormTools.switchDesignOf(tParam.getMSF(),
41 (XTextDocument) tEnv.getObjRelation("Document"));
42 util.utils.shortWait();
43 oObj.addAdjustmentListener(listener);
44 adjustScrollBar();
46 boolean res = adjusted;
47 oObj.removeAdjustmentListener(listener);
48 adjusted = false;
49 adjustScrollBar();
50 res &= !adjusted;
51 tRes.tested("addAdjustmentListener()", res);
54 public void _removeAdjustmentListener() {
55 //this method is checked in addAjustmentListener
56 //so that method is requiered here and if it works
57 //this method is given OK too
58 requiredMethod("addAdjustmentListener()");
59 tRes.tested("removeAdjustmentListener()", true);
62 public void _setBlockIncrement() {
63 oObj.setBlockIncrement(15);
64 oObj.setBlockIncrement(5);
65 int bi = oObj.getBlockIncrement();
66 tRes.tested("setBlockIncrement()",bi==5);
69 public void _getBlockIncrement() {
70 //this method is checked in the corresponding set method
71 //so that method is requiered here and if it works
72 //this method is given OK too
73 requiredMethod("setBlockIncrement()");
74 tRes.tested("getBlockIncrement()", true);
77 public void _setLineIncrement() {
78 oObj.setLineIncrement(12);
79 oObj.setLineIncrement(2);
80 int li = oObj.getLineIncrement();
81 tRes.tested("setLineIncrement()",li==2);
84 public void _getLineIncrement() {
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("setLineIncrement()");
89 tRes.tested("getLineIncrement()", true);
92 public void _setMaximum() {
93 oObj.setMaximum(490);
94 oObj.setMaximum(480);
95 int max = oObj.getMaximum();
96 tRes.tested("setMaximum()",max==480);
99 public void _getMaximum() {
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("setMaximum()");
104 tRes.tested("getMaximum()", true);
107 public void _setOrientation() {
108 oObj.setOrientation(ScrollBarOrientation.HORIZONTAL);
109 oObj.setOrientation(ScrollBarOrientation.VERTICAL);
110 int ori = oObj.getOrientation();
111 tRes.tested("setOrientation()",ori==ScrollBarOrientation.VERTICAL);
114 public void _getOrientation() {
115 //this method is checked in the corresponding set method
116 //so that method is requiered here and if it works
117 //this method is given OK too
118 requiredMethod("setOrientation()");
119 tRes.tested("getOrientation()", true);
122 public void _setValue() {
123 oObj.setMaximum(600);
124 oObj.setValue(480);
125 oObj.setValue(520);
126 int val = oObj.getValue();
127 tRes.tested("setValue()",val==520);
130 public void _getValue() {
131 //this method is checked in the corresponding set method
132 //so that method is requiered here and if it works
133 //this method is given OK too
134 requiredMethod("setValue()");
135 tRes.tested("getValue()", true);
138 public void _setVisibleSize() {
139 oObj.setVisibleSize(700);
140 oObj.setVisibleSize(500);
141 int vs = oObj.getVisibleSize();
142 tRes.tested("setVisibleSize()",vs==500);
145 public void _getVisibleSize() {
146 //this method is checked in the corresponding set method
147 //so that method is requiered here and if it works
148 //this method is given OK too
149 requiredMethod("setVisibleSize()");
150 tRes.tested("getVisibleSize()", true);
153 public void _setValues() {
154 oObj.setValues(80, 200, 300);
155 oObj.setValues(70, 210, 500);
156 int val = oObj.getValue();
157 int vs = oObj.getVisibleSize();
158 int max = oObj.getMaximum();
159 tRes.tested("setValues()",((val==70) && (vs==210) && (max==500)));
162 private void adjustScrollBar() {
165 XScrollBar sc = UnoRuntime.queryInterface(
166 XScrollBar.class, tEnv.getTestObject());
168 sc.setValue(500);
170 util.utils.shortWait();
172 XAccessible acc = UnoRuntime.queryInterface(
173 XAccessible.class, tEnv.getTestObject());
175 XAccessibleComponent aCom = UnoRuntime.queryInterface(
176 XAccessibleComponent.class,
177 acc.getAccessibleContext());
179 Point location = aCom.getLocationOnScreen();
180 try {
181 Robot rob = new Robot();
182 rob.mouseMove(location.X + 50, location.Y + 75);
183 rob.mousePress(InputEvent.BUTTON1_MASK);
184 rob.mouseRelease(InputEvent.BUTTON1_MASK);
185 } catch (java.awt.AWTException e) {
186 System.out.println("couldn't adjust scrollbar");
189 util.utils.shortWait();
192 public class AdjustmentListener
193 implements com.sun.star.awt.XAdjustmentListener {
194 public void adjustmentValueChanged(com.sun.star.awt.AdjustmentEvent adjustmentEvent) {
195 System.out.println("Adjustment Value changed");
196 System.out.println("AdjustmentEvent: " + adjustmentEvent.Value);
197 adjusted = true;
200 public void disposing(com.sun.star.lang.EventObject eventObject) {
201 System.out.println("Listener disposed");