| <!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/metrics/system_health/webview_startup_metric.html"> |
| <link rel="import" href="/tracing/value/value_set.html"> |
| |
| <script> |
| 'use strict'; |
| |
| function makeTestModel() { |
| return tr.c.TestUtils.newModel(function(model) { |
| var mainThread = model.getOrCreateProcess(1).getOrCreateThread(2); |
| mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ |
| cat: 'webview', |
| title: 'WebViewStartupInterval', |
| start: 200, |
| duration: 42.0, |
| cpuStart: 150, |
| cpuDuration: 32.0 |
| })); |
| mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ |
| cat: 'webview', |
| title: 'WebViewBlankUrlLoadInterval', |
| start: 250, |
| duration: 27.0, |
| cpuStart: 190, |
| cpuDuration: 17.0 |
| })); |
| }); |
| } |
| |
| tr.b.unittest.testSuite(function() { |
| test('webviewStartupMetric', function() { |
| var values = new tr.v.ValueSet(); |
| tr.metrics.sh.webviewStartupMetric(values, makeTestModel()); |
| assert.closeTo(42, values.getValuesNamed( |
| 'webview_startup_wall_time')[0].average, 1e-2); |
| assert.closeTo(32, values.getValuesNamed( |
| 'webview_startup_cpu_time')[0].average, 1e-2); |
| assert.closeTo(27, values.getValuesNamed( |
| 'webview_url_load_wall_time')[0].average, 1e-2); |
| assert.closeTo(17, values.getValuesNamed( |
| 'webview_url_load_cpu_time')[0].average, 1e-2); |
| }); |
| }); |
| </script> |