2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Scrubbing performance test for <video>.
8 Measures the times to scrub video and audio files. Scrubbing is simulated by
9 having consecutive small seeks performed. The test measures both forward and
19 # HTML test path; relative to src/chrome/test/data.
20 _TEST_HTML_PATH = os.path.join('media', 'html', 'media_scrub.html')
22 # Path under data path for test files.
23 _TEST_MEDIA_PATH = os.path.join('media', 'avperf')
25 # The media files used for testing.
26 _TEST_MEDIA = [os.path.join('tulip', name) for name in
27 ['tulip2.webm', 'tulip2.wav', 'tulip2.ogv', 'tulip2.ogg',
28 'tulip2.mp4', 'tulip2.mp3', 'tulip2.m4a']]
31 class MediaScrubPerfTest(pyauto.PyUITest):
32 """PyAuto test container. See file doc string for more information."""
34 def testMediaScrubPerformance(self):
35 """Launches HTML test which runs the scrub test and records performance."""
36 self.NavigateToURL(self.GetFileURLForDataPath(_TEST_HTML_PATH))
38 for media in _TEST_MEDIA:
39 file_name = self.GetFileURLForDataPath(
40 os.path.join(_TEST_MEDIA_PATH, media))
42 # Some tests take more than the default PyAuto calls timeout, so we start
43 # each test and wait until 'testDone' flag is set by the test.
44 self.CallJavascriptFunc('startTest', [file_name])
46 if not self.WaitUntil(self.GetDOMValue, args=['testDone'],
47 retry_sleep=5, timeout=180, debug=False):
48 error_msg = 'Scrubbing tests timed out.'
50 error_msg = self.GetDOMValue('errorMsg')
52 self.fail('Error while running the test: %s' % error_msg)
54 forward_scrub_time = float(self.GetDOMValue('forwardScrubTime'))
55 backward_scrub_time = float(self.GetDOMValue('backwardScrubTime'))
56 mixed_scrub_time = float(self.GetDOMValue('mixedScrubTime'))
57 pyauto_utils.PrintPerfResult('scrubbing', os.path.basename(file_name) +
58 '_forward', forward_scrub_time, 'ms')
59 pyauto_utils.PrintPerfResult('scrubbing', os.path.basename(file_name) +
60 '_backward', backward_scrub_time, 'ms')
61 pyauto_utils.PrintPerfResult('scrubbing', os.path.basename(file_name) +
62 '_mixed', mixed_scrub_time, 'ms')
65 if __name__ == '__main__':