Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / task / _XInteractionHandler.java
blob3aed88c8994a5e88a2437de7159801d79ed8db11
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 ************************************************************************/
28 package ifc.task;
32 /**
33 * <code>com.sun.star.task.XInteractionHandler</code> interface testing.
34 * This test needs the following object relations :
35 * <ul>
36 * <li> <code>'XInteractionHandler.Request'</code>
37 * (of type <code>com.sun.star.task.XInteractionRequest</code>):
38 * this interface implementation is handler specific and is
39 * passed as argument to method <code>handle</code>. </li>
40 * <ul> <p>
41 * Test is <b> NOT </b> multithread compilant. <p>
42 * @see com.sun.star.task.XInteractionHandler
44 import lib.MultiMethodTest;
45 import lib.Status;
47 import com.sun.star.task.XInteractionHandler;
48 import com.sun.star.task.XInteractionRequest;
50 /**
51 * <code>com.sun.star.task.XInteractionHandler</code> interface testing.
52 * This test needs the following object relations :
53 * <ul>
54 * <li> <code>'XInteractionHandler.Request'</code>
55 * (of type <code>com.sun.star.task.XInteractionRequest</code>):
56 * this interface implementation is handler specific and is
57 * passed as argument to method <code>handle</code>. </li>
58 * <ul> <p>
59 * Test is <b> NOT </b> multithread compilant. <p>
60 * @see com.sun.star.task.XInteractionHandler
62 public class _XInteractionHandler extends MultiMethodTest {
64 // oObj filled by MultiMethodTest
65 public XInteractionHandler oObj = null ;
67 private XInteractionRequest request = null ;
69 /**
70 * Retrieves an object relation. <p>
71 * @throws StatusException If the relation is not found.
73 public void before() {
74 request = (XInteractionRequest)
75 tEnv.getObjRelation("XInteractionHandler.Request") ;
77 //if (request == null)
78 // throw new StatusException(Status.failed("Reelation not found")) ;
81 /**
82 * Sinse this test is interactive (dialog window can't be
83 * disposed using API) it is skipped. <p>
84 * Always has <b>SKIPPED.OK</b> status .
86 public void _handle() {
90 final XMultiServiceFactory msf = (XMultiServiceFactory)tParam.getMSF() ;
91 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
92 XComponent textDoc = null ;
93 try {
94 textDoc = SOF.createTextDoc( null );
95 } catch (com.sun.star.uno.Exception e) {
96 log.println("Can't create Document") ;
97 tRes.tested("handle()", false) ;
98 return ;
100 final XComponent fTextDoc = textDoc ;
101 final XModel xModelDoc = (XModel)
102 UnoRuntime.queryInterface(XModel.class, textDoc);
104 Thread thr = new Thread( new Runnable() {
105 public void run() {
106 try {
107 Thread.sleep(1000) ;
108 } catch (InterruptedException e ) {}
110 //fTextDoc.dispose() ;
112 XFrame docFr = xModelDoc.getCurrentController().getFrame() ;
113 docFr.dispose() ;
115 ///*
116 try {
118 Object dsk = msf.createInstance
119 ("com.sun.star.frame.Desktop");
121 XFrame xDsk = (XFrame)
122 UnoRuntime.queryInterface(XFrame.class, dsk) ;
124 XFrame fr = xDsk.findFrame("_top", 55) ;
126 XWindow win = fr.getContainerWindow() ;
128 String name = null ;
129 if (fr != null) {
130 name = fr.getName() ;
131 docFr.dispose() ;
134 } catch (com.sun.star.uno.Exception e) {
135 e.printStackTrace();
136 } //
138 }) ;
139 thr.start() ;
141 oObj.handle(request) ;
142 try {
143 thr.join(500) ;
144 } catch (InterruptedException e ) {}
147 tRes.tested("handle()", Status.skipped(true)) ;