Example #1
0
    def check_src(self, src_type, url):
        # Why wait to check src until initial ad is done playing?
        # - src attribute in video element is sometimes null during ad playback
        # - many ads still don't use MSE even if main video does
        with self.marionette.using_context('content'):
            youtube = YouTubePuppeteer(self.marionette, url)
            youtube.attempt_ad_skip()
            wait = Wait(youtube,
                        timeout=min(self.max_timeout,
                                    youtube.player_duration * 1.3),
                        interval=1)

            def cond(y):
                return y.video_src.startswith(src_type)

            verbose_until(wait, youtube, cond)
    def test_video_playing_in_one_tab(self):
        with self.marionette.using_context('content'):
            for url in self.video_urls:
                self.logger.info(url)
                youtube = YouTubePuppeteer(self.marionette, url)
                self.logger.info('Expected duration: %s' %
                                 youtube.expected_duration)
                youtube.deactivate_autoplay()

                final_piece = 60
                try:
                    time_left = wait_for_almost_done(youtube,
                                                     final_piece=final_piece)
                except VideoException as e:
                    raise self.failureException(e)
                duration = abs(youtube.expected_duration) + 1
                if duration > 1:
                    self.logger.info('Almost done: %s - %s seconds left.' %
                                     (youtube.movie_id, time_left))
                    if time_left > final_piece:
                        self.marionette.log('time_left greater than '
                                            'final_piece - %s' % time_left,
                                            level='WARNING')
                        self.save_screenshot()
                else:
                    self.marionette.log('Duration close to 0 - %s' % youtube,
                                        level='WARNING')
                    self.save_screenshot()
                try:
                    verbose_until(Wait(youtube,
                                       timeout=max(100, time_left) * 1.3,
                                       interval=1),
                                  youtube,
                                  playback_done)
                except TimeoutException as e:
                    raise self.failureException(e)