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