1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import com
.sun
.star
.util
.XRefreshListener
;
33 import com
.sun
.star
.util
.XRefreshable
;
36 * Testing <code>com.sun.star.util.XRefreshable</code>
39 * <li><code> refresh()</code></li>
40 * <li><code> addRefreshListener()</code></li>
41 * <li><code> removeRefreshListener()</code></li>
43 * Test is <b> NOT </b> multithread compilant. <p>
44 * @see com.sun.star.util.XRefreshable
46 public class _XRefreshable
extends MultiMethodTest
{
48 public XRefreshable oObj
= null;
50 final boolean listenerCalled
[] = new boolean[1];
54 * <code>XRefreshListener</code> implementation which
55 * sets a flag when <code>refreshed</code> method is
58 public class MyRefreshListener
implements XRefreshListener
{
59 public void refreshed (com
.sun
.star
.lang
.EventObject e
) {
60 listenerCalled
[0] = true;
63 public void disposing (com
.sun
.star
.lang
.EventObject obj
) {}
66 XRefreshListener listener
= new MyRefreshListener();
69 * Just adds a listener. <p>
70 * Always has <b>OK</b> status.
72 public void _addRefreshListener() {
74 oObj
.addRefreshListener(listener
) ;
75 tRes
.tested("addRefreshListener()", true);
79 * Calls the method and checks if the listener was called. <p>
80 * Has <b>OK</b> status if listener's flag is set after call.
81 * The following method tests are to be completed successfully before :
83 * <li> <code> addRefreshListener </code> : to have a listener added.</li>
86 public void _refresh() {
88 requiredMethod("addRefreshListener()");
92 tRes
.tested("refresh()", listenerCalled
[0]);
93 if (!listenerCalled
[0])
94 log
.println("RefreshListener wasn't called after refresh");
99 * Removes the listener added before and calls <code>refresh</code>
100 * method. Listener must not be called. <p>
101 * Has <b>OK</b> status if listener's flag isn't changed.
103 * <li> <code> refresh </code> : listener added must be already
107 public void _removeRefreshListener() {
108 requiredMethod("refresh()");
109 listenerCalled
[0] = false;
111 oObj
.removeRefreshListener(listener
) ;
114 tRes
.tested("removeRefreshListener()", !listenerCalled
[0]);
115 if (listenerCalled
[0])
116 log
.println("RefreshListener was called after removing");
118 } // finish class _XRefreshable