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 
22 import lib.MultiMethodTest;
23 import lib.Status;
24 
25 import com.sun.star.awt.XRadioButton;
26 
27 /**
28 * Testing <code>com.sun.star.awt.XRadioButton</code>
29 * interface methods :
30 * <ul>
31 *  <li><code> addItemListener()</code></li>
32 *  <li><code> removeItemListener()</code></li>
33 *  <li><code> getState()</code></li>
34 *  <li><code> setState()</code></li>
35 *  <li><code> setLabel()</code></li>
36 * </ul> <p>
37 * Test is <b> NOT </b> multithread compliant. <p>
38 * @see com.sun.star.awt.XRadioButton
39 */
40 public class _XRadioButton extends MultiMethodTest {
41 
42     public XRadioButton oObj = null;
43     private boolean state = false ;
44 
45     /**
46     * Listener implementation which sets flags on appropriate method calls
47     */
48     protected static class TestItemListener implements com.sun.star.awt.XItemListener {
49         private final java.io.PrintWriter log;
50 
TestItemListener(java.io.PrintWriter log)51         public TestItemListener(java.io.PrintWriter log) {
52             this.log = log ;
53         }
54 
disposing(com.sun.star.lang.EventObject e)55         public void disposing(com.sun.star.lang.EventObject e) {
56             log.println(" disposing was called.") ;
57         }
58 
itemStateChanged(com.sun.star.awt.ItemEvent e)59         public void itemStateChanged(com.sun.star.awt.ItemEvent e) {
60             log.println(" itemStateChanged was called.") ;
61         }
62 
63     }
64 
65     TestItemListener itemListener = null ;
66 
67     /**
68     * !!! Can be checked only interactively !!!
69     */
_addItemListener()70     public void _addItemListener() {
71 
72         itemListener = new TestItemListener(log) ;
73 
74         oObj.addItemListener(itemListener) ;
75 
76         tRes.tested("addItemListener()", Status.skipped(true)) ;
77     }
78 
79     /**
80     * !!! Can be checked only interactively !!!
81     */
_removeItemListener()82     public void _removeItemListener() {
83         requiredMethod("addItemListener()") ;
84 
85         oObj.removeItemListener(itemListener) ;
86 
87         tRes.tested("removeItemListener()", Status.skipped(true)) ;
88     }
89 
90     /**
91     * Gets state and stores it. <p>
92     * Has <b> OK </b> status if no runtime exceptions occurred
93     */
_getState()94     public void _getState() {
95 
96         boolean result = true ;
97         state = oObj.getState() ;
98 
99         tRes.tested("getState()", result) ;
100     }
101 
102     /**
103     * Sets a new state and the gets it for checking. <p>
104     * Has <b> OK </b> status if set and get states are equal. <p>
105     * The following method tests are to be completed successfully before :
106     * <ul>
107     *  <li> <code> getState </code>  </li>
108     * </ul>
109     */
_setState()110     public void _setState() {
111         requiredMethod("getState()") ;
112 
113         boolean result = true ;
114         oObj.setState(!state) ;
115 
116         waitForEventIdle();
117 
118         result = oObj.getState() == !state ;
119 
120         tRes.tested("setState()", result) ;
121     }
122 
123     /**
124     * Just sets a new label. <p>
125     * Has <b> OK </b> status if no runtime exceptions occurred
126     */
_setLabel()127     public void _setLabel() {
128 
129         boolean result = true ;
130         oObj.setLabel("XRadioButton") ;
131 
132         tRes.tested("setLabel()", result) ;
133     }
134 }
135 
136 
137