OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """A framework to run PyAuto HTML media tests. | 7 """A framework to run PyAuto HTML media tests. |
8 | 8 |
9 This PyAuto powered script plays media (video or audio) files (using the HTML5 | 9 This PyAuto powered script plays media (video or audio) files (using the HTML5 |
10 tag embedded in an HTML file). The parameters needed to run this test are | 10 tag embedded in an HTML file). The parameters needed to run this test are |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 a tuple of media_url (with proper query string) and a parameter string, | 67 a tuple of media_url (with proper query string) and a parameter string, |
68 which is used for performance result display. | 68 which is used for performance result display. |
69 """ | 69 """ |
70 # Read environment variables. | 70 # Read environment variables. |
71 player_html_url = os.getenv(MediaTestEnvNames.PLAYER_HTML_URL_ENV_NAME, | 71 player_html_url = os.getenv(MediaTestEnvNames.PLAYER_HTML_URL_ENV_NAME, |
72 'DEFAULT') | 72 'DEFAULT') |
73 player_html_url_nickname = os.getenv( | 73 player_html_url_nickname = os.getenv( |
74 MediaTestEnvNames.PLAYER_HTML_URL_NICKNAME_ENV_NAME, | 74 MediaTestEnvNames.PLAYER_HTML_URL_NICKNAME_ENV_NAME, |
75 self.DEFAULT_PLAYER_HTML_URL_NICKNAME) | 75 self.DEFAULT_PLAYER_HTML_URL_NICKNAME) |
76 extra_nickname = os.getenv(MediaTestEnvNames.EXTRA_NICKNAME_ENV_NAME, '') | 76 extra_nickname = os.getenv(MediaTestEnvNames.EXTRA_NICKNAME_ENV_NAME, '') |
| 77 |
| 78 tag = os.getenv(MediaTestEnvNames.MEDIA_TAG_ENV_NAME, |
| 79 self.DEFAULT_MEDIA_TAG_NAME) |
| 80 query_dictionary = {'tag': tag, 'media': media_filename} |
77 # This parameter tricks the media cache into thinking | 81 # This parameter tricks the media cache into thinking |
78 # it's a new file every time. | 82 # it's a new file every time. |
79 # However, it looks like does not make much difference in | 83 # However, it looks like does not make much difference in |
80 # performance. | 84 # performance. |
81 add_t_parameter = os.getenv( | 85 if os.getenv(MediaTestEnvNames.ADD_T_PARAMETER_ENV_NAME): |
82 MediaTestEnvNames.ADD_T_PARAMETER_ENV_NAME) in ('Y', 'y') | |
83 # Print only playback time data. | |
84 print_only_time = os.getenv( | |
85 MediaTestEnvNames.PRINT_ONLY_TIME_ENV_NAME) in ('Y', 'y') | |
86 tag = os.getenv(MediaTestEnvNames.MEDIA_TAG_ENV_NAME, | |
87 self.DEFAULT_MEDIA_TAG_NAME) | |
88 query_dictionary = {'tag': tag, 'media': media_filename} | |
89 if add_t_parameter: | |
90 query_dictionary['t'] = 'dummy' | 86 query_dictionary['t'] = 'dummy' |
91 query_str = '&'.join( | 87 query_str = '&'.join( |
92 [k + '=' + str(v) for (k, v) in query_dictionary.items()]) | 88 [k + '=' + str(v) for (k, v) in query_dictionary.items()]) |
93 if player_html_url_nickname == self.DEFAULT_PLAYER_HTML_URL_NICKNAME: | 89 if player_html_url_nickname == self.DEFAULT_PLAYER_HTML_URL_NICKNAME: |
94 # Default is local file under DataDir(). | 90 # Default is local file under DataDir(). |
95 file_url = self.GetFileURLForDataPath( | 91 file_url = self.GetFileURLForDataPath( |
96 os.path.join('media', 'html', self.GetPlayerHTMLFileName())) | 92 os.path.join('media', 'html', self.GetPlayerHTMLFileName())) |
97 url = file_url + '?' + query_str | 93 url = file_url + '?' + query_str |
98 else: | 94 else: |
99 url = player_html_url + '?' + query_str | 95 url = player_html_url + '?' + query_str |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 # overridden. | 157 # overridden. |
162 | 158 |
163 def PreAllRunsProcess(self): | 159 def PreAllRunsProcess(self): |
164 """A method to be executed before all runs. | 160 """A method to be executed before all runs. |
165 | 161 |
166 The default behavior is to read parameters for the tests and initialize | 162 The default behavior is to read parameters for the tests and initialize |
167 variables. | 163 variables. |
168 """ | 164 """ |
169 self.media_filename = os.getenv(MediaTestEnvNames.MEDIA_FILENAME_ENV_NAME, | 165 self.media_filename = os.getenv(MediaTestEnvNames.MEDIA_FILENAME_ENV_NAME, |
170 self.DEFAULT_MEDIA_FILENAME) | 166 self.DEFAULT_MEDIA_FILENAME) |
171 self.remove_first_result = ( | 167 self.remove_first_result = os.getenv( |
172 os.getenv(MediaTestEnvNames.REMOVE_FIRST_RESULT_ENV_NAME) | 168 MediaTestEnvNames.REMOVE_FIRST_RESULT_ENV_NAME) |
173 in ('Y', 'y')) | |
174 self.number_of_runs = int(os.getenv(MediaTestEnvNames.N_RUNS_ENV_NAME, | 169 self.number_of_runs = int(os.getenv(MediaTestEnvNames.N_RUNS_ENV_NAME, |
175 self.DEFAULT_NUMBER_OF_RUNS)) | 170 self.DEFAULT_NUMBER_OF_RUNS)) |
176 self.url, self.parameter_str = self._GetMediaURLAndParameterString( | 171 self.url, self.parameter_str = self._GetMediaURLAndParameterString( |
177 self.media_filename) | 172 self.media_filename) |
178 self.times = [] | 173 self.times = [] |
179 | 174 |
180 def PostAllRunsProcess(self): | 175 def PostAllRunsProcess(self): |
181 """A method to execute after all runs. | 176 """A method to execute after all runs. |
182 | 177 |
183 The default behavior is to do nothing | 178 The default behavior is to do nothing |
184 """ | 179 """ |
185 pass | 180 pass |
186 | 181 |
187 def PreEachRunProcess(self, run_counter): | 182 def PreEachRunProcess(self, run_counter): |
188 """A method to execute before each run. | 183 """A method to execute before each run. |
189 | 184 |
190 The default behavior is to record start time. | 185 The default behavior is to record start time. |
191 | 186 |
192 Args: | 187 Args: |
193 run_counter: counter for each run. | 188 run_counter: counter for each run. |
194 """ | 189 """ |
195 self.start = time.time() | 190 self.start = time.time() |
| 191 if os.getenv(MediaTestEnvNames.REFERENCE_BUILD_ENV_NAME): |
| 192 self.current_trace_type = 't_ref' |
196 | 193 |
197 def PostEachRunProcess(self, run_counter): | 194 def PostEachRunProcess(self, run_counter): |
198 """A method to execute after each run. | 195 """A method to execute after each run. |
199 | 196 |
200 The default behavior is to do nothing. | 197 The default behavior is to do nothing. |
201 | 198 |
202 Args: | 199 Args: |
203 run_counter: counter for each run. | 200 run_counter: counter for each run. |
204 """ | 201 """ |
205 pass | 202 pass |
206 | 203 |
207 def GetPlayerHTMLFileName(self): | 204 def GetPlayerHTMLFileName(self): |
208 """A method to get the player HTML file name.""" | 205 """A method to get the player HTML file name.""" |
209 return 'media_playback.html' | 206 return 'media_playback.html' |
210 | 207 |
211 | 208 |
212 if __name__ == '__main__': | 209 if __name__ == '__main__': |
213 pyauto_media.Main() | 210 pyauto_media.Main() |
OLD | NEW |