blob: e41741c71dad6d37bce303b39c71c959acce6312 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright 2015 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="/extras/chrome/gpu/gpu.html">
<link rel="import" href="/extras/importer/trace_event_importer.html">
<link rel="import" href="/model/model.html">
<script>
'use strict';
tr.b.unittest.testSuite(function() {
var AsyncSlice = tr.model.AsyncSlice;
var GpuAsyncSlice = tr.e.gpu.GpuAsyncSlice;
test('construct', function() {
assert.equal(AsyncSlice.getConstructor('disabled-by-default-gpu.device',
'gpu1'),
GpuAsyncSlice);
assert.equal(AsyncSlice.getConstructor('disabled-by-default-gpu.service',
'gpu2'),
GpuAsyncSlice);
});
test('subgroup', function() {
var s_device = new GpuAsyncSlice('disabled-by-default-gpu.device', 'gpu1',
7, 0, {'channel': 'test_channel1'});
var s_service = new GpuAsyncSlice('disabled-by-default-gpu.service', 'gpu2',
7, 0, {'channel': 'test_channel2'});
assert.equal(s_device.viewSubGroupTitle, 'Device.test_channel1');
assert.equal(s_service.viewSubGroupTitle, 'Service.test_channel2');
});
test('import', function() {
var events = [
{name: 'trace1', args: {}, pid: 1, ts: 100,
cat: 'disabled-by-default-gpu.service', tid: 2, ph: 'b', id: 71},
{name: 'trace1', args: {}, pid: 1, ts: 200,
cat: 'disabled-by-default-gpu.service', tid: 2, ph: 'e', id: 71},
{name: 'trace2', args: {'channel': 'test_channel'}, pid: 1, ts: 100,
cat: 'disabled-by-default-gpu.service', tid: 2, ph: 'b', id: 72},
{name: 'trace2', args: {'channel': 'test_channel'}, pid: 1, ts: 200,
cat: 'disabled-by-default-gpu.service', tid: 2, ph: 'e', id: 72},
{name: 'trace3', args: {'channel': 'test_channel'}, pid: 1, ts: 100,
cat: 'disabled-by-default-gpu.device', tid: 2, ph: 'b', id: 73},
{name: 'trace3', args: {'channel': 'test_channel'}, pid: 1, ts: 200,
cat: 'disabled-by-default-gpu.device', tid: 2, ph: 'e', id: 73}
];
var m = new tr.Model(events);
var t2 = m.getOrCreateProcess(1).getOrCreateThread(2);
assert.equal(t2.asyncSliceGroup.length, 3);
var slice1 = t2.asyncSliceGroup.slices[0];
var slice2 = t2.asyncSliceGroup.slices[1];
var slice3 = t2.asyncSliceGroup.slices[2];
assert.instanceOf(slice1, GpuAsyncSlice);
assert.instanceOf(slice2, GpuAsyncSlice);
assert.instanceOf(slice3, GpuAsyncSlice);
assert.equal(slice1.viewSubGroupTitle, 'trace1');
assert.equal(slice2.viewSubGroupTitle, 'Service.test_channel');
assert.equal(slice3.viewSubGroupTitle, 'Device.test_channel');
});
});
</script>