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