1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XRadioButton.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 import lib
.MultiMethodTest
;
37 import com
.sun
.star
.awt
.XRadioButton
;
40 * Testing <code>com.sun.star.awt.XRadioButton</code>
43 * <li><code> addItemListener()</code></li>
44 * <li><code> removeItemListener()</code></li>
45 * <li><code> getState()</code></li>
46 * <li><code> setState()</code></li>
47 * <li><code> setLabel()</code></li>
49 * Test is <b> NOT </b> multithread compilant. <p>
50 * @see com.sun.star.awt.XRadioButton
52 public class _XRadioButton
extends MultiMethodTest
{
54 public XRadioButton oObj
= null;
55 private boolean state
= false ;
58 * Listener implementation which sets flags on appropriate method calls
60 protected class TestItemListener
implements com
.sun
.star
.awt
.XItemListener
{
61 public boolean disposingCalled
= false ;
62 public boolean itemStateChangedCalled
= false ;
63 private java
.io
.PrintWriter log
= null ;
65 public TestItemListener(java
.io
.PrintWriter log
) {
69 public void disposing(com
.sun
.star
.lang
.EventObject e
) {
70 disposingCalled
= true ;
71 log
.println(" disposing was called.") ;
74 public void itemStateChanged(com
.sun
.star
.awt
.ItemEvent e
) {
75 itemStateChangedCalled
= true ;
76 log
.println(" itemStateChanged was called.") ;
81 TestItemListener itemListener
= null ;
84 * !!! Can be checked only interactively !!!
86 public void _addItemListener() {
88 itemListener
= new TestItemListener(log
) ;
90 oObj
.addItemListener(itemListener
) ;
92 tRes
.tested("addItemListener()", Status
.skipped(true)) ;
96 * !!! Can be checked only interactively !!!
98 public void _removeItemListener() {
99 requiredMethod("addItemListener()") ;
101 oObj
.removeItemListener(itemListener
) ;
103 tRes
.tested("removeItemListener()", Status
.skipped(true)) ;
107 * Gets state and stores it. <p>
108 * Has <b> OK </b> status if no runtime exceptions occured
110 public void _getState() {
112 boolean result
= true ;
113 state
= oObj
.getState() ;
115 tRes
.tested("getState()", result
) ;
119 * Sets a new state and the gets it for checking. <p>
120 * Has <b> OK </b> status if set and get states are equal. <p>
121 * The following method tests are to be completed successfully before :
123 * <li> <code> getState </code> </li>
126 public void _setState() {
127 requiredMethod("getState()") ;
129 boolean result
= true ;
130 oObj
.setState(!state
) ;
134 } catch (InterruptedException e
) {}
136 result
= oObj
.getState() == !state
;
138 tRes
.tested("setState()", result
) ;
142 * Just sets a new label. <p>
143 * Has <b> OK </b> status if no runtime exceptions occured
145 public void _setLabel() {
147 boolean result
= true ;
148 oObj
.setLabel("XRadioButton") ;
150 tRes
.tested("setLabel()", result
) ;