1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 from measurements
import media
7 from telemetry
import benchmark
8 from telemetry
.page
import page_test
9 from telemetry
.value
import list_of_scalar_values
10 from telemetry
.value
import scalar
13 class _MSEMeasurement(page_test
.PageTest
):
14 def ValidateAndMeasurePage(self
, page
, tab
, results
):
15 media_metric
= tab
.EvaluateJavaScript('window.__testMetrics')
16 trace
= media_metric
['id'] if 'id' in media_metric
else None
17 metrics
= media_metric
['metrics'] if 'metrics' in media_metric
else []
19 trace_name
= '%s.%s' % (m
, trace
)
20 if isinstance(metrics
[m
], list):
21 results
.AddValue(list_of_scalar_values
.ListOfScalarValues(
22 results
.current_page
, trace_name
, units
='ms',
23 values
=[float(v
) for v
in metrics
[m
]],
27 results
.AddValue(scalar
.ScalarValue(
28 results
.current_page
, trace_name
, units
='ms',
29 value
=float(metrics
[m
]), important
=True))
32 @benchmark.Disabled('android')
33 class Media(benchmark
.Benchmark
):
34 """Obtains media metrics for key user scenarios."""
36 page_set
= page_sets
.ToughVideoCasesPageSet
40 class MediaNetworkSimulation(benchmark
.Benchmark
):
41 """Obtains media metrics under different network simulations."""
43 page_set
= page_sets
.MediaCnsCasesPageSet
46 @benchmark.Enabled('android')
47 @benchmark.Disabled('l')
48 class MediaAndroid(benchmark
.Benchmark
):
49 """Obtains media metrics for key user scenarios on Android."""
52 page_set
= page_sets
.ToughVideoCasesPageSet
53 # Exclude is_4k and 50 fps media files (garden* & crowd*).
54 options
= {'page_label_filter_exclude': 'is_4k,is_50fps'}
57 @benchmark.Enabled('chromeos')
58 class MediaChromeOS4kOnly(benchmark
.Benchmark
):
59 """Benchmark for media performance on ChromeOS using only is_4k test content.
62 tag
= 'chromeOS4kOnly'
63 page_set
= page_sets
.ToughVideoCasesPageSet
65 'page_label_filter': 'is_4k',
66 # Exclude is_50fps test files: crbug/331816
67 'page_label_filter_exclude': 'is_50fps'
71 @benchmark.Enabled('chromeos')
72 class MediaChromeOS(benchmark
.Benchmark
):
73 """Benchmark for media performance on all ChromeOS platforms.
75 This benchmark does not run is_4k content, there's a separate benchmark for
80 page_set
= page_sets
.ToughVideoCasesPageSet
81 # Exclude is_50fps test files: crbug/331816
82 options
= {'page_label_filter_exclude': 'is_4k,is_50fps'}
85 class MediaSourceExtensions(benchmark
.Benchmark
):
86 """Obtains media metrics for key media source extensions functions."""
87 test
= _MSEMeasurement
88 page_set
= page_sets
.MseCasesPageSet
90 def CustomizeBrowserOptions(self
, options
):
91 # Needed to allow XHR requests to return stream objects.
92 options
.AppendExtraBrowserArgs(
93 ['--enable-experimental-web-platform-features',
94 '--disable-gesture-requirement-for-media-playback'])