| <!DOCTYPE html> |
| <!-- |
| Copyright (c) 2013 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/measure/measure.html"> |
| <link rel="import" href="/tracing/model/model.html"> |
| |
| <script> |
| 'use strict'; |
| |
| tr.b.unittest.testSuite(function() { |
| var AsyncSlice = tr.model.AsyncSlice; |
| var MeasureAsyncSlice = tr.e.measure.MeasureAsyncSlice; |
| |
| test('basic', function() { |
| var s = new MeasureAsyncSlice( |
| 'blink.user_timing', 'createImports', 7, 0, {}); |
| s.duration = 100; |
| |
| assert.equal(AsyncSlice.getConstructor( |
| 'blink.user_timing', 'createImports'), |
| MeasureAsyncSlice); |
| assert.equal(s.viewSubGroupTitle, 'Ungrouped Measure'); |
| }); |
| |
| test('import', function() { |
| var events = [ |
| {name: 'createImports', args: {}, pid: 1, ts: 100, |
| cat: 'blink.user_timing', tid: 2, ph: 'b', id: 71}, |
| {name: 'createImports', args: {}, pid: 1, ts: 200, |
| cat: 'blink.user_timing', tid: 2, ph: 'e', id: 71} |
| ]; |
| var m = tr.c.TestUtils.newModelWithEvents([events]); |
| var t2 = m.getOrCreateProcess(1).getOrCreateThread(2); |
| assert.equal(t2.asyncSliceGroup.length, 1); |
| assert.instanceOf(t2.asyncSliceGroup.slices[0], MeasureAsyncSlice); |
| }); |
| |
| test('groupMeasureAsyncSlice', function() { |
| var events = [ |
| {name: 'createImports', args: {}, pid: 1, ts: 100, |
| cat: 'blink.user_timing', tid: 2, ph: 'b', id: 71}, |
| {name: 'createImports', args: {}, pid: 1, ts: 200, |
| cat: 'blink.user_timing', tid: 2, ph: 'e', id: 71}, |
| {name: 'runAutoClosers', args: {}, pid: 1, ts: 210, |
| cat: 'blink.user_timing', tid: 2, ph: 'b', id: 72}, |
| {name: 'runAutoClosers', args: {}, pid: 1, ts: 310, |
| cat: 'blink.user_timing', tid: 2, ph: 'e', id: 72} |
| ]; |
| var m = tr.c.TestUtils.newModelWithEvents([events]); |
| var t2 = m.getOrCreateProcess(1).getOrCreateThread(2); |
| assert.equal(t2.asyncSliceGroup.length, 2); |
| assert.equal(t2.asyncSliceGroup.slices[0].title, 'createImports'); |
| assert.equal(t2.asyncSliceGroup.slices[1].title, 'runAutoClosers'); |
| assert.instanceOf(t2.asyncSliceGroup.slices[0], MeasureAsyncSlice); |
| assert.instanceOf(t2.asyncSliceGroup.slices[1], MeasureAsyncSlice); |
| }); |
| |
| }); |
| </script> |