Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: tracing/tracing/metrics/media_metric_test.html

Issue 2996233004: Port a media metric to TBMv2 (Closed)
Patch Set: Throw error if multiple media elements Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tracing/tracing/metrics/media_metric.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/metrics/media_metric_test.html
diff --git a/tracing/tracing/metrics/media_metric_test.html b/tracing/tracing/metrics/media_metric_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..64ea02b4b2ea74c171096660d8a55d7b914f8704
--- /dev/null
+++ b/tracing/tracing/metrics/media_metric_test.html
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<!--
+Copyright 2017 The Chromium Authors. All rights reserved.
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+-->
+
+<link rel="import" href="/tracing/core/test_utils.html">
+<link rel="import" href="/tracing/extras/importer/trace_event_importer.html">
+<link rel="import" href="/tracing/metrics/media_metric.html">
+<link rel="import" href="/tracing/value/histogram_set.html">
+
+<script>
+'use strict';
+
+tr.b.unittest.testSuite(function() {
+ function makeModel(events) {
+ return tr.c.TestUtils.newModelWithEvents([events]);
+ }
+
+ test('mediaMetric_noData', function() {
+ const histograms = new tr.v.HistogramSet();
+ const events = [
+ {name: 'a', args: {}, pid: 52, ts: 524, cat: 'foo', tid: 53, ph: 'B'},
+ {name: 'a', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'B'}
+ ];
+ tr.metrics.mediaMetric(histograms, makeModel(events));
+ assert.lengthOf(histograms, 0);
+ });
+
+ test('mediaMetric_videoTimeToPlay', function() {
+ const histograms = new tr.v.HistogramSet();
+ const events = [
+ {name: 'WebMediaPlayerImpl::DoLoad', args: {},
+ pid: 52, ts: 524, cat: 'media', tid: 1, ph: 'X'},
+ {name: 'VideoRendererImpl::Render', args: {},
+ pid: 52, ts: 560, cat: 'media', tid: 53, ph: 'X'},
+ {name: 'VideoRendererImpl::Render', args: {},
+ pid: 52, ts: 580, cat: 'media', tid: 53, ph: 'X'},
+ {name: 'thread_name', args: {name: 'CrRendererMain'},
+ pid: 52, ts: 0, cat: '__metadata', tid: 1, ph: 'M'},
+ {name: 'thread_name', args: {name: 'Compositor'},
+ pid: 52, ts: 0, cat: '__metadata', tid: 53, ph: 'M'},
+ ];
+ tr.metrics.mediaMetric(histograms, makeModel(events));
+
+ assert.isDefined(histograms.getHistogramNamed('time_to_video_play'));
+ const ttpValue = histograms.getHistogramNamed('time_to_video_play');
+ const ttpStatistics = ttpValue.running;
+ assert.strictEqual(ttpStatistics.count, 1);
+ assert.closeTo(ttpStatistics.mean, 0.036, 1e-5);
+ assert.closeTo(ttpStatistics.max, 0.036, 1e-5);
+ });
+
+ test('mediaMetric_audioTimeToPlay', function() {
+ const histograms = new tr.v.HistogramSet();
+ const events = [
+ {name: 'thread_name', args: {name: 'CrRendererMain'},
+ pid: 52, ts: 0, cat: '__metadata', tid: 1, ph: 'M'},
+ {name: 'thread_name', args: {name: 'AudioOutputDevice'},
+ pid: 52, ts: 0, cat: '__metadata', tid: 53, ph: 'M'},
+ {name: 'WebMediaPlayerImpl::DoLoad', args: {},
+ pid: 52, ts: 1234, cat: 'media', tid: 1, ph: 'X'},
+ {name: 'AudioRendererImpl::Render', args: {},
+ pid: 52, ts: 4321, cat: 'media', tid: 53, ph: 'X'},
+ ];
+ tr.metrics.mediaMetric(histograms, makeModel(events));
+
+ assert.isDefined(histograms.getHistogramNamed('time_to_audio_play'));
+ const ttpValue = histograms.getHistogramNamed('time_to_audio_play');
+ const ttpStatistics = ttpValue.running;
+ assert.strictEqual(ttpStatistics.count, 1);
+ assert.closeTo(ttpStatistics.mean, 3.087, 1e-5);
+ assert.closeTo(ttpStatistics.max, 3.087, 1e-5);
+ });
+});
+</script>
« no previous file with comments | « tracing/tracing/metrics/media_metric.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698