use of com.tmall.wireless.tangram.support.TimerSupport.OnTickListener in project Tangram-Android by alibaba.
the class RxTimerSupportTest method testTimerIntermediateArg.
@Test
@SmallTest
@UiThreadTest
public void testTimerIntermediateArg() {
assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
mTimerSupport.register(1, new OnTickListener() {
long start = System.currentTimeMillis();
@Override
public void onTick() {
assertEquals(Looper.myLooper(), Looper.getMainLooper());
assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
long end = System.currentTimeMillis();
long time = (end - start);
Log.d("RxTimerSupportTest", "testTimerIntermediateArg " + time);
assertTrue(Math.abs(time) < 50 || Math.abs(time - 1 * 1000) < 50);
start = end;
}
}, true);
}
use of com.tmall.wireless.tangram.support.TimerSupport.OnTickListener in project Tangram-Android by alibaba.
the class RxTimerSupportTest method testIntervalLargerThan1.
@Test
@SmallTest
@UiThreadTest
public void testIntervalLargerThan1() {
assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
mTimerSupport.register(3, new OnTickListener() {
long start = System.currentTimeMillis();
@Override
public void onTick() {
assertEquals(Looper.myLooper(), Looper.getMainLooper());
assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
long end = System.currentTimeMillis();
long time = (end - start);
Log.d("RxTimerSupportTest", "3 testTimerExecution " + time);
assertTrue(Math.abs(time - 3 * 1000) < 50);
start = end;
}
});
}
use of com.tmall.wireless.tangram.support.TimerSupport.OnTickListener in project Tangram-Android by alibaba.
the class RxTimerSupportTest method testRegisterAndUnregister.
@Test
@SmallTest
@UiThreadTest
public void testRegisterAndUnregister() {
assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
OnTickListener onTickListener = new OnTickListener() {
long start = System.currentTimeMillis();
@Override
public void onTick() {
assertEquals(Looper.myLooper(), Looper.getMainLooper());
assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
long end = System.currentTimeMillis();
long time = (end - start);
Log.d("RxTimerSupportTest", "testTimerIntermediateArg " + time);
// assertTrue(Math.abs(time) < 50 || Math.abs(time - 1 * 1000) < 50);
start = end;
}
};
mTimerSupport.register(1, onTickListener, true);
mTimerSupport.unregister(onTickListener);
mTimerSupport.register(1, onTickListener, true);
mTimerSupport.unregister(onTickListener);
mTimerSupport.register(1, onTickListener, true);
mTimerSupport.unregister(onTickListener);
mTimerSupport.register(1, onTickListener, true);
}
use of com.tmall.wireless.tangram.support.TimerSupport.OnTickListener in project Tangram-Android by alibaba.
the class RxTimerSupportTest method testTwoListener.
@Test
@SmallTest
@UiThreadTest
public void testTwoListener() {
assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
mTimerSupport.register(1, new OnTickListener() {
long start = System.currentTimeMillis();
@Override
public void onTick() {
assertEquals(Looper.myLooper(), Looper.getMainLooper());
assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
long end = System.currentTimeMillis();
long time = (end - start);
Log.d("RxTimerSupportTest", "1 testTimerExecution " + time);
assertTrue(Math.abs(time - 1 * 1000) < 50);
start = end;
}
});
mTimerSupport.register(3, new OnTickListener() {
long start = System.currentTimeMillis();
@Override
public void onTick() {
assertEquals(Looper.myLooper(), Looper.getMainLooper());
assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
long end = System.currentTimeMillis();
long time = (end - start);
Log.d("RxTimerSupportTest", "3 testTimerExecution " + time);
assertTrue(Math.abs(time - 3 * 1000) < 50);
start = end;
}
});
}
use of com.tmall.wireless.tangram.support.TimerSupport.OnTickListener in project Tangram-Android by alibaba.
the class RxTimerSupportTest method testStop.
@Test
@SmallTest
@UiThreadTest
public void testStop() {
assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
mTimerSupport.register(1, new OnTickListener() {
@Override
public void onTick() {
// should not here
assertTrue(false);
}
});
mTimerSupport.register(3, new OnTickListener() {
@Override
public void onTick() {
// should not here
assertTrue(false);
}
});
mTimerSupport.clear();
}
Aggregations