merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / util / _XFlushable.java
bloba138931b9270c457871b0720b11814ed884ddde4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XFlushable.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.util;
33 import lib.MultiMethodTest;
35 import com.sun.star.util.XFlushListener;
36 import com.sun.star.util.XFlushable;
38 /**
39 * Testing <code>com.sun.star.util.XFlushable</code>
40 * interface methods :
41 * <ul>
42 * <li><code> flush()</code></li>
43 * <li><code> addFlushListener()</code></li>
44 * <li><code> removeFlushListener()</code></li>
45 * </ul> <p>
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 ;
54 /**
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) {
61 called = true ;
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() ;
71 /**
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()") ;
83 oObj.flush() ;
85 tRes.tested("flush()", true) ;
86 tRes.tested("addFlushListener()", listener2.wasFlushed()) ;
87 tRes.tested("removeFlushListener()", !listener1.wasFlushed()) ;
90 /**
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>
93 * method call.
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