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 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.util
.XRefreshListener
;
24 import com
.sun
.star
.util
.XRefreshable
;
27 * Testing <code>com.sun.star.util.XRefreshable</code>
30 * <li><code> refresh()</code></li>
31 * <li><code> addRefreshListener()</code></li>
32 * <li><code> removeRefreshListener()</code></li>
34 * Test is <b> NOT </b> multithread compliant. <p>
35 * @see com.sun.star.util.XRefreshable
37 public class _XRefreshable
extends MultiMethodTest
{
39 public XRefreshable oObj
= null;
41 final boolean listenerCalled
[] = new boolean[1];
45 * <code>XRefreshListener</code> implementation which
46 * sets a flag when <code>refreshed</code> method is
49 public class MyRefreshListener
implements XRefreshListener
{
50 public void refreshed (com
.sun
.star
.lang
.EventObject e
) {
51 listenerCalled
[0] = true;
54 public void disposing (com
.sun
.star
.lang
.EventObject obj
) {}
57 XRefreshListener listener
= new MyRefreshListener();
60 * Just adds a listener. <p>
61 * Always has <b>OK</b> status.
63 public void _addRefreshListener() {
65 oObj
.addRefreshListener(listener
) ;
66 tRes
.tested("addRefreshListener()", true);
70 * Calls the method and checks if the listener was called. <p>
71 * Has <b>OK</b> status if listener's flag is set after call.
72 * The following method tests are to be completed successfully before :
74 * <li> <code> addRefreshListener </code> : to have a listener added.</li>
77 public void _refresh() {
79 requiredMethod("addRefreshListener()");
83 tRes
.tested("refresh()", listenerCalled
[0]);
84 if (!listenerCalled
[0])
85 log
.println("RefreshListener wasn't called after refresh");
90 * Removes the listener added before and calls <code>refresh</code>
91 * method. Listener must not be called. <p>
92 * Has <b>OK</b> status if listener's flag isn't changed.
94 * <li> <code> refresh </code> : listener added must be already
98 public void _removeRefreshListener() {
99 requiredMethod("refresh()");
100 listenerCalled
[0] = false;
102 oObj
.removeRefreshListener(listener
) ;
105 tRes
.tested("removeRefreshListener()", !listenerCalled
[0]);
106 if (listenerCalled
[0])
107 log
.println("RefreshListener was called after removing");
109 } // finish class _XRefreshable