Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / util / _XFlushable.java
blobd96e075e95e522a6238fa2255fbf5c109e6ee26f
1 /*
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 .
19 package ifc.util;
21 import lib.MultiMethodTest;
23 import com.sun.star.util.XFlushListener;
24 import com.sun.star.util.XFlushable;
26 /**
27 * Testing <code>com.sun.star.util.XFlushable</code>
28 * interface methods :
29 * <ul>
30 * <li><code> flush()</code></li>
31 * <li><code> addFlushListener()</code></li>
32 * <li><code> removeFlushListener()</code></li>
33 * </ul> <p>
34 * Test is <b> NOT </b> multithread compliant. <p>
35 * @see com.sun.star.util.XFlushable
37 public class _XFlushable extends MultiMethodTest {
39 // oObj filled by MultiMethodTest
40 public XFlushable oObj = null ;
42 /**
43 * Simple <code>XFlushListener</code> implementation which
44 * just registers if any calls to its methods were made.
46 private class MyFlushListener implements XFlushListener{
47 boolean called = false ;
48 public void flushed(com.sun.star.lang.EventObject e) {
49 called = true ;
51 public void disposing(com.sun.star.lang.EventObject e) {}
52 public boolean wasFlushed() { return called; }
55 private final MyFlushListener listener1 = new MyFlushListener(),
56 listener2 = new MyFlushListener() ;
58 /**
59 * Test call method <code>flush</code> and checks if added listener
60 * was called and removed one wasn't. <p>
61 * Has OK status if no exception has occurred. <p>
62 * Methods to be executed before :
63 * {@link #_addFlushListener},
64 * {@link #_removeFlushListener}
66 public void _flush() {
67 executeMethod("addFlushListener()") ;
68 executeMethod("removeFlushListener()") ;
70 oObj.flush() ;
72 tRes.tested("flush()", true) ;
73 tRes.tested("addFlushListener()", listener2.wasFlushed()) ;
74 tRes.tested("removeFlushListener()", !listener1.wasFlushed()) ;
77 /**
78 * Test adds two listeners, one of which will be removed then.<p>
79 * Has OK status if the listener was called on <code>flush()</code>
80 * method call.
82 public void _addFlushListener() {
83 oObj.addFlushListener(listener1) ;
84 oObj.addFlushListener(listener2) ;
87 /**
88 * Test removes one of two listeners added before. <p>
89 * Has OK status if the listener removed wasn't called on
90 * <code>flush()</code> method call.
91 * Methods to be executed before :
92 * {@link #_addFlushListener},
94 public void _removeFlushListener() {
95 executeMethod("addFlushListener()") ;
97 oObj.removeFlushListener(listener1) ;
100 } // finish class _XFlushable