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.assertLessEqual(tracker.getLastPosition(), playDuration) self.assertLess(playDuration - 1, tracker.getLastPosition()) for i in range(1, PositionTracker.HISTORY_SECS): self.assertLessEqual(i * (1000 / 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.assertLessEqual(tracker.getLastPosition(), playDuration) self.assertLess(playDuration - 1, tracker.getLastPosition()) for i in range(1, PositionTracker.HISTORY_SECS): self.assertLessEqual(i * (1000/SLEEP_MILLIS), len(tracker.getHistory(i)))
def test_getHistory_howFarBack_bounds(self): player = Mock() tracker = PositionTracker(player) self.assertEqual(0, len(tracker.getHistory(2))) self.assertEqual(0, len(tracker.getHistory(0))) self.assertEqual(0, len(tracker.getHistory(999)))
def test_constructor(self): player = Mock() tracker = PositionTracker(player) self.assertEqual(0.0, tracker.getLastPosition()) self.assertEqual(0, len(tracker.getHistory(2)))