1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 Copyright (c) 2012 The Chromium Authors. All rights reserved. 5 Use of this source code is governed by a BSD-style license that can be 6 found in the LICENSE file. 7 --> 8 <head> 9 <title>Single Slice Selection Analysis Tests</title> 10 <script src="/src/base.js"></script> 11 </head> 12 <body> 13 <script> 14 base.require('unittest'); 15 base.require('test_utils'); 16 base.require('analysis.single_slice_selection_analysis'); 17 base.require('analysis.test.analysis_test_support'); 18 </script> 19 <script> 20 'use strict'; 21 22 function testSelectionAnalysisWithSingleSliceArgsAndCategory() { 23 var data = tracing.analysis.test.createReferenceData(true); 24 25 var selection = new tracing.Selection(); 26 data.t1track.selectByTitle('D', selection); 27 28 var analysis = new tracing.analysis.SingleSliceSelectionAnalysis(); 29 analysis.selection = selection; 30 analysis.verticalDisplay = true; 31 32 var singleSliceEl = analysis; 33 var categoryEl = singleSliceEl.children[1]; 34 var argEl1 = singleSliceEl.children[5]; 35 var argEl2 = singleSliceEl.children[6]; 36 37 assertEquals(true, analysis instanceof 38 tracing.analysis.SingleSliceSelectionAnalysis); 39 assertEquals(7, singleSliceEl.children.length); 40 assertEquals('category', categoryEl.children[1].textContent); 41 assertEquals('Arg D src_file', argEl1.children[1].textContent); 42 assertEquals('Arg D src_func', argEl2.children[1].textContent); 43 } 44 45 function testSingleSliceSelectionWithMissingCategoryAndArgs() { 46 var data = tracing.analysis.test.createReferenceData(true); 47 48 var selection = new tracing.Selection(); 49 data.t1track.selectByTitle('f', selection); 50 51 var analysis = new tracing.analysis.SingleSliceSelectionAnalysis(); 52 analysis.selection = selection; 53 analysis.verticalDisplay = true; 54 55 var singleSliceEl = analysis; 56 var row1 = analysis.children[0]; 57 var row2 = analysis.children[1]; 58 var row3 = analysis.children[2]; 59 var row4 = analysis.children[3]; 60 61 assertEquals('f', row1.children[1].textContent); 62 assertEquals('', row2.children[1].textContent); 63 assertEquals('0', row3.children[1].textContent); 64 assertEquals('0.002', row4.children[1].textContent); 65 } 66 67 function testSingleSliceSelectionWithMultipleSlices() { 68 var data = tracing.analysis.test.createReferenceData(true); 69 70 var selection = new tracing.Selection(); 71 data.t1track.selectByTitle('b', selection); 72 73 var analysis = new tracing.analysis.SingleSliceSelectionAnalysis(); 74 assertThrows(function() { 75 analysis.selection = selection; 76 }); 77 } 78 79 function testSingleSliceSelectionWithFalseArgs() { 80 var data = tracing.analysis.test.createReferenceData(true); 81 82 var selection = new tracing.Selection(); 83 data.t1track.selectByTitle('F', selection); 84 85 var analysis = new tracing.analysis.SingleSliceSelectionAnalysis(); 86 analysis.selection = selection; 87 analysis.verticalDisplay = true; 88 89 var singleSliceEl = analysis; 90 var categoryEl = singleSliceEl.children[1]; 91 var argEl1 = singleSliceEl.children[5]; 92 var argEl2 = singleSliceEl.children[6]; 93 94 assertEquals(true, singleSliceEl instanceof 95 tracing.analysis.SingleSliceSelectionAnalysis); 96 assertEquals(7, singleSliceEl.children.length); 97 assertEquals('0', argEl1.children[1].textContent); 98 assertEquals('false', argEl2.children[1].textContent); 99 } 100 101 </script> 102 </body> 103 </html> 104