Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / analysis / analysis_results_test.html
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
6 -->
7
8 <link rel="import" href="/tracing/analysis/analysis_results.html">
9 <link rel="import" href="/tracing/analysis/stub_analysis_table.html">
10 <link rel="import" href="/tracing/selection.html">
11
12 <script>
13 'use strict';
14
15 tvcm.unittest.testSuite(function() {
16   test('selectionChangingLink', function() {
17     var r = tracing.analysis.AnalysisResults();
18     var track = {};
19     var linkEl = r.createSelectionChangingLink('hello', function() {
20       var selection = new tracing.Selection();
21       selection.push({guid:1});
22       return selection;
23     });
24     var didRequestSelectionChange = false;
25     linkEl.addEventListener('requestSelectionChange', function(e) {
26       didRequestSelectionChange = true;
27     });
28     linkEl.click();
29     assertTrue(didRequestSelectionChange);
30   });
31
32   test('displayValuesInInfoRow', function() {
33     var r = new tracing.analysis.AnalysisResults();
34     var table = new tracing.analysis.StubAnalysisTable();
35     var node;
36     var sectionNode;
37     assertEquals(0, table.nodeCount);
38
39     r.appendInfoRow(table, 'false_value', false);
40     assertEquals(1, table.nodeCount);
41     sectionNode = table.lastNode;
42     assertEquals(1, sectionNode.nodeCount);
43     node = sectionNode.lastNode;
44     assertEquals('false_value', node.children[0].innerText);
45     assertEquals('false', node.children[1].innerText);
46
47     r.appendInfoRow(table, 'true_value', true);
48
49     assertEquals(1, sectionNode.nodeCount);
50     node = sectionNode.lastNode;
51     assertEquals('true_value', node.children[0].innerText);
52     assertEquals('true', node.children[1].innerText);
53
54     r.appendInfoRow(table, 'string_value', 'a string');
55     assertEquals(1, sectionNode.nodeCount);
56     node = sectionNode.lastNode;
57     assertEquals('string_value', node.children[0].innerText);
58     assertEquals('"a string"', node.children[1].innerText);
59
60     r.appendInfoRow(table, 'number_value', 12345);
61     assertEquals(1, sectionNode.nodeCount);
62     node = sectionNode.lastNode;
63     assertEquals('number_value', node.children[0].innerText);
64     assertEquals('12345', node.children[1].innerText);
65
66     r.appendInfoRow(table, 'undefined', undefined);
67     assertEquals(1, sectionNode.nodeCount);
68     node = sectionNode.lastNode;
69     assertEquals('undefined', node.children[0].innerText);
70     assertEquals('', node.children[1].innerText);
71
72     assertEquals(0, sectionNode.nodeCount);
73     assertEquals(0, table.nodeCount);
74   });
75 });
76 </script>