1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XFlushable.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.util
.XFlushListener
;
36 import com
.sun
.star
.util
.XFlushable
;
39 * Testing <code>com.sun.star.util.XFlushable</code>
42 * <li><code> flush()</code></li>
43 * <li><code> addFlushListener()</code></li>
44 * <li><code> removeFlushListener()</code></li>
46 * Test is <b> NOT </b> multithread compilant. <p>
47 * @see com.sun.star.util.XFlushable
49 public class _XFlushable
extends MultiMethodTest
{
51 // oObj filled by MultiMethodTest
52 public XFlushable oObj
= null ;
55 * Simple <code>XFlushListener</code> implementation which
56 * just registers if any calls to its methods were made.
58 private class MyFlushListener
implements XFlushListener
{
59 boolean called
= false ;
60 public void flushed(com
.sun
.star
.lang
.EventObject e
) {
63 public void disposing(com
.sun
.star
.lang
.EventObject e
) {}
64 public void reset() { called
= false; }
65 public boolean wasFlushed() { return called
; }
68 private MyFlushListener listener1
= new MyFlushListener(),
69 listener2
= new MyFlushListener() ;
72 * Test call method <code>flush</code> and checks if added listener
73 * was called and removed one wasn't. <p>
74 * Has OK status if no exception has occured. <p>
75 * Methods to be executed before :
76 * {@link #_addFlushListener},
77 * {@link #_removeFlushListener}
79 public void _flush() {
80 executeMethod("addFlushListener()") ;
81 executeMethod("removeFlushListener()") ;
85 tRes
.tested("flush()", true) ;
86 tRes
.tested("addFlushListener()", listener2
.wasFlushed()) ;
87 tRes
.tested("removeFlushListener()", !listener1
.wasFlushed()) ;
91 * Test adds two listeners, one of which will be removed then.<p>
92 * Has OK status if the listener was called on <code>flush()</code>
95 public void _addFlushListener() {
96 oObj
.addFlushListener(listener1
) ;
97 oObj
.addFlushListener(listener2
) ;
101 * Test removes one of two listeners added before. <p>
102 * Has OK status if the listener removed wasn't called on
103 * <code>flush()</code> method call.
104 * Methods to be executed before :
105 * {@link #_addFlushListener},
107 public void _removeFlushListener() {
108 executeMethod("addFlushListener()") ;
110 oObj
.removeFlushListener(listener1
) ;
113 } // finish class _XFlushable