OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2011 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 """Simple test for HTML5 media tag to measure playback time. | |
7 | |
8 This PyAuto powered script plays media (video or audio) files using the HTML5 | |
9 tag embedded in an HTML file (specified in the GetPlayerHTMLFileName() method) | |
10 and measures simple playback time. The parameters needed to run this test are | |
11 passed in the form of environment variables (such as the number of runs). | |
12 media_perf_runner.py is used for generating these variables | |
13 (PyAuto does not support direct parameters). | |
14 """ | |
15 import os | |
16 import time | |
17 | |
18 from media_test_base import MediaTestBase | |
19 from media_test_env_names import MediaTestEnvNames | |
20 import pyauto_media | |
21 from ui_perf_test_utils import UIPerfTestUtils | |
22 | |
23 | |
24 class MediaPlaybackTimeTest(MediaTestBase): | |
25 """Test class to record playback time.""" | |
26 | |
27 def testHTML5MediaTag(self): | |
28 """Test the HTML5 media tag.""" | |
29 MediaTestBase.ExecuteTest(self) | |
30 | |
31 def PostAllRunsProcess(self): | |
32 """A method to execute after all runs. | |
33 | |
34 This is to print out the playback time data. | |
35 """ | |
36 self.media_filename_nickname = os.getenv( | |
37 MediaTestEnvNames.MEDIA_FILENAME_NICKNAME_ENV_NAME, | |
38 self.media_filename) | |
39 # Print out playback time for each run. | |
40 trace = 't' | |
41 if self.reference_build: | |
42 trace += '_ref' | |
43 print UIPerfTestUtils.GetResultStringForPerfBot( | |
44 measurement='playback', modifier='', | |
45 trace=trace, values=self.times[1:], | |
46 units='sec') | |
47 | |
48 def PostEachRunProcess(self, unused_run_counter): | |
49 """A method to execute after each run. | |
50 | |
51 This is an overridden method to calculate and store playback time for each | |
52 run. | |
53 | |
54 Args: | |
55 unused_run_counter: counter for each run. | |
56 """ | |
57 if hasattr(self, 'start'): | |
58 self.times.append(time.time() - self.start) | |
59 | |
60 if __name__ == '__main__': | |
61 pyauto_media.Main() | |
OLD | NEW |