@Test public void startTracking_whenRunning_shouldScheduleSelf() { subject.startRepeating(100); reset(mockHandler); subject.run(); verify(mockHandler).postDelayed(eq(subject), eq(100l)); }
@Test public void run_whenNotRunning_shouldNotSchedule() { subject.stop(); reset(mockHandler); subject.run(); verifyZeroInteractions(mockHandler); }
@Test public void start_whenRunning_shouldNotScheduleAndRunShouldScheduleWithNewInterval() { subject.startRepeating(100l); reset(mockHandler); subject.startRepeating(200l); verifyZeroInteractions(mockHandler); subject.run(); verify(mockHandler).postDelayed(eq(subject), eq(200l)); }
@Test public void stopTracking_whenRunning_shouldPreventNextScheduling() { subject.startRepeating(100l); verify(mockHandler).post(eq(subject)); subject.run(); verify(mockHandler).postDelayed(eq(subject), eq(100l)); reset(mockHandler); subject.stop(); subject.run(); verifyZeroInteractions(mockHandler); }