1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package ifc.awt; 29 30 31 import lib.MultiMethodTest; 32 import lib.Status; 33 34 import com.sun.star.awt.XRadioButton; 35 36 /** 37 * Testing <code>com.sun.star.awt.XRadioButton</code> 38 * interface methods : 39 * <ul> 40 * <li><code> addItemListener()</code></li> 41 * <li><code> removeItemListener()</code></li> 42 * <li><code> getState()</code></li> 43 * <li><code> setState()</code></li> 44 * <li><code> setLabel()</code></li> 45 * </ul> <p> 46 * Test is <b> NOT </b> multithread compilant. <p> 47 * @see com.sun.star.awt.XRadioButton 48 */ 49 public class _XRadioButton extends MultiMethodTest { 50 51 public XRadioButton oObj = null; 52 private boolean state = false ; 53 54 /** 55 * Listener implementation which sets flags on appropriate method calls 56 */ 57 protected class TestItemListener implements com.sun.star.awt.XItemListener { 58 public boolean disposingCalled = false ; 59 public boolean itemStateChangedCalled = false ; 60 private java.io.PrintWriter log = null ; 61 62 public TestItemListener(java.io.PrintWriter log) { 63 this.log = log ; 64 } 65 66 public void disposing(com.sun.star.lang.EventObject e) { 67 disposingCalled = true ; 68 log.println(" disposing was called.") ; 69 } 70 71 public void itemStateChanged(com.sun.star.awt.ItemEvent e) { 72 itemStateChangedCalled = true ; 73 log.println(" itemStateChanged was called.") ; 74 } 75 76 } 77 78 TestItemListener itemListener = null ; 79 80 /** 81 * !!! Can be checked only interactively !!! 82 */ 83 public void _addItemListener() { 84 85 itemListener = new TestItemListener(log) ; 86 87 oObj.addItemListener(itemListener) ; 88 89 tRes.tested("addItemListener()", Status.skipped(true)) ; 90 } 91 92 /** 93 * !!! Can be checked only interactively !!! 94 */ 95 public void _removeItemListener() { 96 requiredMethod("addItemListener()") ; 97 98 oObj.removeItemListener(itemListener) ; 99 100 tRes.tested("removeItemListener()", Status.skipped(true)) ; 101 } 102 103 /** 104 * Gets state and stores it. <p> 105 * Has <b> OK </b> status if no runtime exceptions occured 106 */ 107 public void _getState() { 108 109 boolean result = true ; 110 state = oObj.getState() ; 111 112 tRes.tested("getState()", result) ; 113 } 114 115 /** 116 * Sets a new state and the gets it for checking. <p> 117 * Has <b> OK </b> status if set and get states are equal. <p> 118 * The following method tests are to be completed successfully before : 119 * <ul> 120 * <li> <code> getState </code> </li> 121 * </ul> 122 */ 123 public void _setState() { 124 requiredMethod("getState()") ; 125 126 boolean result = true ; 127 oObj.setState(!state) ; 128 129 try { 130 Thread.sleep(200) ; 131 } catch (InterruptedException e) {} 132 133 result = oObj.getState() == !state ; 134 135 tRes.tested("setState()", result) ; 136 } 137 138 /** 139 * Just sets a new label. <p> 140 * Has <b> OK </b> status if no runtime exceptions occured 141 */ 142 public void _setLabel() { 143 144 boolean result = true ; 145 oObj.setLabel("XRadioButton") ; 146 147 tRes.tested("setLabel()", result) ; 148 } 149 } 150 151 152