blob: 022c7d05e981902f8be977b370bb10c9c23afb44 [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="/perf_insights/mappers/scheduling/map_input_blockers.html">
<link rel="import" href="/perf_insights/mre/mre_result.html">
<link rel="import" href="/tracing/base/iteration_helpers.html">
<link rel="import" href="/tracing/core/test_utils.html">
<link rel="import" href="/tracing/extras/chrome/chrome_test_utils.html">
<script>
'use strict';
tr.b.unittest.testSuite(function() {
var TestUtils = tr.c.TestUtils;
var ThreadSlice = tr.model.ThreadSlice;
test('mapperTest', function() {
var m = tr.e.chrome.ChromeTestUtils.newChromeModel(function(m) {
var mainThread = m.rendererMain;
// Set up a model with two events that are blocking input event handling.
mainThread.sliceGroup.pushSlice(TestUtils.newSliceEx({
type: ThreadSlice,
start: -10,
duration: 15,
title: 'blockingEvent1'
}));
mainThread.sliceGroup.pushSlice(TestUtils.newSliceEx({
type: ThreadSlice,
start: 5,
duration: 4,
title: 'blockingEvent2'
}));
var inputEvent = mainThread.sliceGroup.pushSlice(TestUtils.newSliceEx({
type: ThreadSlice,
start: 10,
duration: 10,
title: 'LatencyInfo.Flow',
args: {step: 'HandleInputEventMain'}
}));
var flow = TestUtils.newFlowEventEx({
start: 0,
duration: 10
});
inputEvent.inFlowEvents.push(flow);
});
var result = new pi.mre.MreResult();
pie.mapInputBlockersForTest(result, m);
assert.equal(tr.b.dictionaryLength(result.pairs), 1);
// The mapper computes the amount of delay each blocking event contributed
// to the input event.
var inputBlockers = result.pairs.inputBlockers;
assert.deepEqual(inputBlockers.blockingEvent1, [5]);
assert.deepEqual(inputBlockers.blockingEvent2, [4]);
});
});
</script>