Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / frame / _XNotifyingDispatch.java
blobeaf3b554dd55b28e21915f33c83cafa855161f73
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.frame;
22 import com.sun.star.beans.PropertyValue;
23 import com.sun.star.util.URL;
24 import lib.MultiMethodTest;
25 import lib.Status;
26 import lib.StatusException;
27 import com.sun.star.frame.XNotifyingDispatch;
28 import com.sun.star.frame.DispatchResultEvent;
30 /**
31 * Testing <code>com.sun.star.frame.XNotifyingDispatch</code>
32 * interface methods :
33 * <ul>
34 * <li><code> dispatchWithNotification()</code></li>
35 * </ul> <p>
36 * This test needs the following object relations :
37 * <ul>
38 * <li> <code>'XDispatch.URL'</code> (of type <code>com.sun.star.util.URL
39 * </code>): URL for passing to <code>dispatch()</code> method. </li>
40 * <li> <code>[OPTIONAL] 'XNotifyingDispatchArgument'</code>
41 * (of type sequence<code>com::sun::star::beans::PropertyValue
42 * </code>): argumets for <code>dispatchWithNotification()</code> method. </li>
43 * <ul> <p>
44 * @see com.sun.star.frame.XDispatch
45 * @see com.sun.star.frame.XNotifyingDispatch
46 * @see ifc.frame._XDispatch
48 public class _XNotifyingDispatch extends MultiMethodTest {
50 public XNotifyingDispatch oObj = null;
53 /**
54 * Listener implementation which sets flags on appropriate method calls
56 protected class TestNotificationListener implements
57 com.sun.star.frame.XDispatchResultListener {
58 public boolean disposingCalled = false ;
59 public boolean finishedDispatch = false ;
60 private final java.io.PrintWriter log;
62 public TestNotificationListener(java.io.PrintWriter log) {
63 this.log = log ;
66 public void disposing(com.sun.star.lang.EventObject e) {
67 disposingCalled = true ;
68 log.println(" disposing was called.") ;
71 public void dispatchFinished( DispatchResultEvent e) {
72 finishedDispatch = true ;
73 log.println(" dispatchFinished was called.") ;
78 TestNotificationListener notificationListener = null;
79 PropertyValue[] arguments = null;
80 URL url = null ;
82 /**
83 * Retrieves object relations and creates new listeners.
84 * @throws StatusException If one of relations not found.
86 @Override
87 public void before() {
88 notificationListener = new TestNotificationListener(log) ;
89 url = (URL) tEnv.getObjRelation("XDispatch.URL") ;
91 if (url == null) throw new StatusException
92 (Status.failed("Relation not found.")) ;
94 arguments = (PropertyValue[])
95 tEnv.getObjRelation("XNotifyingDispatchArgument");
98 /**
99 * Calls the method using URL and arguments from relation. <p>
100 * Has <b> OK </b> status if listener is called.
101 * The following method tests are to be completed successfully before :
103 public void _dispatchWithNotification() {
105 boolean result = true ;
107 oObj.dispatchWithNotification(url, arguments, notificationListener);
109 util.utils.pause(200);
111 log.println("Listener called: "+ notificationListener.finishedDispatch);
113 result = notificationListener.finishedDispatch;
116 tRes.tested("dispatchWithNotification()", result) ;