blob: 2a7bb88eadaacaee701b738162fc62092f03605b [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/value/value.html">
<link rel="import" href="/perf_insights/value/run_info.html">
<link rel="import" href="/perf_insights/results/results.html">
<link rel="import" href="/perf_insights_examples/map_startup_info.html">
<link rel="import" href="/tracing/core/test_utils.html">
<link rel="import" href="/tracing/extras/rail/load_interaction_record.html">
<link rel="import" href="/tracing/model/thread_slice.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.e.rail.LoadInteractionRecord(m, 15, 45);
loadIr.name = 'Startup';
m.interactionRecords.push(loadIr);
loadIr.associatedEvents.push(t2_s1);
loadIr.associatedEvents.push(t2_s2);
});
var results = new pi.r.Results();
var runInfo = new pi.v.RunInfo('my_test.json');
pie.mapStartupInfoForTest(results, runInfo, m);
assert.equal(results.allValues.length, 1);
assert.equal(results.allValues[0].value.browserStartup.min, 10);
assert.equal(results.allValues[0].value.browserStartup.max, 80);
assert.isFalse(results.allValues[0].value.browserStartup.isEmpty);
assert.isTrue(results.allValues[0].value.rendererStartup.isEmpty);
});
test('mapperTestEmptyTrace', function() {
var m = test_utils.newModel();
var results = new pi.r.Results();
var runInfo = new pi.v.RunInfo('my_test.json');
pie.mapStartupInfoForTest(results, runInfo, m);
assert.equal(results.allValues.length, 1);
assert.isTrue(results.allValues[0] instanceof pi.v.SkipValue);
});
});
</script>