Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / form / _XLoadable.java
blobda8f57bb140e9aa971bbc09de5ef27217c0eefb2
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;
22 import lib.MultiMethodTest;
24 import com.sun.star.form.XLoadable;
26 /**
27 * Testing <code>com.sun.star.form.XLoadable</code>
28 * interface methods :
29 * <ul>
30 * <li><code> load()</code></li>
31 * <li><code> unload()</code></li>
32 * <li><code> reload()</code></li>
33 * <li><code> isLoaded()</code></li>
34 * <li><code> addLoadListener()</code></li>
35 * <li><code> removeLoadListener()</code></li>
36 * </ul> <p>
37 * Test is <b> NOT </b> multithread compliant. <p>
38 * @see com.sun.star.form.XLoadable
40 public class _XLoadable extends MultiMethodTest {
42 public XLoadable oObj = null;
44 /**
45 * Listener implementation which sets flags on appropriate method calls
47 protected class TestLoadListener implements com.sun.star.form.XLoadListener {
48 public boolean disposingCalled = false ;
49 public boolean loadedCalled = false ;
50 public boolean reloadedCalled = false ;
51 public boolean reloadingCalled = false ;
52 public boolean unloadedCalled = false ;
53 public boolean unloadingCalled = false ;
54 private final java.io.PrintWriter log;
56 public TestLoadListener(java.io.PrintWriter log) {
57 this.log = log ;
60 public void disposing(com.sun.star.lang.EventObject e) {
61 disposingCalled = true ;
62 log.println(" disposing was called.") ;
65 public void loaded(com.sun.star.lang.EventObject e) {
66 loadedCalled = true ;
67 log.println(" loaded was called.") ;
70 public void reloaded(com.sun.star.lang.EventObject e) {
71 reloadedCalled = true ;
72 log.println(" reloaded was called.") ;
75 public void reloading(com.sun.star.lang.EventObject e) {
76 reloadingCalled = true ;
77 log.println(" reloading was called.") ;
80 public void unloaded(com.sun.star.lang.EventObject e) {
81 unloadedCalled = true ;
82 log.println(" unloaded was called.") ;
85 public void unloading(com.sun.star.lang.EventObject e) {
86 unloadingCalled = true ;
87 log.println(" unloading was called.") ;
91 TestLoadListener loadListener = null ;
93 /**
94 * Creates new listener.
96 @Override
97 public void before() {
98 loadListener = new TestLoadListener(log) ;
102 * Loads the form. <p>
103 * Has <b> OK </b> status if <code>isLoaded()</code> returns
104 * <code>true</code> and listener method <code>loaded()</code>
105 * is called.
106 * The following method tests are to be completed successfully before :
107 * <ul>
108 * <li> <code> isLoaded() </code> : to be sure form is not loaded </li>
109 * <li> <code> addLoadListener() </code> : to check if this listener method
110 * is called. </li>
111 * </ul>
113 public void _load() {
114 requiredMethod("isLoaded()") ;
115 requiredMethod("addLoadListener()") ;
117 boolean result = true ;
118 oObj.load() ;
120 util.utils.pause(100);
121 result = oObj.isLoaded() && loadListener.loadedCalled ;
123 tRes.tested("load()", result) ;
127 * Unloads the form. <p>
128 * Has <b> OK </b> status if <code>isLoaded()</code> returns
129 * <code>false</code> and listener method <code>unloaded()</code>
130 * is called.
131 * The following method tests are to be completed successfully before :
132 * <ul>
133 * <li> <code> reload() </code> : to be sure the form is loaded </li>
134 * <li> <code> addLoadListener() </code> : to check if this listener method
135 * is called. </li>
136 * </ul>
138 public void _unload() {
139 requiredMethod("reload()") ;
140 requiredMethod("addLoadListener()") ;
142 boolean result = true ;
143 oObj.unload() ;
145 util.utils.pause(100);
146 result = !oObj.isLoaded() && loadListener.unloadedCalled ;
148 tRes.tested("unload()", result) ;
152 * Reloads the form. <p>
153 * Has <b> OK </b> status if <code>isLoaded()</code> returns
154 * <code>true</code> and listener method <code>reloaded()</code>
155 * is called.
156 * The following method tests are to be completed successfully before :
157 * <ul>
158 * <li> <code> load() </code> : to be sure form is loaded </li>
159 * <li> <code> addLoadListener() </code> : to check if this listener method
160 * is called. </li>
161 * </ul>
163 public void _reload() {
164 requiredMethod("load()") ;
165 requiredMethod("addLoadListener()") ;
167 boolean result = true ;
168 oObj.reload() ;
170 util.utils.pause(100);
171 result = oObj.isLoaded() && loadListener.reloadedCalled;
173 tRes.tested("reload()", result) ;
177 * Checks if the component is already loaded. If yes it unloads
178 * it <p>
179 * Has <b> OK </b> status if finally <code>isLoaded()</code> method
180 * returns <code>false</code>.
182 public void _isLoaded() {
184 boolean isLoaded = oObj.isLoaded() ;
185 if (isLoaded) oObj.unload();
186 isLoaded = oObj.isLoaded() ;
188 tRes.tested("isLoaded()", !isLoaded) ;
192 * Adds a listener. If its methods are called or not is checked
193 * in other object methods. <p>
194 * Has <b> OK </b> status if no runtime exceptions occurred.
196 public void _addLoadListener() {
198 boolean result = true ;
199 oObj.addLoadListener(loadListener) ;
201 tRes.tested("addLoadListener()", result) ;
205 * Removes the listener added before. <p>
206 * Has <b> OK </b> status if after <code>load()</code> call no
207 * listener methods were called. <p>
208 * The following method tests are to be completed successfully before :
209 * <ul>
210 * <li> <code> unload() </code> : to make this test run finally.</li>
211 * </ul>
213 public void _removeLoadListener() {
214 requiredMethod("unload()") ;
216 boolean result = true ;
217 oObj.removeLoadListener(loadListener) ;
218 loadListener.loadedCalled = false ;
219 oObj.load();
221 result = ! loadListener.loadedCalled ;
223 tRes.tested("removeLoadListener()", result) ;
226 @Override
227 protected void after() {
228 disposeEnvironment();