OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import sys | 5 import sys |
6 | 6 |
7 from telemetry import test | 7 from telemetry import test |
8 from telemetry.page import page_measurement | 8 from telemetry.page import page_measurement |
9 | 9 |
10 from measurements import media | 10 from measurements import media |
11 | 11 |
12 | 12 |
13 class MSEMeasurement(page_measurement.PageMeasurement): | 13 class MSEMeasurement(page_measurement.PageMeasurement): |
14 def MeasurePage(self, page, tab, results): | 14 def MeasurePage(self, page, tab, results): |
15 media_metric = tab.EvaluateJavaScript('window.__testMetrics') | 15 media_metric = tab.EvaluateJavaScript('window.__testMetrics') |
16 trace = media_metric['id'] | 16 trace = media_metric['id'] if 'id' in media_metric else None |
17 metrics = media_metric['metrics'] | 17 metrics = media_metric['metrics'] if 'metrics' in media_metric else [] |
18 for m in metrics: | 18 for m in metrics: |
19 if isinstance(metrics[m], list): | 19 if isinstance(metrics[m], list): |
20 values = [float(v) for v in metrics[m]] | 20 values = [float(v) for v in metrics[m]] |
21 else: | 21 else: |
22 values = float(metrics[m]) | 22 values = float(metrics[m]) |
23 results.Add(trace, 'ms', values, chart_name=m) | 23 results.Add(trace, 'ms', values, chart_name=m) |
24 | 24 |
25 | 25 |
26 class Media(test.Test): | 26 class Media(test.Test): |
27 """Obtains media metrics for key user scenarios.""" | 27 """Obtains media metrics for key user scenarios.""" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 def CustomizeBrowserOptions(self, options): | 64 def CustomizeBrowserOptions(self, options): |
65 # Needed to run media actions in JS in Android. | 65 # Needed to run media actions in JS in Android. |
66 options.AppendExtraBrowserArgs( | 66 options.AppendExtraBrowserArgs( |
67 '--disable-gesture-requirement-for-media-playback') | 67 '--disable-gesture-requirement-for-media-playback') |
68 | 68 |
69 class MediaSourceExtensions(test.Test): | 69 class MediaSourceExtensions(test.Test): |
70 """Obtains media metrics for key media source extensions functions.""" | 70 """Obtains media metrics for key media source extensions functions.""" |
71 test = media.Media | 71 test = media.Media |
72 # Disable MSE media-tests on Android and linux: crbug/329691 | 72 # Disable MSE media-tests on Android and linux: crbug/329691 |
73 # Disable MSE tests on windows 8 crbug.com/330910 | 73 # Disable MSE tests on windows 8 crbug.com/330910 |
74 enabled = (not sys.platform.startswith('linux') and | |
75 not sys.platform.startswith('win')) | |
76 test = MSEMeasurement | 74 test = MSEMeasurement |
77 page_set = 'page_sets/mse_cases.json' | 75 page_set = 'page_sets/mse_cases.json' |
78 | 76 |
79 def CustomizeBrowserOptions(self, options): | 77 def CustomizeBrowserOptions(self, options): |
80 # Needed to allow XHR requests to return stream objects. | 78 # Needed to allow XHR requests to return stream objects. |
81 options.AppendExtraBrowserArgs( | 79 options.AppendExtraBrowserArgs( |
82 '--enable-experimental-web-platform-features') | 80 ['--enable-experimental-web-platform-features', |
| 81 '--disable-gesture-requirement-for-media-playback']) |
OLD | NEW |