<!DOCTYPE HTML>
<html>
<!--
Copyright (c) 2012 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.
-->
<head>
<title>Single Slice Selection Analysis Tests</title>
<script src="/src/base.js"></script>
</head>
<body>
<script>
base.require('unittest');
base.require('test_utils');
base.require('analysis.single_slice_selection_analysis');
base.require('analysis.test.analysis_test_support');
</script>
<script>
'use strict';
function testSelectionAnalysisWithSingleSliceArgsAndCategory() {
var data = tracing.analysis.test.createReferenceData(true);
var selection = new tracing.Selection();
data.t1track.selectByTitle('D', selection);
var analysis = new tracing.analysis.SingleSliceSelectionAnalysis();
analysis.selection = selection;
analysis.verticalDisplay = true;
var singleSliceEl = analysis;
var categoryEl = singleSliceEl.children[1];
var argEl1 = singleSliceEl.children[5];
var argEl2 = singleSliceEl.children[6];
assertEquals(true, analysis instanceof
tracing.analysis.SingleSliceSelectionAnalysis);
assertEquals(7, singleSliceEl.children.length);
assertEquals('category', categoryEl.children[1].textContent);
assertEquals('Arg D src_file', argEl1.children[1].textContent);
assertEquals('Arg D src_func', argEl2.children[1].textContent);
}
function testSingleSliceSelectionWithMissingCategoryAndArgs() {
var data = tracing.analysis.test.createReferenceData(true);
var selection = new tracing.Selection();
data.t1track.selectByTitle('f', selection);
var analysis = new tracing.analysis.SingleSliceSelectionAnalysis();
analysis.selection = selection;
analysis.verticalDisplay = true;
var singleSliceEl = analysis;
var row1 = analysis.children[0];
var row2 = analysis.children[1];
var row3 = analysis.children[2];
var row4 = analysis.children[3];
assertEquals('f', row1.children[1].textContent);
assertEquals('', row2.children[1].textContent);
assertEquals('0', row3.children[1].textContent);
assertEquals('0.002', row4.children[1].textContent);
}
function testSingleSliceSelectionWithMultipleSlices() {
var data = tracing.analysis.test.createReferenceData(true);
var selection = new tracing.Selection();
data.t1track.selectByTitle('b', selection);
var analysis = new tracing.analysis.SingleSliceSelectionAnalysis();
assertThrows(function() {
analysis.selection = selection;
});
}
function testSingleSliceSelectionWithFalseArgs() {
var data = tracing.analysis.test.createReferenceData(true);
var selection = new tracing.Selection();
data.t1track.selectByTitle('F', selection);
var analysis = new tracing.analysis.SingleSliceSelectionAnalysis();
analysis.selection = selection;
analysis.verticalDisplay = true;
var singleSliceEl = analysis;
var categoryEl = singleSliceEl.children[1];
var argEl1 = singleSliceEl.children[5];
var argEl2 = singleSliceEl.children[6];
assertEquals(true, singleSliceEl instanceof
tracing.analysis.SingleSliceSelectionAnalysis);
assertEquals(7, singleSliceEl.children.length);
assertEquals('0', argEl1.children[1].textContent);
assertEquals('false', argEl2.children[1].textContent);
}
</script>
</body>
</html>