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.form;
25 
26 import lib.MultiMethodTest;
27 import lib.Status;
28 import lib.StatusException;
29 
30 import com.sun.star.form.XApproveActionBroadcaster;
31 import com.sun.star.form.XApproveActionListener;
32 import com.sun.star.lang.EventObject;
33 
34 /**
35 * Testing <code>com.sun.star.form.XApproveActionBroadcaster</code>
36 * interface methods:
37 * <ul>
38 *  <li><code> addApproveActionListener() </code></li>
39 *  <li><code> removeApproveActionListener() </code></li>
40 * </ul><p>
41 * Test is <b> NOT </b> multithread compilant. <p>
42 * @see com.sun.star.form.XApproveActionBroadcaster
43 */
44 public class _XApproveActionBroadcaster extends MultiMethodTest {
45     public XApproveActionBroadcaster oObj = null;
46 
47     /**
48     * Class we need to test methods.
49     */
50     protected class TestListener implements XApproveActionListener {
51         public boolean approve = false ;
52 
init()53         public void init() {
54             approve = false ;
55         }
disposing(EventObject ev)56         public void disposing(EventObject ev) {}
approveAction(EventObject ev)57         public boolean approveAction(EventObject ev) {
58             log.println("XApproveActionListener: ActionListener was called");
59             return approve ;
60         }
61 
62     }
63 
64     private TestListener listener = new TestListener();
65 
66     /**
67     * Test calls the method. <p>
68     * Has <b> OK </b> status if the method successfully returns
69     * and no exceptions were thrown.
70     */
_addApproveActionListener()71     public void _addApproveActionListener() {
72         oObj.addApproveActionListener(listener) ;
73         tRes.tested("addApproveActionListener()", true);
74     }
75 
76     /**
77     * Test calls the method. <p>
78     * Has <b> OK </b> status if the method successfully returns
79     * and no exceptions were thrown. <p>
80     * The following method tests are to be completed successfully before :
81     * <ul>
82     *  <li> <code> addApproveActionListener() </code> : adds listener to an
83     * object </li>
84     * </ul>
85     */
_removeApproveActionListener()86     public void _removeApproveActionListener() {
87         requiredMethod("addApproveActionListener()");
88         listener.init() ;
89         listener.approve = true ;
90         oObj.removeApproveActionListener(listener);
91         tRes.tested("removeApproveActionListener()", true);
92     }
93 
94 
95     /**
96     * Just log output
97     */
after()98     protected void after() {
99         log.println("Skipping all XApproveActionBroadcaster methods, since they"
100                 + " need user interaction");
101         throw new StatusException(Status.skipped(true));
102     }
103 
104 }
105 
106 
107