tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / form / _XReset.java
blobb3afa18df5c9909da85ffb0f10c356150159fbe2
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.form;
21 import lib.MultiMethodTest;
23 import com.sun.star.form.XReset;
24 import com.sun.star.form.XResetListener;
25 import com.sun.star.lang.EventObject;
27 /**
28 * Testing <code>com.sun.star.form.XReset</code>
29 * interface methods :
30 * <ul>
31 * <li><code> reset()</code></li>
32 * <li><code> addResetListener()</code></li>
33 * <li><code> removeResetListener()</code></li>
34 * </ul>
35 * Test is <b> NOT </b> multithread compliant. <p>
36 * @see com.sun.star.form.XReset
38 public class _XReset extends MultiMethodTest {
40 public static XReset oObj = null;
42 /**
43 * Indicates if listeners must approve reset requests or not.
45 protected boolean approve = true;
46 /**
47 * Array of two elements, each of them indicates <code>reset</code>
48 * call of appropriate listener.
50 protected boolean resetted[] = new boolean[2];
51 /**
52 * Array of two elements, each of them indicates
53 * <code>approveReset</code> call of appropriate listener.
55 protected boolean approveReset[] = new boolean[2];
57 /**
58 * The listener which sets flags (in array elements with index 0)
59 * on <code>reset</code> and
60 * <code>approveReset</code> events. It approves reset request
61 * depending on <code>approve</code> field.
63 protected class MyResetListener implements XResetListener {
64 public void disposing ( EventObject oEvent ) {}
65 public boolean approveReset ( EventObject oEvent ) {
66 approveReset[0] = true;
67 //cancel the reset action
68 return approve;
70 public void resetted ( EventObject oEvent ) {
71 resetted[0] = true;
76 /**
77 * The listener which sets flags (in array elements with index 1)
78 * on <code>reset</code> and
79 * <code>approveReset</code> events. It approves reset request
80 * depending on <code>approve</code> field.
82 protected class MyResetListener2 implements XResetListener {
83 public void disposing ( EventObject oEvent ) {}
84 public boolean approveReset ( EventObject oEvent ) {
85 approveReset[1] = true;
86 //don't cancel the reset action
87 return true;
89 public void resetted ( EventObject oEvent ) {
90 resetted[1] = true;
94 /**
95 * Listener which is added in test
97 protected XResetListener listener1 = new MyResetListener();
98 /**
99 * Listener which is added in test
101 protected XResetListener listener2 = new MyResetListener2();
104 * Just adds two reset listeners. <p>
105 * Status for it is set later in <code>reset</code> method test.
107 public void _addResetListener() {
109 log.println("Testing addResetListener ...");
110 oObj.addResetListener( listener2 );
111 oObj.addResetListener( listener1 );
113 } // finished _addResetListener()
116 * First calls <code>reset</code> method without approving
117 * the request, in this case only <code>approveReset</code>
118 * event must be called. Second calls <code>reset</code> with
119 * approving the request. In this case both listener's events
120 * must be called. <p>
121 * Has <b>OK</b> status for <code>reset</code> method if in
122 * the first case only <code>approveReset</code> method was
123 * called. <p>
124 * Has <b>OK</b> status for <code>addResetListener</code> method
125 * if in the second case both listener's methods were called.<p>
126 * The following method tests are to be completed successfully before :
127 * <ul>
128 * <li> <code> addResetListener </code> : to have listeners added.</li>
129 * </ul>
131 public void _reset() {
133 executeMethod("addResetListener()");
134 log.println("Testing reset() ...");
135 approve = false;
136 oObj.reset();
137 waitForEventIdle();
138 tRes.tested("reset()", (approveReset[0] && (! resetted[0])));
139 approve = true;
140 oObj.reset();
141 waitForEventIdle();
142 tRes.tested("addResetListener()", (approveReset[1] && resetted[1]));
144 } // finished _reset
147 * Removes the first listener, clears it's call flags, and
148 * calls <code>reset</code> method.<p>
149 * Has <b> OK </b> status if no methods of the listener removed
150 * were called. <p>
151 * The following method tests are to be completed successfully before :
152 * <ul>
153 * <li> <code> reset </code> : to test this method last. </li>
154 * </ul>
156 public void _removeResetListener() {
157 requiredMethod("reset()");
158 log.println("Testing removeResetListener ...");
159 approveReset[0] = resetted[0] = false;
160 oObj.removeResetListener(listener1);
161 oObj.reset();
162 waitForEventIdle();
163 tRes.tested("removeResetListener()", !approveReset[0] && !resetted[0]);
164 //removing the second listener here may avoid crashing the office
165 } // finished _removeResetListener()
168 } // finished class _XRefresh