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 ************************************************************************/
31 import com
.sun
.star
.beans
.PropertyValue
;
32 import com
.sun
.star
.util
.URL
;
33 import lib
.MultiMethodTest
;
35 import lib
.StatusException
;
36 import com
.sun
.star
.frame
.XNotifyingDispatch
;
37 import com
.sun
.star
.frame
.DispatchResultEvent
;
40 * Testing <code>com.sun.star.frame.XNotifyingDispatch</code>
43 * <li><code> dispatchWithNotification()</code></li>
45 * This test needs the following object relations :
47 * <li> <code>'XDispatch.URL'</code> (of type <code>com.sun.star.util.URL
48 * </code>): URL for passing to <code>dispatch()</code> method. </li>
49 * <li> <code>[OPTIONAL] 'XNotifyingDispatchArgument'</code>
50 * (of type sequence<code>com::sun::star::beans::PropertyValue
51 * </code>): argumets for <code>dispatchWithNotification()</code> method. </li>
53 * @see com.sun.star.frame.XDispatch
54 * @see com.sun.star.frame.XNotifyingDispatch
55 * @see ifc.frmae._XDispatch
57 public class _XNotifyingDispatch
extends MultiMethodTest
{
59 public XNotifyingDispatch oObj
= null;
63 * Listener implementation which sets flags on appropriate method calls
65 protected class TestNotificationListener
implements
66 com
.sun
.star
.frame
.XDispatchResultListener
{
67 public boolean disposingCalled
= false ;
68 public boolean finishedDispatch
= false ;
69 private java
.io
.PrintWriter log
= null ;
71 public TestNotificationListener(java
.io
.PrintWriter log
) {
75 public void disposing(com
.sun
.star
.lang
.EventObject e
) {
76 disposingCalled
= true ;
77 log
.println(" disposing was called.") ;
80 public void dispatchFinished( DispatchResultEvent e
) {
81 finishedDispatch
= true ;
82 log
.println(" dispatchFinished was called.") ;
87 TestNotificationListener notificationListener
= null;
88 PropertyValue
[] arguments
= null;
92 * Retrieves object relations and creates new listeners.
93 * @throws StatusException If one of relations not found.
95 public void before() {
96 notificationListener
= new TestNotificationListener(log
) ;
97 url
= (URL
) tEnv
.getObjRelation("XDispatch.URL") ;
99 if (url
== null) throw new StatusException
100 (Status
.failed("Relation not found.")) ;
102 arguments
= (PropertyValue
[])
103 tEnv
.getObjRelation("XNotifyingDispatchArgument");
107 * Calls the method using URL and arguments from relation. <p>
108 * Has <b> OK </b> status if listener is called.
109 * The following method tests are to be completed successfully before :
111 public void _dispatchWithNotification() {
113 boolean result
= true ;
115 oObj
.dispatchWithNotification(url
, arguments
, notificationListener
);
120 catch(java
.lang
.InterruptedException e
) {}
122 log
.println("Listener called: "+ notificationListener
.finishedDispatch
);
124 result
= notificationListener
.finishedDispatch
;
127 tRes
.tested("dispatchWithNotification()", result
) ;