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