1 /* 2 * This file is part of the LibreOffice project. 3 * 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/. 7 * 8 * This file incorporates work covered by the following license notice: 9 * 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 . 17 */ 18 19 package ifc.awt; 20 21 import lib.MultiMethodTest; 22 23 import com.sun.star.awt.SpinEvent; 24 import com.sun.star.awt.XSpinField; 25 import com.sun.star.awt.XSpinListener; 26 import com.sun.star.lang.EventObject; 27 28 /** 29 * Testing <code>com.sun.star.awt.XSpinField</code> 30 * interface methods : 31 * <ul> 32 * <li><code> addSpinListener()</code></li> 33 * <li><code> removeSpinListener()</code></li> 34 * <li><code> up()</code></li> 35 * <li><code> down()</code></li> 36 * <li><code> first()</code></li> 37 * <li><code> last()</code></li> 38 * <li><code> enableRepeat()</code></li> 39 * </ul> <p> 40 * Test is <b> NOT </b> multithread compliant. <p> 41 * @see com.sun.star.awt.XSpinField 42 */ 43 public class _XSpinField extends MultiMethodTest { 44 45 public XSpinField oObj = null; 46 47 /** 48 * Listener implementation which set flags on appropriate 49 * listener methods calls. 50 */ 51 protected static class TestListener implements XSpinListener { 52 public boolean upFl = false ; 53 public boolean downFl = false ; 54 public boolean firstFl = false ; 55 public boolean lastFl = false ; 56 up(SpinEvent e)57 public void up(SpinEvent e) { 58 upFl = true ; 59 } down(SpinEvent e)60 public void down(SpinEvent e) { 61 downFl = true ; 62 } first(SpinEvent e)63 public void first(SpinEvent e) { 64 firstFl = true ; 65 } last(SpinEvent e)66 public void last(SpinEvent e) { 67 lastFl = true ; 68 } disposing(EventObject e)69 public void disposing(EventObject e) {} 70 } 71 72 private final TestListener listener = new TestListener() ; 73 74 /** 75 * Just adds a listener. <p> 76 * Has <b>OK</b> status if no runtime exceptions occurred. 77 */ _addSpinListener()78 public void _addSpinListener() { 79 oObj.addSpinListener(listener) ; 80 81 tRes.tested("addSpinListener()", true) ; 82 } 83 84 /** 85 * Calls the method. <p> 86 * Has <b>OK</b> status if the appropriate listener method 87 * was called. <p> 88 * The following method tests are to be completed successfully before : 89 * <ul> 90 * <li> <code> addSpinListener </code> </li> 91 * </ul> 92 */ _up()93 public void _up() { 94 requiredMethod("addSpinListener()") ; 95 96 oObj.up() ; 97 waitForEventIdle(); 98 99 tRes.tested("up()", listener.upFl) ; 100 } 101 102 /** 103 * Calls the method. <p> 104 * Has <b>OK</b> status if the appropriate listener method 105 * was called. <p> 106 * The following method tests are to be completed successfully before : 107 * <ul> 108 * <li> <code> addSpinListener </code> </li> 109 * </ul> 110 */ _down()111 public void _down() throws Exception { 112 requiredMethod("addSpinListener()") ; 113 114 oObj.down() ; 115 waitForEventIdle(); 116 117 tRes.tested("down()", listener.downFl) ; 118 } 119 120 /** 121 * Calls the method. <p> 122 * Has <b>OK</b> status if the appropriate listener method 123 * was called.<p> 124 * The following method tests are to be completed successfully before : 125 * <ul> 126 * <li> <code> addSpinListener </code> </li> 127 * </ul> 128 */ _first()129 public void _first() throws Exception { 130 requiredMethod("addSpinListener()") ; 131 132 oObj.first(); 133 waitForEventIdle(); 134 135 tRes.tested("first()", listener.firstFl) ; 136 } 137 138 /** 139 * Calls the method. <p> 140 * Has <b>OK</b> status if the appropriate listener method 141 * was called.<p> 142 * The following method tests are to be completed successfully before : 143 * <ul> 144 * <li> <code> addSpinListener </code> </li> 145 * </ul> 146 */ _last()147 public void _last() throws Exception { 148 requiredMethod("addSpinListener()") ; 149 150 oObj.last(); 151 waitForEventIdle(); 152 153 tRes.tested("last()", listener.lastFl) ; 154 } 155 156 /** 157 * Removes the listener, then calls <code>up</code> method and 158 * checks if the listener wasn't called. <p> 159 * Has <b>OK</b> status if listener wasn't called. <p> 160 * The following method tests are to be completed successfully before : 161 * <ul> 162 * <li> <code> addSpinListener </code> </li> 163 * <li> <code> up </code> </li> 164 * <li> <code> down </code> </li> 165 * <li> <code> first </code> </li> 166 * <li> <code> last </code> </li> 167 * </ul> 168 */ _removeSpinListener()169 public void _removeSpinListener() { 170 requiredMethod("addSpinListener()") ; 171 executeMethod("up()") ; 172 executeMethod("down()") ; 173 executeMethod("first()") ; 174 executeMethod("last()") ; 175 176 listener.upFl = false ; 177 178 oObj.removeSpinListener(listener) ; 179 180 oObj.up() ; 181 182 tRes.tested("removeSpinListener()", !listener.upFl) ; 183 } 184 185 /** 186 * Enables then disables repeating. <p> 187 * Has <b>OK</b> status if no runtime exceptions occurred. 188 */ _enableRepeat()189 public void _enableRepeat() { 190 oObj.enableRepeat(true) ; 191 oObj.enableRepeat(false) ; 192 193 tRes.tested("enableRepeat()", true) ; 194 } 195 } 196