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.ui;
25 
26 import com.sun.star.ui.XUIConfiguration;
27 import com.sun.star.ui.XUIConfigurationListener;
28 import lib.MultiMethodTest;
29 
30 /**
31 * Testing <code>com.sun.star.ui.XUIConfiguration</code>
32 * interface methods :
33 * <ul>
34 *  <li><code> addConfigurationListener()</code></li>
35 *  <li><code> removeConfigurationListener()</code></li>
36 * </ul> <p>
37 * Test is <b> NOT </b> multithread compilant. <p>
38 * After test completion object environment has to be recreated.
39 * @see com.sun.star.ui.XUIConfiguration
40 */
41 
42 public class _XUIConfiguration extends MultiMethodTest {
43 
44     public XUIConfiguration oObj;
45     XUIConfigurationListenerImpl xListener = null;
46 
47     /**
48      * Interface for the Listener of the object relation
49      * <CODE>XUIConfiguration.XUIConfigurationListenerImpl</CODE>
50      * @see com.sun.star.ui.XUIConfigurationListener
51      */
52     public static interface XUIConfigurationListenerImpl
53                                     extends XUIConfigurationListener {
54         public void reset();
55         public void fireEvent();
56         public boolean actionWasTriggered();
57     }
58 
59 
60     /**
61      * try to get a listener out of the object relation
62      * <CODE>XUIConfiguration.XUIConfigurationListenerImpl</CODE>
63      */
64     public void before() {
65         xListener = (XUIConfigurationListenerImpl)tEnv.getObjRelation(
66                         "XUIConfiguration.XUIConfigurationListenerImpl");
67         XUIConfigurationListener l;
68     }
69 
70     /**
71      * adds a listener an fire an event
72      * Has <B>OK</B> status if listener was called
73      */
74     public void _addConfigurationListener() {
75         oObj.addConfigurationListener(xListener);
76         xListener.fireEvent();
77         tRes.tested("addConfigurationListener()", xListener.actionWasTriggered());
78     }
79 
80     /**
81      * removes the listener and calls an event.
82      * Has <B>OK</B> status if listener is not called.
83      */
84     public void _removeConfigurationListener() {
85         requiredMethod("addConfigurationListener()");
86         oObj.removeConfigurationListener(xListener);
87         xListener.reset();
88         xListener.fireEvent();
89         tRes.tested("removeConfigurationListener()", !xListener.actionWasTriggered());
90     }
91 
92     /**
93      * Dispose because the UIConfigurationManager has to be recreated
94      */
95     public void after() {
96         disposeEnvironment();
97     }
98 }
99