1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.task;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir /**
29cdf0e10cSrcweir * <code>com.sun.star.task.XInteractionHandler</code> interface testing.
30cdf0e10cSrcweir * This test needs the following object relations :
31cdf0e10cSrcweir * <ul>
32cdf0e10cSrcweir *  <li> <code>'XInteractionHandler.Request'</code>
33cdf0e10cSrcweir *    (of type <code>com.sun.star.task.XInteractionRequest</code>):
34cdf0e10cSrcweir *    this interface implementation is handler specific and is
35cdf0e10cSrcweir *    passed as argument to method <code>handle</code>. </li>
36cdf0e10cSrcweir * <ul> <p>
37cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p>
38cdf0e10cSrcweir * @see com.sun.star.task.XInteractionHandler
39cdf0e10cSrcweir */
40cdf0e10cSrcweir import lib.MultiMethodTest;
41cdf0e10cSrcweir import lib.Status;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir import com.sun.star.task.XInteractionHandler;
44cdf0e10cSrcweir import com.sun.star.task.XInteractionRequest;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir /**
47cdf0e10cSrcweir * <code>com.sun.star.task.XInteractionHandler</code> interface testing.
48cdf0e10cSrcweir * This test needs the following object relations :
49cdf0e10cSrcweir * <ul>
50cdf0e10cSrcweir *  <li> <code>'XInteractionHandler.Request'</code>
51cdf0e10cSrcweir *    (of type <code>com.sun.star.task.XInteractionRequest</code>):
52cdf0e10cSrcweir *    this interface implementation is handler specific and is
53cdf0e10cSrcweir *    passed as argument to method <code>handle</code>. </li>
54cdf0e10cSrcweir * <ul> <p>
55cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p>
56cdf0e10cSrcweir * @see com.sun.star.task.XInteractionHandler
57cdf0e10cSrcweir */
58cdf0e10cSrcweir public class _XInteractionHandler extends MultiMethodTest {
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     // oObj filled by MultiMethodTest
61cdf0e10cSrcweir     public XInteractionHandler oObj = null ;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     private XInteractionRequest request = null ;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     /**
66cdf0e10cSrcweir     * Retrieves an object relation. <p>
67cdf0e10cSrcweir     * @throws StatusException If the relation is not found.
68cdf0e10cSrcweir     */
before()69cdf0e10cSrcweir     public void before() {
70cdf0e10cSrcweir         request = (XInteractionRequest)
71cdf0e10cSrcweir             tEnv.getObjRelation("XInteractionHandler.Request") ;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         //if (request == null)
74cdf0e10cSrcweir         //    throw new StatusException(Status.failed("Reelation not found")) ;
75cdf0e10cSrcweir     }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     /**
78cdf0e10cSrcweir     * Sinse this test is interactive (dialog window can't be
79cdf0e10cSrcweir     * disposed using API) it is skipped. <p>
80cdf0e10cSrcweir     * Always has <b>SKIPPED.OK</b> status .
81cdf0e10cSrcweir     */
_handle()82cdf0e10cSrcweir     public void _handle() {
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         /*
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         final XMultiServiceFactory msf = (XMultiServiceFactory)tParam.getMSF() ;
87cdf0e10cSrcweir         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
88cdf0e10cSrcweir         XComponent textDoc = null ;
89cdf0e10cSrcweir         try {
90cdf0e10cSrcweir             textDoc = SOF.createTextDoc( null );
91cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception e) {
92cdf0e10cSrcweir             log.println("Can't create Document") ;
93cdf0e10cSrcweir             tRes.tested("handle()", false) ;
94cdf0e10cSrcweir             return ;
95cdf0e10cSrcweir         }
96cdf0e10cSrcweir         final XComponent fTextDoc = textDoc ;
97cdf0e10cSrcweir         final XModel xModelDoc = (XModel)
98cdf0e10cSrcweir             UnoRuntime.queryInterface(XModel.class, textDoc);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir         Thread thr = new Thread( new Runnable() {
101cdf0e10cSrcweir             public void run() {
102cdf0e10cSrcweir                 try {
103cdf0e10cSrcweir                     Thread.sleep(1000) ;
104cdf0e10cSrcweir                 } catch (InterruptedException e ) {}
105cdf0e10cSrcweir 
106cdf0e10cSrcweir                 //fTextDoc.dispose() ;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir                 XFrame docFr = xModelDoc.getCurrentController().getFrame() ;
109cdf0e10cSrcweir                 docFr.dispose() ;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir                 ///*
112cdf0e10cSrcweir                 try {
113cdf0e10cSrcweir 
114cdf0e10cSrcweir                     Object dsk = msf.createInstance
115cdf0e10cSrcweir                         ("com.sun.star.frame.Desktop");
116cdf0e10cSrcweir 
117cdf0e10cSrcweir                     XFrame xDsk = (XFrame)
118cdf0e10cSrcweir                         UnoRuntime.queryInterface(XFrame.class, dsk) ;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir                     XFrame fr = xDsk.findFrame("_top", 55) ;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir                     XWindow win = fr.getContainerWindow() ;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir                     String name = null ;
125cdf0e10cSrcweir                     if (fr != null) {
126cdf0e10cSrcweir                         name = fr.getName() ;
127cdf0e10cSrcweir                         docFr.dispose() ;
128cdf0e10cSrcweir                     }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir                 } catch (com.sun.star.uno.Exception e) {
131cdf0e10cSrcweir                     e.printStackTrace();
132cdf0e10cSrcweir                 } //
133cdf0e10cSrcweir             }
134cdf0e10cSrcweir         }) ;
135cdf0e10cSrcweir         thr.start() ;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         oObj.handle(request) ;
138cdf0e10cSrcweir         try {
139cdf0e10cSrcweir             thr.join(500) ;
140cdf0e10cSrcweir         } catch (InterruptedException e ) {}
141cdf0e10cSrcweir         */
142cdf0e10cSrcweir 
143cdf0e10cSrcweir         tRes.tested("handle()", Status.skipped(true)) ;
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 
148