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 
29 import com.sun.star.awt.XCheckBox;
30 
31 /**
32 * Testing <code>com.sun.star.awt.XCheckBox</code>
33 * interface methods :
34 * <ul>
35 *  <li><code> addItemListener()</code></li>
36 *  <li><code> removeItemListener()</code></li>
37 *  <li><code> getState()</code></li>
38 *  <li><code> setState()</code></li>
39 *  <li><code> setLabel()</code></li>
40 *  <li><code> enableTriState()</code></li>
41 * </ul> <p>
42 *
43 * @see com.sun.star.awt.XCheckBox
44 */
45 public class _XCheckBox extends MultiMethodTest {
46 
47     public XCheckBox oObj = null;
48 
49     /**
50     * Listener implementation which sets flags on appropriate method calls
51     */
52     protected class TestItemListener implements com.sun.star.awt.XItemListener {
53         public boolean disposingCalled = false ;
54         public boolean itemStateChangedCalled = false ;
55 
disposing(com.sun.star.lang.EventObject e)56         public void disposing(com.sun.star.lang.EventObject e) {
57             disposingCalled = true ;
58         }
59 
itemStateChanged(com.sun.star.awt.ItemEvent e)60         public void itemStateChanged(com.sun.star.awt.ItemEvent e) {
61             itemStateChangedCalled = true ;
62         }
63 
64     }
65     TestItemListener listener = new TestItemListener() ;
66     short state = -1 ;
67 
68     /**
69     * !!! Can be checked only interactively !!!
70     */
_addItemListener()71     public void _addItemListener() {
72 
73         boolean result = true ;
74         oObj.addItemListener(listener) ;
75         tRes.tested("addItemListener()", result) ;
76     }
77 
78     /**
79     * !!! Can be checked only interactively !!!
80     */
_removeItemListener()81     public void _removeItemListener() {
82 
83         boolean result = true ;
84         oObj.removeItemListener(listener) ;
85 
86         tRes.tested("removeItemListener()", result) ;
87     }
88 
89     /**
90     * Just retrieves current state and stores it. <p>
91     * Has <b>OK</b> status if no runtime exceptions occurs.
92     */
_getState()93     public void _getState() {
94 
95         boolean result = true ;
96         state = oObj.getState() ;
97 
98         tRes.tested("getState()", result) ;
99     }
100 
101     /**
102     * Sets a new value and then checks get value. <p>
103     * Has <b>OK</b> status if set and get values are equal. <p>
104     * The following method tests are to be completed successfully before :
105     * <ul>
106     *  <li> <code> getState </code>  </li>
107     * </ul>
108     */
_setState()109     public void _setState() {
110         requiredMethod("getState()") ;
111 
112         boolean result = true ;
113         short newState = state == 0 ? (short)1 : (short)0 ;
114         oObj.setState(newState) ;
115         result = newState == oObj.getState() ;
116 
117         tRes.tested("setState()", result) ;
118     }
119 
120     /**
121     * Just sets some text for label. <p>
122     * Has <b>OK</b> status if no runtime exceptions occurs.
123     */
_setLabel()124     public void _setLabel() {
125 
126         boolean result = true ;
127         oObj.setLabel("XCheckBox test") ;
128 
129         tRes.tested("setLabel()", result) ;
130     }
131 
132     /**
133     * Just enables tristate. <p>
134     * Has <b>OK</b> status if no runtime exceptions occurs.
135     */
_enableTriState()136     public void _enableTriState() {
137 
138         boolean result = true ;
139         oObj.enableTriState(true) ;
140 
141         tRes.tested("enableTriState()", result) ;
142     }
143 
144 }
145 
146 
147