Chromium Code Reviews| Index: tracing/tracing/metrics/webrtc/webrtc_rendering_metric_test.html |
| diff --git a/tracing/tracing/metrics/webrtc/webrtc_rendering_metric_test.html b/tracing/tracing/metrics/webrtc/webrtc_rendering_metric_test.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7ac8d9da7b08dcc49df0c3ee886457179ebceca7 |
| --- /dev/null |
| +++ b/tracing/tracing/metrics/webrtc/webrtc_rendering_metric_test.html |
| @@ -0,0 +1,73 @@ |
| +<!DOCTYPE html> |
| +<!-- |
| +Copyright 2016 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/webrtc/webrtc_rendering_metric.html"> |
| +<link rel="import" href="/tracing/model/slice_group.html"> |
| +<link rel="import" href="/tracing/value/histogram.html"> |
| +<link rel="import" href="/tracing/value/histogram_set.html"> |
| + |
| +<script> |
| +'use strict'; |
| + |
| +tr.b.unittest.testSuite(function() { |
| + const FAKE_EVENTS = [ |
| + [1663780195583, 1663780212249], |
| + [1663780212249, 1663780228915], |
| + [1663780228915, 1663780245581], |
| + [1663780245581, 1663780262247], |
| + [1663780262247, 1663780278913], |
| + [1663780278913, 1663780295579], |
| + [1663780295579, 1663780312245], |
| + [1663780312245, 1663780328911], |
| + [1663780328911, 1663780345577], |
| + [1663780345577, 1663780362243], |
| + [1663780362243, 1663780378909], |
| + [1663780378909, 1663780395575], |
| + [1663780395575, 1663780412241], |
| + [1663780412241, 1663780428907], |
| + [1663780428907, 1663780445573], |
| + ].map(eventFromPair); |
| + |
| + function eventFromPair(pair) { |
| + return { |
| + title: 'WebMediaPlayerMS::UpdateCurrentFrame', |
| + args: { |
| + 'Ideal Render Instant': pair[0], |
| + 'Actual Render Begin': pair[1], |
| + 'Actual Render End': 0, |
| + 'Serial': 0, |
| + } |
| + }; |
| + } |
| + |
| + function runWebrtcRenderingMetric() { |
| + let values = new tr.v.HistogramSet(); |
| + let model = tr.c.TestUtils.newModelWithEvents([FAKE_EVENTS]); |
|
ehmaldonado_chromium
2017/02/24 19:09:48
When I try to test this, I get this error. Am I do
benjhayden
2017/02/24 22:43:37
This works for me:
let model = tr.c.TestUtils.
ehmaldonado_chromium
2017/02/24 23:06:17
After fixing those errors, it doesn't seem to be p
benjhayden
2017/02/24 23:44:40
It would be best if the test used a real Model in
ehmaldonado_chromium
2017/02/24 23:54:33
Yes, of course. This is just for testing while I g
|
| + tr.metrics.webrtc.webrtcRenderingMetric(values, model); |
| + return values; |
| + } |
| + |
| + test('driftTime', function() { |
| + const expectedDriftTime = [15585, 30917, 29583, 23915, 17913, 16911, 15909]; |
| + let values = runWebrtcRenderingMetric(); |
| + let driftTime = values.getHistogramNamed('WebRTCRendering_drift_time'); |
| + assert.closeTo(driftTime.running.sum, |
| + tr.b.Statistics.sum(expectedDriftTime)); |
| + assert.closeTo(driftTime.average, tr.b.Statistics.mean(expectedDriftTime)); |
| + assert.closeTo(driftTime.variance, |
| + tr.b.Statistics.variance(expectedDriftTime)); |
| + }); |
| + |
| + test('percentBadlyOutOfSync', function() { |
| + let values = runWebrtcRenderingMetric(); |
| + let prcentBadlyOutOfSync = |
| + values.getHistogramNamed('WebRTCRendering_percent_badly_out_of_sync'); |
| + }); |
| +}); |
| +</script> |