blob: 2518a981ac02e35984ddda6b8a5c7cb1f6de6de4 [file] [log] [blame]
<!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="/extras/chrome/cc/input_latency_async_slice.html">
<link rel="import" href="/core/test_utils.html">
<link rel="import" href="/model/model.html">
<link rel="import" href="/model/model_indices.html">
<script>
'use strict';
tr.b.unittest.testSuite(function() {
var newAsyncSliceEx = tr.c.test_utils.newAsyncSliceEx;
var newSliceEx = tr.c.test_utils.newSliceEx;
var newFlowEventEx = tr.c.test_utils.newFlowEventEx;
var newModel = tr.c.test_utils.newModel;
test('matchByType_oldStyle', function() {
var sOuter = newAsyncSliceEx({
title: 'InputLatency',
cat: 'benchmark',
start: 0,
end: 10,
id: '0x100',
isTopLevel: true,
args: {
data: {
INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT: {'time' : 0},
INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT: {time: 10}
}
}
});
var sInner = newAsyncSliceEx({
title: 'InputLatency:GestureScrollUpdate',
cat: 'benchmark',
start: 2,
end: 10,
id: '0x100',
args: {
'step': 'GestureScrollUpdate'
}
});
sOuter.subSlices.push(sInner);
assert.isTrue(sOuter instanceof tr.e.cc.InputLatencyAsyncSlice);
assert.isTrue(sInner instanceof tr.e.cc.InputLatencyAsyncSlice);
assert.equal(sOuter.inputLatency, 10);
});
test('matchByType_newStyle', function() {
var sInfo = newAsyncSliceEx({
title: 'InputLatency::GestureScrollUpdate',
cat: 'benchmark',
start: 2,
end: 10,
id: '0x100',
isTopLevel: true,
args: {
data: {
INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT: {'time' : 0},
INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT: {time: 10}
}
}
});
assert.isTrue(sInfo instanceof tr.e.cc.InputLatencyAsyncSlice);
assert.equal(sInfo.inputLatency, 10);
});
test('matchByCategory', function() {
var sInfo = newAsyncSliceEx({
title: 'InputLatency::BadTypeName',
cat: 'benchmark,latencyInfo',
start: 2,
end: 10,
id: '0x100',
isTopLevel: true,
args: {
data: {
INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT: {'time' : 0},
INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT: {'time' : 0},
INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT: {time: 10}
}
}
});
assert.isTrue(sInfo instanceof tr.e.cc.InputLatencyAsyncSlice);
assert.equal(sInfo.inputLatency, 10);
});
test('testGetAssociatedEvents', function() {
var m = newModel(function(m) {
var p = m.getOrCreateProcess(1);
var t = p.getOrCreateThread(1);
var s0 = newSliceEx({
title: 'a',
start: 0.0,
duration: 0.5
});
var s1 = newSliceEx({
title: 'b',
start: 0.5,
duration: 0.5
});
var s2 = newSliceEx({
title: 'c',
start: 1.0,
duration: 0.5
});
var f1 = newFlowEventEx({
'title': 'test1',
start: 0,
end: 10,
startSlice: s0,
endSlice: s1,
id: '0x100'
});
var f2 = newFlowEventEx({
'title': 'test2',
start: 20,
end: 30,
startSlice: s1,
endSlice: s2,
id: '0x100'
});
m.flowEvents.push(f1);
m.flowEvents.push(f2);
m.as0 = newAsyncSliceEx({
title: 'InputLatency::TestShouldReturnEmpty',
cat: 'benchmark,latencyInfo',
start: 2,
end: 10,
id: '0x101',
isTopLevel: true,
startThread: t
});
m.as1 = newAsyncSliceEx({
title: 'InputLatency::TestShouldReturnTwoElements',
cat: 'benchmark,latencyInfo',
start: 2,
end: 10,
id: '0x100',
isTopLevel: true,
startThread: t
});
});
assert.equal(m.as0.associatedEvents.length, 0);
assert.equal(m.as1.associatedEvents.length, 5);
assert.equal(m.as1.associatedEvents[0].id, '0x100');
});
});
</script>