| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 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. | |
| 5 | |
| 6 """Scrubbing performance test for <video>. | |
| 7 | |
| 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 | |
| 10 backward scrubbing. | |
| 11 """ | |
| 12 | |
| 13 import os | |
| 14 | |
| 15 import pyauto_media | |
| 16 import pyauto_utils | |
| 17 import pyauto | |
| 18 | |
| 19 # HTML test path; relative to src/chrome/test/data. | |
| 20 _TEST_HTML_PATH = os.path.join('media', 'html', 'media_scrub.html') | |
| 21 | |
| 22 # Path under data path for test files. | |
| 23 _TEST_MEDIA_PATH = os.path.join('media', 'avperf') | |
| 24 | |
| 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']] | |
| 29 | |
| 30 | |
| 31 class MediaScrubPerfTest(pyauto.PyUITest): | |
| 32 """PyAuto test container. See file doc string for more information.""" | |
| 33 | |
| 34 def testMediaScrubPerformance(self): | |
| 35 """Launches HTML test which runs the scrub test and records performance.""" | |
| 36 self.NavigateToURL(self.GetFileURLForDataPath(_TEST_HTML_PATH)) | |
| 37 | |
| 38 for media in _TEST_MEDIA: | |
| 39 file_name = self.GetFileURLForDataPath( | |
| 40 os.path.join(_TEST_MEDIA_PATH, media)) | |
| 41 | |
| 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]) | |
| 45 | |
| 46 if not self.WaitUntil(self.GetDOMValue, args=['testDone'], | |
| 47 retry_sleep=5, timeout=180, debug=False): | |
| 48 error_msg = 'Scrubbing tests timed out.' | |
| 49 else: | |
| 50 error_msg = self.GetDOMValue('errorMsg') | |
| 51 if error_msg: | |
| 52 self.fail('Error while running the test: %s' % error_msg) | |
| 53 | |
| 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') | |
| 63 | |
| 64 | |
| 65 if __name__ == '__main__': | |
| 66 pyauto_media.Main() | |
| OLD | NEW |