Beispiel #1
0
 def test_PlayerNeverEntersAnyCommBreaks(self):
     # Setup
     when(self.player).isPlaying().thenReturn(True)
     when(self.program).getCommercials().thenReturn([CommercialBreak(100, 200), CommercialBreak(600, 700)])
     when(self.player).getTime().thenReturn(500)
     
     # Test
     skipper = TrackingCommercialSkipper(self.player, self.program, self.translator, self.settings)
     skipper.onPlayBackStarted()
     time.sleep(2)
     when(self.player).isPlaying().thenReturn(False)
     skipper.onPlayBackStopped()
     
     # Verify
     verify(self.player, times(0)).seekTime(any())
Beispiel #2
0
 def test_RecordingWithNoCommBreaksDoesNothing(self):
     # Setup
     when(self.player).isPlaying().thenReturn(True)
     when(self.program).getCommercials().thenReturn([])
     when(self.player).getTime().thenReturn(500)
     
     # Test
     skipper = TrackingCommercialSkipper(self.player, self.program, self.translator, self.settings)
     skipper.onPlayBackStarted()
     time.sleep(1)
     when(self.player).isPlaying().thenReturn(False)
     skipper.onPlayBackStopped()
     
     # Verify
     verify(self.player, times(0)).seekTime(any())
Beispiel #3
0
 def goPlayRecording(self):
     program=self.recordings[self.coverFlow.getSelectedPosition()]
     
     if self.settings.getBoolean('streaming_enabled'):
         if not self.canStream():
             return 
         p = StreamingPlayer(program=program, **to_kwargs(self, ['settings', 'mythThumbnailCache', 'translator', 'platform']))
         p.playRecording(NoOpCommercialSkipper())
     else:    
         p = MountedPlayer(program=program, **to_kwargs(self, ['mythThumbnailCache', 'translator', 'platform']))
         p.playRecording(TrackingCommercialSkipper(p, program, self.translator))
     del p
Beispiel #4
0
    def test_PlayerSkippingAroundWhenEntersCommBreakDoesntSkipCommercial(self):
        # Setup
        when(self.player).isPlaying().thenReturn(True)
        when(self.program).getCommercials().thenReturn(
            [CommercialBreak(500, 600)])

        # close to beginning = within 2 secs from start of commercial
        when(self.player).getTime().thenReturn(501).thenReturn(502).thenReturn(
            504).thenReturn(505)

        # mock a valid tracker history
        trackerHistory = []
        for x in range(499, 500):
            trackerHistory.append(TrackerSample(time.time() + (x - 499), x))
        when(self.tracker).getHistory(any()).thenReturn(trackerHistory)

        # Test
        skipper = TrackingCommercialSkipper(self.player, self.program,
                                            self.translator)
        skipper.onPlayBackStarted()
        time.sleep(1)
        when(self.player).isPlaying().thenReturn(False)
        skipper.onPlayBackStopped()

        # Verify
        verify(self.player, times(0)).seekTime(any())
Beispiel #5
0
 def test_PlayerSkippingAroundWhenEntersCommBreakDoesntSkipCommercial(self):
     # Setup
     when(self.player).isPlaying().thenReturn(True)
     when(self.program).getCommercials().thenReturn([CommercialBreak(500, 600)])
     
     # close to beginning = within 2 secs from start of commercial
     when(self.player).getTime().thenReturn(501).thenReturn(502).thenReturn(504).thenReturn(505)
     
     # mock a valid tracker history
     trackerHistory = []
     for x in range(499, 500):
         trackerHistory.append(TrackerSample(time.time() + (x - 499), x))
     when(self.tracker).getHistory(any()).thenReturn(trackerHistory)
     
     # Test
     skipper = TrackingCommercialSkipper(self.player, self.program, self.translator, self.settings)
     skipper.onPlayBackStarted()
     time.sleep(1)
     when(self.player).isPlaying().thenReturn(False)
     skipper.onPlayBackStopped()
     
     # Verify
     verify(self.player, times(0)).seekTime(any())        
Beispiel #6
0
 def test_PlayerEntersCommBreakCloseToBeginningSkipsCommercial(self):
     # Setup
     when(self.player).isPlaying().thenReturn(True)
     when(self.program).getCommercials().thenReturn([CommercialBreak(500, 2500)])
     
     # close to beginning = within 2 secs from start of commercial
     when(self.player).getTime().thenReturn(501).thenReturn(2501)
     
     # mock a valid tracker history
     trackerHistory = []
     for x in range(490, 501):
         trackerHistory.append(TrackerSample(time.time() + x, x))
     when(self.tracker).getHistory(any()).thenReturn(trackerHistory)
     
     # Test
     skipper = TrackingCommercialSkipper(self.player, self.program, self.translator)
     skipper.onPlayBackStarted()
     time.sleep(1)
     when(self.player).isPlaying().thenReturn(False)
     skipper.onPlayBackStopped()
     
     # Verify
     verify(self.player, times(1)).seekTime(any())
Beispiel #7
0
 def playWithCommSkip(self):
     log.debug("Playing with skip %s .." % safe_str(self.program.title()))
     deps = to_kwargs(self, ['program', 'mythThumbnailCache', 'translator', 'settings', 'platform'])
     
     if self.streaming:
         if not self.canStream():  
             return
         # Play via myth://
         p = StreamingPlayer(**deps)
         p.playRecording(NoOpCommercialSkipper(p, self.program, self.translator))
     else:
         # Play via local fs
         p = MountedPlayer(**deps)
         p.playRecording(TrackingCommercialSkipper(p, self.program, self.translator))
         del p
Beispiel #8
0
    def test_RecordingWithNoCommBreaksDoesNothing(self):
        # Setup
        when(self.player).isPlaying().thenReturn(True)
        when(self.program).getCommercials().thenReturn([])
        when(self.player).getTime().thenReturn(500)

        # Test
        skipper = TrackingCommercialSkipper(self.player, self.program,
                                            self.translator)
        skipper.onPlayBackStarted()
        time.sleep(1)
        when(self.player).isPlaying().thenReturn(False)
        skipper.onPlayBackStopped()

        # Verify
        verify(self.player, times(0)).seekTime(any())
Beispiel #9
0
    def test_PlayerNeverEntersAnyCommBreaks(self):
        # Setup
        when(self.player).isPlaying().thenReturn(True)
        when(self.program).getCommercials().thenReturn(
            [CommercialBreak(100, 200),
             CommercialBreak(600, 700)])
        when(self.player).getTime().thenReturn(500)

        # Test
        skipper = TrackingCommercialSkipper(self.player, self.program,
                                            self.translator)
        skipper.onPlayBackStarted()
        time.sleep(2)
        when(self.player).isPlaying().thenReturn(False)
        skipper.onPlayBackStopped()

        # Verify
        verify(self.player, times(0)).seekTime(any())