1// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5'use strict'; 6 7base.require('tracing.analysis.analysis_results'); 8base.require('tracing.analysis.stub_analysis_table'); 9base.require('tracing.selection'); 10 11base.unittest.testSuite('tracing.analysis.analysis_results', function() { 12 test('selectionChangingLink', function() { 13 var r = tracing.analysis.AnalysisResults(); 14 var track = {}; 15 var linkEl = r.createSelectionChangingLink('hello', function() { 16 var selection = new tracing.Selection(); 17 selection.addSlice(track, {}); 18 return selection; 19 }); 20 var didRequestSelectionChange = false; 21 linkEl.addEventListener('requestSelectionChange', function(e) { 22 didRequestSelectionChange = true; 23 }); 24 linkEl.click(); 25 assertTrue(didRequestSelectionChange); 26 }); 27 28 test('displayValuesInSummaryRow', function() { 29 var r = new tracing.analysis.AnalysisResults(); 30 var table = new tracing.analysis.StubAnalysisTable(); 31 var node; 32 assertEquals(0, table.nodeCount); 33 34 r.appendSummaryRow(table, 'false_value', false); 35 assertEquals(1, table.nodeCount); 36 node = table.lastNode; 37 assertEquals('false_value', node.children[0].innerText); 38 assertEquals('false', node.children[1].innerText); 39 40 r.appendSummaryRow(table, 'true_value', true); 41 assertEquals(1, table.nodeCount); 42 node = table.lastNode; 43 assertEquals('true_value', node.children[0].innerText); 44 assertEquals('true', node.children[1].innerText); 45 46 r.appendSummaryRow(table, 'string_value', 'a string'); 47 assertEquals(1, table.nodeCount); 48 node = table.lastNode; 49 assertEquals('string_value', node.children[0].innerText); 50 assertEquals('"a string"', node.children[1].innerText); 51 52 r.appendSummaryRow(table, 'number_value', 12345); 53 assertEquals(1, table.nodeCount); 54 node = table.lastNode; 55 assertEquals('number_value', node.children[0].innerText); 56 assertEquals('12345', node.children[1].innerText); 57 58 r.appendSummaryRow(table, 'undefined', undefined); 59 assertEquals(1, table.nodeCount); 60 node = table.lastNode; 61 assertEquals('undefined', node.children[0].innerText); 62 assertEquals('', node.children[1].innerText); 63 64 assertEquals(0, table.nodeCount); 65 }); 66}); 67