blob: 74efb105092f8bea5ae6daa7e273a9514cbf71b0 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 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/mre/mre_result.html">
<link rel="import" href="/perf_insights_examples/map_startup_info.html">
<link rel="import" href="/tracing/base/iteration_helpers.html">
<link rel="import" href="/tracing/core/test_utils.html">
<link rel="import" href="/tracing/model/thread_slice.html">
<link rel="import" href="/tracing/model/user_model/load_expectation.html">
<script>
'use strict';
tr.b.unittest.testSuite(function() {
var test_utils = tr.c.TestUtils;
test('mapperTest', function() {
var m = test_utils.newModel(function(m) {
var p1 = m.getOrCreateProcess(1);
var t2 = p1.getOrCreateThread(2);
t2.name = 'CrBrowserMain';
var t2_s1 = test_utils.newSliceEx({
name: 'Some slice',
start: 10, duration: 20,
type: tr.model.ThreadSlice
});
t2_s1.parentContainer = t2;
var t2_s2 = test_utils.newSliceEx({
name: 'Another slice',
start: 30, duration: 50,
type: tr.model.ThreadSlice
});
t2_s2.parentContainer = t2;
t2.sliceGroup.pushSlice(t2_s1);
t2.sliceGroup.pushSlice(t2_s2);
var loadIr = new tr.model.um.LoadExpectation(
m, tr.model.um.LOAD_SUBTYPE_NAMES.STARTUP, 15, 45);
m.userModel.expectations.push(loadIr);
loadIr.associatedEvents.push(t2_s1);
loadIr.associatedEvents.push(t2_s2);
});
var result = new pi.mre.MreResult();
pie.mapStartupInfoForTest(result, m);
assert.equal(tr.b.dictionaryLength(result.pairs), 1);
assert.equal(result.failures.length, 0);
var startupInfo = result.pairs.startup_info;
assert.equal(startupInfo.browserStartup.min, 10);
assert.equal(startupInfo.browserStartup.max, 80);
assert.isFalse(startupInfo.browserStartup.isEmpty);
assert.isTrue(startupInfo.rendererStartup.isEmpty);
});
test('mapperTestEmptyTrace', function() {
var m = test_utils.newModel();
var result = new pi.mre.MreResult();
pie.mapStartupInfoForTest(result, m);
assert.equal(tr.b.dictionaryLength(result.pairs), 1);
assert.equal(result.pairs.startup_info, null);
});
});
</script>