public class ControlApplication extends Application { private static final String TAG=ControlApplication.class.getName(); private Waiter waiter; //Thread which controls idle time // only lazy initializations here! @Override public void onCreate() { super.onCreate(); Log.d(TAG, "Starting application"+this.toString()); waiter=new Waiter(15*60*1000); //15 mins waiter.start(); } public void touch() { waiter.touch(); } }
private static Object waitFor(Waitable action) { Waiter waiter = new Waiter(action); waiter.getTimeouts().setTimeout("Waiter.WaitingTime", 120000); try { return waiter.waitAction(null); } catch (InterruptedException ex) { throw new JemmyException(action.getDescription() + " has been " + "interrupted.", ex); } } }
@SuppressWarnings("unchecked") public T invoke() { return (T) new QueueTool().invokeSmoothly(new QueueTool.QueueAction("Invoking smoothly") { public Object launch() throws Exception { return work(); } }); }
public static void waitToAvoidInstability(int time) { try { eventTool.getTimeouts().setTimeout("EventTool.WaitNoEventTimeout", Math.max(600, time)); eventTool.waitNoEvent(time); } catch (TimeoutExpiredException e) { // Ignore } } }
/** * Wait finished scan - repeatedly */ public static void waitScanFinished(){ try { new QueueTool().waitEmpty(); } catch (TimeoutExpiredException tee) { getLog().println("The following exception is ignored"); tee.printStackTrace(getLog()); } }
final Waiter waiter = new Waiter(); bus.registerMessageHandler(message -> { waiter.assertEquals(message.body(), "foo"); waiter.resume(); }); waiter.await(5000);
final Waiter waiter = new Waiter(); bus.registerListener(() -> { // Perform assertion in some other thread waiter.assertTrue(true); waiter.resume(); }); // Wait for resume() to be called waiter.await(5000);
/** * Set default timeouts */ @Override public void initialize() { // prolong timeouts JemmyProperties.setCurrentTimeout("JMenuOperator.PushMenuTimeout", 60000); JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 60000); JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNodeVisibleTimeout", 60000); JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 5 * 60000); JemmyProperties.setCurrentTimeout("Waiter.WaitingTime", 5 * 60000); }
public boolean checkComponent(Component component) { return byNameComponentChooser.checkComponent(component) || byTextComponentChooser.checkComponent(component) || byTooltipComponentChooser.checkComponent(component); }
final Waiter waiter = new Waiter(); new Thread(() -> { doSomeWork(); waiter.assertTrue(true); waiter.resume(); }).start(); // Wait for resume() to be called waiter.await(1000);
@Bean public ActionProducer actionProducer() { return new ActionProducer(); }
public String getDescription() { return this.componentType + " with name or title '" + byNameComponentChooser.getDescription() + "'"; } }
@Override public void run() { JemmyProperties.pop(); } });
private static Object waitFor(Waitable action) { Waiter waiter = new Waiter(action); waiter.getTimeouts().setTimeout("Waiter.WaitingTime", 120000); try { return waiter.waitAction(null); } catch (InterruptedException ex) { throw new JemmyException(action.getDescription() + " has been " + "interrupted.", ex); } } }
@Test public void shouldDeliverMessage() throws Throwable { final Waiter waiter = new Waiter(); messageBus.registerHandler(message -> { // Called on separate thread waiter.assertEquals(message, "foo"); // Unblocks the waiter.await call waiter.resume(); }; messageBus.send("foo"); // Wait for resume() to be called waiter.await(1000); }
/** * Set default timeouts */ @Override public void initialize() { // prolong timeouts JemmyProperties.setCurrentTimeout("JMenuOperator.PushMenuTimeout", 60000); JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 60000); JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNodeVisibleTimeout", 60000); JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 5 * 60000); JemmyProperties.setCurrentTimeout("Waiter.WaitingTime", 5 * 60000); }
@Bean public ActionProducer actionProducer() { return new ActionProducer(); }
public String getDescription() { return byNameComponentChooser.getDescription(); } }
@Bean(scope=DefaultScopes.PROTOTYPE) public ActionProducer actionProducer() { return new ActionProducer(); }