use of com.tmall.wireless.tangram.support.TimerSupport.OnTickListener in project Tangram-Android by alibaba.
the class RxTimerSupportTest method testResume.
@Test
@SmallTest
@UiThreadTest
public void testResume() {
assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
mTimerSupport.register(1, new OnTickListener() {
@Override
public void onTick() {
assertEquals(Looper.myLooper(), Looper.getMainLooper());
assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
Log.d("RxTimerSupportTest", "testResume");
}
});
mTimerSupport.pause();
mTimerSupport.restart();
}
use of com.tmall.wireless.tangram.support.TimerSupport.OnTickListener in project Tangram-Android by alibaba.
the class RxTimerSupportTest method testTimerExecution.
@Test
@SmallTest
@UiThreadTest
public void testTimerExecution() {
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", "testTimerExecution " + time);
assertTrue(Math.abs(time - 1 * 1000) < 50);
start = end;
}
});
}
use of com.tmall.wireless.tangram.support.TimerSupport.OnTickListener in project Tangram-Android by alibaba.
the class RxTimerSupportTest method testPause.
@Test
@SmallTest
@UiThreadTest
public void testPause() {
assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
mTimerSupport.register(1, new OnTickListener() {
long start = System.currentTimeMillis();
@Override
public void onTick() {
// should not here
assertTrue(false);
}
});
mTimerSupport.pause();
}
use of com.tmall.wireless.tangram.support.TimerSupport.OnTickListener in project Tangram-Android by alibaba.
the class RxTimer method stop.
@Override
public void stop() {
for (Map.Entry<OnTickListener, Disposable> entry : tickCache.entrySet()) {
Disposable disposable = entry.getValue();
disposable.dispose();
}
tickCache.clear();
}
Aggregations