bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XMessageBoxFactory.java
blob9601c313d0704b7c5530e415ed413f281cb21296
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.awt;
21 import com.sun.star.awt.AsyncCallback;
22 import com.sun.star.awt.Rectangle;
23 import com.sun.star.awt.XCallback;
24 import com.sun.star.awt.XMessageBox;
25 import com.sun.star.awt.XMessageBoxFactory;
26 import com.sun.star.awt.XRequestCallback;
27 import com.sun.star.awt.XWindow;
28 import com.sun.star.awt.XWindowPeer;
29 import com.sun.star.lang.XMultiServiceFactory;
30 import com.sun.star.uno.Any;
31 import com.sun.star.uno.UnoRuntime;
32 import lib.MultiMethodTest;
33 import util.UITools;
35 /**
36 * Testing <code>com.sun.star.awt.XMessageBoxFactory</code>
37 * interface methods :
38 * <ul>
39 * <li><code> </code>createMessageBox()</li>
40 * </ul> <p>
41 * Test is <b> NOT </b> multithread compilant. <p>
42 * @see com.sun.star.awt.XMessageBoxFactory
44 public class _XMessageBoxFactory extends MultiMethodTest {
45 public XMessageBoxFactory oObj = null;
47 public void _createMessageBox() {
48 final XMessageBox mb = oObj.createMessageBox(
49 (XWindowPeer) tEnv.getObjRelation("WINPEER"),
50 com.sun.star.awt.MessageBoxType.ERRORBOX, 1, "The Title",
51 "The Message");
52 final UITools tools = new UITools(
53 (XMultiServiceFactory) tParam.getMSF(),
54 UnoRuntime.queryInterface(XWindow.class, mb));
55 final boolean[] done = new boolean[] { false };
56 final boolean[] good = new boolean[] { false };
57 XRequestCallback async = AsyncCallback.create(
58 tParam.getComponentContext());
59 async.addCallback(
60 new XCallback() {
61 public void notify(Object aData) {
62 mb.execute();
63 synchronized (done) {
64 done[0] = true;
65 done.notifyAll();
69 Any.VOID);
70 async.addCallback(
71 new XCallback() {
72 public void notify(Object aData) {
73 try {
74 tools.clickButton("OK");
75 } catch (RuntimeException e) {
76 throw e;
77 } catch (Exception e) {
78 throw new RuntimeException(e);
80 synchronized (good) {
81 good[0] = true;
85 Any.VOID);
86 synchronized (done) {
87 while (!done[0]) {
88 try {
89 done.wait();
90 } catch (InterruptedException e) {
91 throw new RuntimeException(e);
95 boolean ok;
96 synchronized (good) {
97 ok = good[0];
99 tRes.tested("createMessageBox()", ok);