merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / awt / _XMessageBoxFactory.java
blob51f4b31b68a0afdde26dcd64cf6c0f17e6555163
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: _XMessageBoxFactory.java,v $
10 * $Revision: 1.3 $
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.awt;
33 import com.sun.star.awt.Rectangle;
34 import com.sun.star.awt.XWindowPeer;
35 import com.sun.star.lang.XMultiServiceFactory;
36 import lib.MultiMethodTest;
38 import com.sun.star.awt.XMessageBoxFactory;
39 import com.sun.star.awt.XWindow;
40 import com.sun.star.frame.XModel;
41 import java.io.PrintWriter;
42 import lib.Status;
43 import lib.StatusException;
44 import util.UITools;
46 /**
47 * Testing <code>com.sun.star.awt.XMessageBoxFactory</code>
48 * interface methods :
49 * <ul>
50 * <li><code> </code>createMessageBox()</li>
51 * </ul> <p>
52 * Test is <b> NOT </b> multithread compilant. <p>
53 * @see com.sun.star.awt.XMessageBoxFactory
55 public class _XMessageBoxFactory extends MultiMethodTest {
57 public XMessageBoxFactory oObj = null;
58 private XWindowPeer the_win = null;
59 private XModel xModel = null;
61 /**
62 * Retrieves object relation.
63 * @throws StatusException If the relation not found.
65 public void before() {
66 the_win = (XWindowPeer) tEnv.getObjRelation("WINPEER");
67 if (the_win == null)
68 throw new StatusException(Status.failed("Relation 'WINPEER' not found")) ;
69 xModel = (XModel) tEnv.getObjRelation("XModel");
70 if (xModel == null)
71 throw new StatusException(Status.failed("Relation 'xModel' not found")) ;
76 /**
77 * As <code>execute()</code> method is a blocking call,
78 * then it must be executed in a separate thread. This
79 * thread class just call <code>execute</code> method
80 * of tested object.
82 protected Thread execThread = new Thread(
83 new Runnable() {
84 public void run() {
85 Rectangle rect = new Rectangle(0,0,100,100);
86 oObj.createMessageBox(the_win, rect, "errorbox", 1, "The Title", "The Message") ;
88 }) ;
91 /**
92 * Starts the execution of MessageBox in a separate thread.
93 * As this call is blocking then the thread execution
94 * must not be finished. <p>
95 * Has <b>OK</b> status if thread wasn't finished and
96 * no exceptions occured.
98 public void _createMessageBox() {
99 boolean result = true ;
101 log.println("Starting createMessageBox() thread ...") ;
102 execThread.start() ;
104 try {
105 execThread.join(200) ;
106 } catch (InterruptedException e) {
107 log.println("createMessageBox() thread was interrupted") ;
108 result = false ;
110 result &= execThread.isAlive() ;
112 UITools oUITools = new UITools((XMultiServiceFactory) tParam.getMSF(), xModel);
114 XWindow xWindow = null;
115 try{
116 xWindow = oUITools.getActiveTopWindow();
118 oUITools.printAccessibleTree(log, tParam.getBool("DebugIsActive"));
120 oUITools.clickButton("OK");
122 } catch (java.lang.Exception e) {
123 e.printStackTrace((PrintWriter) log);
124 log.println("Could not cklick 'OK' on messagebox: " + e.toString());
125 result = false;
128 tRes.tested("createMessageBox()", result) ;