/** {@inheritDoc} */ public long get_longlong() throws TypeMismatch { try { return ((LongHolder) holder).value; } catch (ClassCastException cex) { TypeMismatch m = new TypeMismatch(); m.initCause(cex); throw m; } }
/** {@inheritDoc} */ public void insert_longlong(long a_x) throws InvalidValue, TypeMismatch { try { ((LongHolder) holder).value = a_x; valueChanged(); } catch (ClassCastException cex) { TypeMismatch t = new TypeMismatch(); t.initCause(cex); throw t; } }
/** {@inheritDoc} */ public void insert_ulonglong(long a_x) throws InvalidValue, TypeMismatch { try { ((LongHolder) holder).value = a_x; valueChanged(); } catch (ClassCastException cex) { TypeMismatch t = new TypeMismatch(); t.initCause(cex); throw t; } }
/** {@inheritDoc} */ public long extract_longlong() throws BAD_OPERATION { check(TCKind._tk_longlong); return ((LongHolder) has).value; }
/** {@inheritDoc} */ public long extract_ulonglong() throws BAD_OPERATION { // LongHolder also holds ulonglong check(TCKind._tk_ulonglong); return ((LongHolder) has).value; }
@Test public void setWinWaitDelay() { try { // delay 5 seconds Assert.assertEquals(Opt.DEFAULT_WIN_WAIT_DELAY, Opt.setWinWaitDelay(3000)); final LongHolder time = new LongHolder(0); Thread thread = new Thread(new Runnable() { public void run() { long start = System.currentTimeMillis(); Win.wait(NOTEPAD_TITLE); long end = System.currentTimeMillis(); time.value = end - start; } }); thread.start(); runNotepad(); sleep(4000); Assert.assertTrue(String.format("%d >= 3000", time.value), time.value >= 3000); Assert.assertTrue(String.format("%d <= 4000", time.value), time.value <= 4000); Assert.assertFalse(thread.isAlive()); Win.close(NOTEPAD_TITLE); // delay 2 seconds Assert.assertEquals(3000, Opt.setWinWaitDelay(2000)); time.value = 0; thread = new Thread(new Runnable() { public void run() { long start = System.currentTimeMillis(); Win.wait(NOTEPAD_TITLE); long end = System.currentTimeMillis(); time.value = end - start; } }); thread.start(); runNotepad(); while (thread.isAlive()) { sleep(100); } Assert.assertTrue(String.format("%d >= 2000", time.value), time.value >= 2000); Assert.assertTrue(String.format("%d <= 3000", time.value), time.value <= 3000); Assert.assertFalse(thread.isAlive()); Win.close(NOTEPAD_TITLE); } finally { // restore default win delay Opt.setWinWaitDelay(Opt.DEFAULT_WIN_WAIT_DELAY); } }