diff options
author | sb <sb@openoffice.org> | 2010-02-25 13:36:39 +0100 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-02-25 13:36:39 +0100 |
commit | f5112edb7df833b6b682e34ff6878c17ea7391c0 (patch) | |
tree | f8f302a354ffdf86a51f13f7f130e9b39e015a87 /qadevOOo | |
parent | 4c193f3c48400ee5e3ae540f3c3d07c9a25f4219 (diff) | |
parent | 0c077660ee7fe67fb821cb7101b0cbe54f605564 (diff) |
sb118: merged in to-the-side sb118 changes
Diffstat (limited to 'qadevOOo')
-rw-r--r-- | qadevOOo/tests/java/ifc/awt/_XMessageBoxFactory.java | 140 |
1 files changed, 52 insertions, 88 deletions
diff --git a/qadevOOo/tests/java/ifc/awt/_XMessageBoxFactory.java b/qadevOOo/tests/java/ifc/awt/_XMessageBoxFactory.java index dbaf4e420..f9919720d 100644 --- a/qadevOOo/tests/java/ifc/awt/_XMessageBoxFactory.java +++ b/qadevOOo/tests/java/ifc/awt/_XMessageBoxFactory.java @@ -27,18 +27,18 @@ package ifc.awt; +import com.sun.star.awt.AsyncCallback; import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XCallback; +import com.sun.star.awt.XMessageBox; +import com.sun.star.awt.XMessageBoxFactory; +import com.sun.star.awt.XRequestCallback; +import com.sun.star.awt.XWindow; import com.sun.star.awt.XWindowPeer; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; import com.sun.star.uno.UnoRuntime; import lib.MultiMethodTest; - -import com.sun.star.awt.XMessageBox; -import com.sun.star.awt.XMessageBoxFactory; -import com.sun.star.awt.XWindow; -import java.io.PrintWriter; -import lib.Status; -import lib.StatusException; import util.UITools; /** @@ -51,94 +51,58 @@ import util.UITools; * @see com.sun.star.awt.XMessageBoxFactory */ public class _XMessageBoxFactory extends MultiMethodTest { - public XMessageBoxFactory oObj = null; - private XWindowPeer the_win = null; - - /** - * Retrieves object relation. - * @throws StatusException If the relation not found. - */ - public void before() { - the_win = (XWindowPeer) tEnv.getObjRelation("WINPEER"); - if (the_win == null) - throw new StatusException(Status.failed("Relation 'WINPEER' not found")) ; - } - - - /** - * As <code>execute()</code> method is a blocking call, - * then it must be executed in a separate thread. This - * thread class just call <code>execute</code> method - * of tested object. - */ - protected Thread execThread = new Thread( - new Runnable() { - public void run() { - Rectangle rect = new Rectangle(0,0,100,100); - XMessageBox mb = oObj.createMessageBox(the_win, rect, "errorbox", 1, "The Title", "The Message") ; - synchronized (this) { - messageBox = mb; - notifyAll(); - } - mb.execute(); - } - }) ; - private XMessageBox messageBox = null; - - - /** - * Starts the execution of MessageBox in a separate thread. - * As this call is blocking then the thread execution - * must not be finished. <p> - * Has <b>OK</b> status if thread wasn't finished and - * no exceptions occured. - */ + public void _createMessageBox() { - boolean result = true ; - - log.println("Starting createMessageBox() thread ...") ; - execThread.start() ; - - try { - execThread.join(200) ; - } catch (InterruptedException e) { - log.println("createMessageBox() thread was interrupted") ; - result = false ; - } - result &= execThread.isAlive() ; - - synchronized (execThread) { - while (messageBox == null) { + final XMessageBox mb = oObj.createMessageBox( + (XWindowPeer) tEnv.getObjRelation("WINPEER"), + new Rectangle(0, 0, 100, 100), "errorbox", 1, "The Title", + "The Message"); + final UITools tools = new UITools( + (XMultiServiceFactory) tParam.getMSF(), + UnoRuntime.queryInterface(XWindow.class, mb)); + final State[] state = new State[] { State.NONE }; + XRequestCallback async = AsyncCallback.create( + tParam.getComponentContext()); + async.addCallback( + new XCallback() { + public void notify(Object aData) { + mb.execute(); + } + }, + Any.VOID); + async.addCallback( + new XCallback() { + public void notify(Object aData) { + boolean ok = true; + try { + tools.clickButton("OK"); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + e.printStackTrace(); + ok = false; + } + synchronized (state) { + state[0] = ok ? State.GOOD : State.BAD; + state.notifyAll(); + } + } + }, + Any.VOID); + boolean ok; + synchronized (state) { + while (state[0] == State.NONE) { try { - execThread.wait(); + state.wait(); } catch (InterruptedException e) { throw new RuntimeException(e); } } + ok = state[0] == State.GOOD; } - try { - Thread.currentThread().sleep(500); - } catch(InterruptedException e) { - throw new RuntimeException(e); - } - UITools oUITools = new UITools( - (XMultiServiceFactory) tParam.getMSF(), - UnoRuntime.queryInterface(XWindow.class, messageBox)); - try{ - oUITools.printAccessibleTree(log, tParam.getBool("DebugIsActive")); - - oUITools.clickButton("OK"); - - } catch (java.lang.Exception e) { - e.printStackTrace((PrintWriter) log); - log.println("Could not cklick 'OK' on messagebox: " + e.toString()); - result = false; - } - - tRes.tested("createMessageBox()", result) ; + tRes.tested("createMessageBox()", ok); } - -} - + private enum State { NONE, GOOD, BAD }; +} |