blob: e896e198aef52ccdd3bd4aeb2a5781a7fab9dfc1 [file] [log] [blame]
<!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>Selection Analysis Tests</title>
<script src="../base.js"></script>
</head>
<body>
<script>
base.require('unittest');
base.require('test_utils');
base.require('timeline');
base.require('analysis.selection_analysis');
base.require('analysis.test.analysis_test_support');
base.requireStylesheet('analysis.test.analysis_test_support');
</script>
<script>
'use strict';
function testSelectionAnalysisWithSingleSlice() {
var data = tracing.analysis.test.createReferenceData(true);
var selection = new tracing.Selection();
data.t1track.selectByTitle('f', selection);
var analysis = new tracing.analysis.SelectionAnalysis();
analysis.selection = selection;
var selectionEl = analysis;
var sliceSelectionEl = selectionEl.children[0];
var singleSliceEl = sliceSelectionEl.children[0];
assertEquals(true,
analysis instanceof tracing.analysis.SelectionAnalysis);
assertEquals(true, sliceSelectionEl instanceof
tracing.analysis.SliceSelectionAnalysis);
assertEquals(1, sliceSelectionEl.children.length);
assertEquals(4, singleSliceEl.children.length);
this.addHTMLOutput(undefined, analysis);
}
function testSelectionAnalysisWithSingleSliceArgsAndCategory() {
var data = tracing.analysis.test.createReferenceData(true);
var selection = new tracing.Selection();
data.t1track.selectByTitle('D', selection);
var analysis = new tracing.analysis.SelectionAnalysis();
analysis.selection = selection;
var selectionEl = analysis;
var sliceSelectionEl = selectionEl.children[0];
var singleSliceEl = sliceSelectionEl.children[0];
var categoryEl = singleSliceEl.children[1];
var argEl1 = singleSliceEl.children[5];
var argEl2 = singleSliceEl.children[6];
assertEquals(true,
analysis instanceof tracing.analysis.SelectionAnalysis);
assertEquals(true, sliceSelectionEl instanceof
tracing.analysis.SliceSelectionAnalysis);
assertEquals(true, singleSliceEl instanceof
tracing.analysis.SingleSliceSelectionAnalysis);
assertEquals(1, sliceSelectionEl.children.length);
assertEquals(7, singleSliceEl.children.length);
this.addHTMLOutput(undefined, analysis);
}
function testSelectionAnalysisWithSlicesAndCounters() {
var data = tracing.analysis.test.createReferenceData(true);
var selection = new tracing.Selection();
data.t1track.selectByTitle('b', selection);
selection.addCounterSample(data.ctr1track, data.ctr1track.counter, 0);
var analysis = new tracing.analysis.SelectionAnalysis();
analysis.selection = selection;
var selectionEl = analysis;
var sliceSelectionEl = selectionEl.children[0];
var counterSelectionEl = selectionEl.children[1];
assertEquals(true, sliceSelectionEl instanceof
tracing.analysis.SliceSelectionAnalysis);
assertEquals(true, counterSelectionEl instanceof
tracing.analysis.CounterSelectionAnalysis);
assertEquals(2, selectionEl.children.length);
assertEquals(3, sliceSelectionEl.children.length);
assertEquals(2, counterSelectionEl.children.length);
this.addHTMLOutput(undefined, analysis);
}
function testSelectionAnalysisWithSingleCounter() {
var data = tracing.analysis.test.createReferenceData(true);
var selection = new tracing.Selection();
selection.addCounterSample(data.ctr1track, data.ctr1track.counter, 0);
var analysis = new tracing.analysis.SelectionAnalysis();
analysis.selection = selection;
var selectionEl = analysis;
var counterSelectionEl = selectionEl.children[0];
var singleCounterEl = counterSelectionEl.children[1];
assertEquals(true,
analysis instanceof tracing.analysis.SelectionAnalysis);
assertEquals(true, counterSelectionEl instanceof
tracing.analysis.CounterSelectionAnalysis);
assertEquals(true, singleCounterEl instanceof
tracing.analysis.SingleCounterSelectionAnalysis);
assertEquals(2, counterSelectionEl.children.length);
assertEquals(1, singleCounterEl.children.length);
this.addHTMLOutput(undefined, analysis);
}
function testSelectionAnalysisWithMultipleCounters() {
var data = tracing.analysis.test.createReferenceData(true);
var selection = new tracing.Selection();
selection.addCounterSample(data.ctr1track, data.ctr1track.counter, 0);
selection.addCounterSample(data.ctr2track, data.ctr2track.counter, 3);
var analysis = new tracing.analysis.SelectionAnalysis();
analysis.selection = selection;
var selectionEl = analysis;
var counterSelectionEl = selectionEl.children[0];
var singleCounterEl = counterSelectionEl.children[1];
var singleCounterEl2 = counterSelectionEl.children[2];
assertEquals(true,
analysis instanceof tracing.analysis.SelectionAnalysis);
assertEquals(true, counterSelectionEl instanceof
tracing.analysis.CounterSelectionAnalysis);
assertEquals(true, singleCounterEl instanceof
tracing.analysis.SingleCounterSelectionAnalysis);
assertEquals(true, singleCounterEl2 instanceof
tracing.analysis.SingleCounterSelectionAnalysis);
assertEquals(3, counterSelectionEl.children.length);
assertEquals(1, singleCounterEl.children.length);
assertEquals(1, singleCounterEl2.children.length);
this.addHTMLOutput(undefined, analysis);
}
</script>
</body>
</html>