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 .
22 import com
.sun
.star
.beans
.PropertyValue
;
23 import com
.sun
.star
.util
.URL
;
24 import lib
.MultiMethodTest
;
26 import lib
.StatusException
;
27 import com
.sun
.star
.frame
.XNotifyingDispatch
;
28 import com
.sun
.star
.frame
.DispatchResultEvent
;
31 * Testing <code>com.sun.star.frame.XNotifyingDispatch</code>
34 * <li><code> dispatchWithNotification()</code></li>
36 * This test needs the following object relations :
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>): arguments for <code>dispatchWithNotification()</code> method. </li>
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;
54 * Listener implementation which sets flags on appropriate method calls
56 protected static class TestNotificationListener
implements
57 com
.sun
.star
.frame
.XDispatchResultListener
{
58 public boolean finishedDispatch
= false ;
59 private final java
.io
.PrintWriter log
;
61 public TestNotificationListener(java
.io
.PrintWriter log
) {
65 public void disposing(com
.sun
.star
.lang
.EventObject e
) {
66 log
.println(" disposing was called.") ;
69 public void dispatchFinished( DispatchResultEvent e
) {
70 finishedDispatch
= true ;
71 log
.println(" dispatchFinished was called.") ;
76 TestNotificationListener notificationListener
= null;
77 PropertyValue
[] arguments
= null;
81 * Retrieves object relations and creates new listeners.
82 * @throws StatusException If one of relations not found.
85 public void before() {
86 notificationListener
= new TestNotificationListener(log
) ;
87 url
= (URL
) tEnv
.getObjRelation("XDispatch.URL") ;
89 if (url
== null) throw new StatusException
90 (Status
.failed("Relation not found.")) ;
92 arguments
= (PropertyValue
[])
93 tEnv
.getObjRelation("XNotifyingDispatchArgument");
97 * Calls the method using URL and arguments from relation. <p>
98 * Has <b> OK </b> status if listener is called.
99 * The following method tests are to be completed successfully before :
101 public void _dispatchWithNotification() {
103 boolean result
= true ;
105 oObj
.dispatchWithNotification(url
, arguments
, notificationListener
);
109 log
.println("Listener called: "+ notificationListener
.finishedDispatch
);
111 result
= notificationListener
.finishedDispatch
;
114 tRes
.tested("dispatchWithNotification()", result
) ;