def test_functional(self): # Setup playDuration = 5 p = MockPlayer(playDuration) # Test tracker = PositionTracker(p) tracker.onPlayBackStarted() time.sleep(playDuration) tracker.onPlayBackStopped() # HACK: Python thread wackyness..maybe upgrade to 2.5 will fix it. # Waiting for thread to exit time.sleep(0.5) # Verify self.assertTrue(tracker.getLastPosition() <= playDuration) self.assertTrue((playDuration - 1) < tracker.getLastPosition()) for i in range(1, PositionTracker.HISTORY_SECS): self.assertTrue( i * (1000 / player.SLEEP_MILLIS) <= len(tracker.getHistory(i)))
def test_functional(self): # Setup playDuration = 5 p = MockPlayer(playDuration) # Test tracker = PositionTracker(p) tracker.onPlayBackStarted() time.sleep(playDuration) tracker.onPlayBackStopped() # HACK: Python thread wackyness..maybe upgrade to 2.5 will fix it. # Waiting for thread to exit time.sleep(0.5) # Verify self.assertTrue(tracker.getLastPosition() <= playDuration) self.assertTrue((playDuration - 1) < tracker.getLastPosition()) for i in range(1, PositionTracker.HISTORY_SECS): self.assertTrue(i * (1000/player.SLEEP_MILLIS) <= len(tracker.getHistory(i)))
def test_getHistory_howFarBack_bounds(self): player = Mock() tracker = PositionTracker(player) self.assertTrue(len(tracker.getHistory(2)) == 0) self.assertTrue(len(tracker.getHistory(0)) == 0) self.assertTrue(len(tracker.getHistory(999)) == 0)
def test_constructor(self): player = Mock() tracker = PositionTracker(player) self.assertEquals(0.0, tracker.getLastPosition()) self.assertTrue(len(tracker.getHistory(2)) == 0)