1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.awt;
25 
26 
27 import lib.MultiMethodTest;
28 import lib.Status;
29 
30 import com.sun.star.awt.XRadioButton;
31 
32 /**
33 * Testing <code>com.sun.star.awt.XRadioButton</code>
34 * interface methods :
35 * <ul>
36 *  <li><code> addItemListener()</code></li>
37 *  <li><code> removeItemListener()</code></li>
38 *  <li><code> getState()</code></li>
39 *  <li><code> setState()</code></li>
40 *  <li><code> setLabel()</code></li>
41 * </ul> <p>
42 * Test is <b> NOT </b> multithread compilant. <p>
43 * @see com.sun.star.awt.XRadioButton
44 */
45 public class _XRadioButton extends MultiMethodTest {
46 
47     public XRadioButton oObj = null;
48     private boolean state = false ;
49 
50     /**
51     * Listener implementation which sets flags on appropriate method calls
52     */
53     protected class TestItemListener implements com.sun.star.awt.XItemListener {
54         public boolean disposingCalled = false ;
55         public boolean itemStateChangedCalled = false ;
56         private java.io.PrintWriter log = null ;
57 
TestItemListener(java.io.PrintWriter log)58         public TestItemListener(java.io.PrintWriter log) {
59             this.log = log ;
60         }
61 
disposing(com.sun.star.lang.EventObject e)62         public void disposing(com.sun.star.lang.EventObject e) {
63             disposingCalled = true ;
64             log.println(" disposing was called.") ;
65         }
66 
itemStateChanged(com.sun.star.awt.ItemEvent e)67         public void itemStateChanged(com.sun.star.awt.ItemEvent e) {
68             itemStateChangedCalled = true ;
69             log.println(" itemStateChanged was called.") ;
70         }
71 
72     }
73 
74     TestItemListener itemListener = null ;
75 
76     /**
77     * !!! Can be checked only interactively !!!
78     */
_addItemListener()79     public void _addItemListener() {
80 
81         itemListener = new TestItemListener(log) ;
82 
83         oObj.addItemListener(itemListener) ;
84 
85         tRes.tested("addItemListener()", Status.skipped(true)) ;
86     }
87 
88     /**
89     * !!! Can be checked only interactively !!!
90     */
_removeItemListener()91     public void _removeItemListener() {
92         requiredMethod("addItemListener()") ;
93 
94         oObj.removeItemListener(itemListener) ;
95 
96         tRes.tested("removeItemListener()", Status.skipped(true)) ;
97     }
98 
99     /**
100     * Gets state and stores it. <p>
101     * Has <b> OK </b> status if no runtime exceptions occured
102     */
_getState()103     public void _getState() {
104 
105         boolean result = true ;
106         state = oObj.getState() ;
107 
108         tRes.tested("getState()", result) ;
109     }
110 
111     /**
112     * Sets a new state and the gets it for checking. <p>
113     * Has <b> OK </b> status if set and get states are equal. <p>
114     * The following method tests are to be completed successfully before :
115     * <ul>
116     *  <li> <code> getState </code>  </li>
117     * </ul>
118     */
_setState()119     public void _setState() {
120         requiredMethod("getState()") ;
121 
122         boolean result = true ;
123         oObj.setState(!state) ;
124 
125         try {
126             Thread.sleep(200) ;
127         } catch (InterruptedException e) {}
128 
129         result = oObj.getState() == !state ;
130 
131         tRes.tested("setState()", result) ;
132     }
133 
134     /**
135     * Just sets a new label. <p>
136     * Has <b> OK </b> status if no runtime exceptions occured
137     */
_setLabel()138     public void _setLabel() {
139 
140         boolean result = true ;
141         oObj.setLabel("XRadioButton") ;
142 
143         tRes.tested("setLabel()", result) ;
144     }
145 }
146 
147 
148