From 487c3b809916ca208251d2cead9b86cb151d1bc0 Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 26 Apr 2010 15:35:49 +0200 Subject: [PATCH] sb120: #i111159# made XMessageBoxFactory test code more robust --- .../java/ifc/awt/_XMessageBoxFactory.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/qadevOOo/tests/java/ifc/awt/_XMessageBoxFactory.java b/qadevOOo/tests/java/ifc/awt/_XMessageBoxFactory.java index c4e80ee8a1d7..9c96506938da 100644 --- a/qadevOOo/tests/java/ifc/awt/_XMessageBoxFactory.java +++ b/qadevOOo/tests/java/ifc/awt/_XMessageBoxFactory.java @@ -61,48 +61,50 @@ public class _XMessageBoxFactory extends MultiMethodTest { final UITools tools = new UITools( (XMultiServiceFactory) tParam.getMSF(), UnoRuntime.queryInterface(XWindow.class, mb)); - final State[] state = new State[] { State.NONE }; + final boolean[] done = new boolean[] { false }; + final boolean[] good = new boolean[] { false }; XRequestCallback async = AsyncCallback.create( tParam.getComponentContext()); async.addCallback( new XCallback() { public void notify(Object aData) { mb.execute(); + synchronized (done) { + done[0] = true; + done.notifyAll(); + } } }, 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; + throw new RuntimeException(e); } - synchronized (state) { - state[0] = ok ? State.GOOD : State.BAD; - state.notifyAll(); + synchronized (good) { + good[0] = true; } } }, Any.VOID); - boolean ok; - synchronized (state) { - while (state[0] == State.NONE) { + synchronized (done) { + while (!done[0]) { try { - state.wait(); + done.wait(); } catch (InterruptedException e) { throw new RuntimeException(e); } } - ok = state[0] == State.GOOD; + } + boolean ok; + synchronized (good) { + ok = good[0]; } tRes.tested("createMessageBox()", ok); } - - private enum State { NONE, GOOD, BAD }; }