merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / task / _XInteractionHandler.java
blob2c07cf91f499b403abcc8c6723cead85db8dadb5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XInteractionHandler.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.task;
35 /**
36 * <code>com.sun.star.task.XInteractionHandler</code> interface testing.
37 * This test needs the following object relations :
38 * <ul>
39 * <li> <code>'XInteractionHandler.Request'</code>
40 * (of type <code>com.sun.star.task.XInteractionRequest</code>):
41 * this interface implementation is handler specific and is
42 * passed as argument to method <code>handle</code>. </li>
43 * <ul> <p>
44 * Test is <b> NOT </b> multithread compilant. <p>
45 * @see com.sun.star.task.XInteractionHandler
47 import lib.MultiMethodTest;
48 import lib.Status;
50 import com.sun.star.task.XInteractionHandler;
51 import com.sun.star.task.XInteractionRequest;
53 /**
54 * <code>com.sun.star.task.XInteractionHandler</code> interface testing.
55 * This test needs the following object relations :
56 * <ul>
57 * <li> <code>'XInteractionHandler.Request'</code>
58 * (of type <code>com.sun.star.task.XInteractionRequest</code>):
59 * this interface implementation is handler specific and is
60 * passed as argument to method <code>handle</code>. </li>
61 * <ul> <p>
62 * Test is <b> NOT </b> multithread compilant. <p>
63 * @see com.sun.star.task.XInteractionHandler
65 public class _XInteractionHandler extends MultiMethodTest {
67 // oObj filled by MultiMethodTest
68 public XInteractionHandler oObj = null ;
70 private XInteractionRequest request = null ;
72 /**
73 * Retrieves an object relation. <p>
74 * @throws StatusException If the relation is not found.
76 public void before() {
77 request = (XInteractionRequest)
78 tEnv.getObjRelation("XInteractionHandler.Request") ;
80 //if (request == null)
81 // throw new StatusException(Status.failed("Reelation not found")) ;
84 /**
85 * Sinse this test is interactive (dialog window can't be
86 * disposed using API) it is skipped. <p>
87 * Always has <b>SKIPPED.OK</b> status .
89 public void _handle() {
93 final XMultiServiceFactory msf = (XMultiServiceFactory)tParam.getMSF() ;
94 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
95 XComponent textDoc = null ;
96 try {
97 textDoc = SOF.createTextDoc( null );
98 } catch (com.sun.star.uno.Exception e) {
99 log.println("Can't create Document") ;
100 tRes.tested("handle()", false) ;
101 return ;
103 final XComponent fTextDoc = textDoc ;
104 final XModel xModelDoc = (XModel)
105 UnoRuntime.queryInterface(XModel.class, textDoc);
107 Thread thr = new Thread( new Runnable() {
108 public void run() {
109 try {
110 Thread.sleep(1000) ;
111 } catch (InterruptedException e ) {}
113 //fTextDoc.dispose() ;
115 XFrame docFr = xModelDoc.getCurrentController().getFrame() ;
116 docFr.dispose() ;
118 ///*
119 try {
121 Object dsk = msf.createInstance
122 ("com.sun.star.frame.Desktop");
124 XFrame xDsk = (XFrame)
125 UnoRuntime.queryInterface(XFrame.class, dsk) ;
127 XFrame fr = xDsk.findFrame("_top", 55) ;
129 XWindow win = fr.getContainerWindow() ;
131 String name = null ;
132 if (fr != null) {
133 name = fr.getName() ;
134 docFr.dispose() ;
137 } catch (com.sun.star.uno.Exception e) {
138 e.printStackTrace();
139 } //
141 }) ;
142 thr.start() ;
144 oObj.handle(request) ;
145 try {
146 thr.join(500) ;
147 } catch (InterruptedException e ) {}
150 tRes.tested("handle()", Status.skipped(true)) ;