зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1299756 - VideoPuppeteer: Use played ranges in determining time remaining. Relax playback done check. r=maja_zf
The VideoPuppeteer now uses played ranges where possible to calculate the remaining time. It will also use the played ranges to determine the expected duration where possible. This is more accurate than using the time when the tests first poll the video. The first poll time was previously self._start_time, but I've renamed this to self._first_seen_time, to reduce ambiguity -- the video may have started playing before this time. The playback_done function has had it's remaining time check relaxed. Previously it was possible to skip over the window where a video would be considered complete, that window is now expanded so that if the start threshold is passed the video is considered played. A concrete example: the tests could play a 90 second video, but the duration of the test is set to 60 so only part of the video need be played back before the test completes. If a 1 second interval was used in the tests there would be a window between 59 to 61 seconds during which if the video were polled it would be considered complete. However, due to latency polling may not take place in this window, leading to racy fails. Now the tests will consider any point beyond 59 seconds to be complete. MozReview-Commit-ID: J6DpqCbZxUg --HG-- extra : rebase_source : 7990e4eee0bce30718b875f652c7148110cd4c3f
This commit is contained in:
Родитель
f3afe526e9
Коммит
5c7d75495a
|
@ -67,8 +67,8 @@ class VideoPuppeteer(object):
|
|||
self._set_duration = set_duration
|
||||
self.video = None
|
||||
self.expected_duration = 0
|
||||
self._start_time = 0
|
||||
self._start_wall_time = 0
|
||||
self._first_seen_time = 0
|
||||
self._first_seen_wall_time = 0
|
||||
wait = Wait(self.marionette, timeout=self.timeout)
|
||||
with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
|
||||
self.marionette.navigate(self.test_url)
|
||||
|
@ -96,8 +96,8 @@ class VideoPuppeteer(object):
|
|||
wait = Wait(self, timeout=self.timeout)
|
||||
verbose_until(wait, self, playback_started,
|
||||
"Check if video has played some range")
|
||||
self._start_time = self.current_time
|
||||
self._start_wall_time = clock()
|
||||
self._first_seen_time = self.current_time
|
||||
self._first_seen_wall_time = clock()
|
||||
self.update_expected_duration()
|
||||
|
||||
def update_expected_duration(self):
|
||||
|
@ -115,14 +115,21 @@ class VideoPuppeteer(object):
|
|||
# video, for example), so self.duration is the duration of the main
|
||||
# video.
|
||||
video_duration = self.duration
|
||||
set_duration = self._set_duration
|
||||
# In case video starts at t > 0, adjust target time partial playback
|
||||
if self._set_duration and self._start_time:
|
||||
set_duration += self._start_time
|
||||
if 0 < set_duration < video_duration:
|
||||
self.expected_duration = set_duration
|
||||
# Do our best to figure out where the video started playing
|
||||
played_ranges = self.played
|
||||
if played_ranges.length > 0:
|
||||
# If we have a range we should only have on continuous range
|
||||
assert played_ranges.length == 1
|
||||
start_position = played_ranges.start(0)
|
||||
else:
|
||||
self.expected_duration = video_duration
|
||||
# If we don't have a range we should have a current time
|
||||
start_position = self._first_seen_time
|
||||
# In case video starts at t > 0, adjust target time partial playback
|
||||
remaining_video = video_duration - start_position
|
||||
if 0 < self._set_duration < remaining_video:
|
||||
self.expected_duration = self._set_duration
|
||||
else:
|
||||
self.expected_duration = remaining_video
|
||||
|
||||
def get_debug_lines(self):
|
||||
"""
|
||||
|
@ -171,7 +178,11 @@ class VideoPuppeteer(object):
|
|||
:return: How much time is remaining given the duration of the video
|
||||
and the duration that has been set.
|
||||
"""
|
||||
return self.expected_duration - self.current_time
|
||||
played_ranges = self.played
|
||||
# Playback should be in one range (as tests do not currently seek).
|
||||
assert played_ranges.length == 1
|
||||
played_duration = self.played.end(0) - self.played.start(0)
|
||||
return self.expected_duration - played_duration
|
||||
|
||||
@property
|
||||
def played(self):
|
||||
|
@ -242,8 +253,8 @@ class VideoPuppeteer(object):
|
|||
"""
|
||||
# Note that self.current_time could temporarily refer to a
|
||||
# spliced-in ad
|
||||
elapsed_current_time = self.current_time - self._start_time
|
||||
elapsed_wall_time = clock() - self._start_wall_time
|
||||
elapsed_current_time = self.current_time - self._first_seen_time
|
||||
elapsed_wall_time = clock() - self._first_seen_wall_time
|
||||
return elapsed_wall_time - elapsed_current_time
|
||||
|
||||
def measure_progress(self):
|
||||
|
@ -341,8 +352,7 @@ def playback_done(video):
|
|||
:return: True if we are close enough to the end of playback; False
|
||||
otherwise.
|
||||
"""
|
||||
remaining_time = video.remaining_time
|
||||
if abs(remaining_time) < video.interval:
|
||||
if video.remaining_time < video.interval:
|
||||
return True
|
||||
|
||||
# Check to see if the video has stalled. Accumulate the amount of lag
|
||||
|
|
Загрузка…
Ссылка в новой задаче