1ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5ef39d40dSAndrew Rist * distributed with this work for additional information 6ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10ef39d40dSAndrew Rist * 11ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12ef39d40dSAndrew Rist * 13ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17ef39d40dSAndrew Rist * specific language governing permissions and limitations 18ef39d40dSAndrew Rist * under the License. 19ef39d40dSAndrew Rist * 20ef39d40dSAndrew Rist *************************************************************/ 21ef39d40dSAndrew Rist 22ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.awt; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import com.sun.star.awt.AsyncCallback; 27cdf0e10cSrcweir import com.sun.star.awt.Rectangle; 28cdf0e10cSrcweir import com.sun.star.awt.XCallback; 29cdf0e10cSrcweir import com.sun.star.awt.XMessageBox; 30cdf0e10cSrcweir import com.sun.star.awt.XMessageBoxFactory; 31cdf0e10cSrcweir import com.sun.star.awt.XRequestCallback; 32cdf0e10cSrcweir import com.sun.star.awt.XWindow; 33cdf0e10cSrcweir import com.sun.star.awt.XWindowPeer; 34cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 35cdf0e10cSrcweir import com.sun.star.uno.Any; 36cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 37cdf0e10cSrcweir import lib.MultiMethodTest; 38cdf0e10cSrcweir import util.UITools; 39cdf0e10cSrcweir 40cdf0e10cSrcweir /** 41cdf0e10cSrcweir * Testing <code>com.sun.star.awt.XMessageBoxFactory</code> 42cdf0e10cSrcweir * interface methods : 43cdf0e10cSrcweir * <ul> 44cdf0e10cSrcweir * <li><code> </code>createMessageBox()</li> 45cdf0e10cSrcweir * </ul> <p> 46cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p> 47cdf0e10cSrcweir * @see com.sun.star.awt.XMessageBoxFactory 48cdf0e10cSrcweir */ 49cdf0e10cSrcweir public class _XMessageBoxFactory extends MultiMethodTest { 50cdf0e10cSrcweir public XMessageBoxFactory oObj = null; 51cdf0e10cSrcweir _createMessageBox()52cdf0e10cSrcweir public void _createMessageBox() { 53cdf0e10cSrcweir final XMessageBox mb = oObj.createMessageBox( 54cdf0e10cSrcweir (XWindowPeer) tEnv.getObjRelation("WINPEER"), 55*61161268SAriel Constenla-Haile com.sun.star.awt.MessageBoxType.ERRORBOX, 1, "The Title", 56cdf0e10cSrcweir "The Message"); 57cdf0e10cSrcweir final UITools tools = new UITools( 58cdf0e10cSrcweir (XMultiServiceFactory) tParam.getMSF(), 59cdf0e10cSrcweir UnoRuntime.queryInterface(XWindow.class, mb)); 60cdf0e10cSrcweir final boolean[] done = new boolean[] { false }; 61cdf0e10cSrcweir final boolean[] good = new boolean[] { false }; 62cdf0e10cSrcweir XRequestCallback async = AsyncCallback.create( 63cdf0e10cSrcweir tParam.getComponentContext()); 64cdf0e10cSrcweir async.addCallback( 65cdf0e10cSrcweir new XCallback() { 66cdf0e10cSrcweir public void notify(Object aData) { 67cdf0e10cSrcweir mb.execute(); 68cdf0e10cSrcweir synchronized (done) { 69cdf0e10cSrcweir done[0] = true; 70cdf0e10cSrcweir done.notifyAll(); 71cdf0e10cSrcweir } 72cdf0e10cSrcweir } 73cdf0e10cSrcweir }, 74cdf0e10cSrcweir Any.VOID); 75cdf0e10cSrcweir async.addCallback( 76cdf0e10cSrcweir new XCallback() { 77cdf0e10cSrcweir public void notify(Object aData) { 78cdf0e10cSrcweir try { 79cdf0e10cSrcweir tools.clickButton("OK"); 80cdf0e10cSrcweir } catch (RuntimeException e) { 81cdf0e10cSrcweir throw e; 82cdf0e10cSrcweir } catch (Exception e) { 83cdf0e10cSrcweir throw new RuntimeException(e); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir synchronized (good) { 86cdf0e10cSrcweir good[0] = true; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir } 89cdf0e10cSrcweir }, 90cdf0e10cSrcweir Any.VOID); 91cdf0e10cSrcweir synchronized (done) { 92cdf0e10cSrcweir while (!done[0]) { 93cdf0e10cSrcweir try { 94cdf0e10cSrcweir done.wait(); 95cdf0e10cSrcweir } catch (InterruptedException e) { 96cdf0e10cSrcweir throw new RuntimeException(e); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir } 99cdf0e10cSrcweir } 100cdf0e10cSrcweir boolean ok; 101cdf0e10cSrcweir synchronized (good) { 102cdf0e10cSrcweir ok = good[0]; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir tRes.tested("createMessageBox()", ok); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir } 107