Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / util / _XFlushable.java
blob83a325b213b3123adebe2bf126bae63c79b3209b
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 ************************************************************************/
28 package ifc.util;
30 import lib.MultiMethodTest;
32 import com.sun.star.util.XFlushListener;
33 import com.sun.star.util.XFlushable;
35 /**
36 * Testing <code>com.sun.star.util.XFlushable</code>
37 * interface methods :
38 * <ul>
39 * <li><code> flush()</code></li>
40 * <li><code> addFlushListener()</code></li>
41 * <li><code> removeFlushListener()</code></li>
42 * </ul> <p>
43 * Test is <b> NOT </b> multithread compilant. <p>
44 * @see com.sun.star.util.XFlushable
46 public class _XFlushable extends MultiMethodTest {
48 // oObj filled by MultiMethodTest
49 public XFlushable oObj = null ;
51 /**
52 * Simple <code>XFlushListener</code> implementation which
53 * just registers if any calls to its methods were made.
55 private class MyFlushListener implements XFlushListener{
56 boolean called = false ;
57 public void flushed(com.sun.star.lang.EventObject e) {
58 called = true ;
60 public void disposing(com.sun.star.lang.EventObject e) {}
61 public void reset() { called = false; }
62 public boolean wasFlushed() { return called; }
65 private MyFlushListener listener1 = new MyFlushListener(),
66 listener2 = new MyFlushListener() ;
68 /**
69 * Test call method <code>flush</code> and checks if added listener
70 * was called and removed one wasn't. <p>
71 * Has OK status if no exception has occurred. <p>
72 * Methods to be executed before :
73 * {@link #_addFlushListener},
74 * {@link #_removeFlushListener}
76 public void _flush() {
77 executeMethod("addFlushListener()") ;
78 executeMethod("removeFlushListener()") ;
80 oObj.flush() ;
82 tRes.tested("flush()", true) ;
83 tRes.tested("addFlushListener()", listener2.wasFlushed()) ;
84 tRes.tested("removeFlushListener()", !listener1.wasFlushed()) ;
87 /**
88 * Test adds two listeners, one of which will be removed then.<p>
89 * Has OK status if the listener was called on <code>flush()</code>
90 * method call.
92 public void _addFlushListener() {
93 oObj.addFlushListener(listener1) ;
94 oObj.addFlushListener(listener2) ;
97 /**
98 * Test removes one of two listeners added before. <p>
99 * Has OK status if the listener removed wasn't called on
100 * <code>flush()</code> method call.
101 * Methods to be executed before :
102 * {@link #_addFlushListener},
104 public void _removeFlushListener() {
105 executeMethod("addFlushListener()") ;
107 oObj.removeFlushListener(listener1) ;
110 } // finish class _XFlushable