Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / analysis / table_builder_test.html
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2014 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/table_builder.html">
9
10 <script>
11 'use strict';
12
13 tvcm.unittest.testSuite(function() {
14   var THIS_DOC = document._currentScript.ownerDocument;
15
16   test('instantiateNestedTableNoNests', function() {
17     var columns = [
18       {
19         title: 'First Column',
20         value: function(row) { return row.firstData; },
21         width: '50%'
22       },
23       {
24         title: 'Second Column',
25         value: function(row) { return row.secondData; }
26       }
27     ];
28
29     var rows = [
30       {
31         firstData: 'A1',
32         secondData: 'A2'
33       },
34       {
35         firstData: 'B1',
36         secondData: 'B2'
37       }
38     ];
39
40     var table = new TracingAnalysisNestedTable();
41     table.tableColumns = columns;
42     table.tableRows = rows;
43
44     this.addHTMLOutput(table);
45   });
46
47   test('instantiateNestedTableWithNests', function() {
48     var columns = [
49       {
50         title: 'First Column',
51         value: function(row) { return row.firstData; },
52         width: '50%'
53       },
54       {
55         title: 'Second Column',
56         value: function(row) { return row.secondData; },
57         width: '50%'
58       }
59     ];
60
61     var rows = [
62       {
63         firstData: 'A1',
64         secondData: 'A2',
65         subRows: [
66           {
67             firstData: 'Sub1 A1',
68             secondData: 'Sub1 A2'
69           },
70           {
71             firstData: 'Sub2 A1',
72             secondData: 'Sub2 A2',
73             subRows: [
74               {
75                 firstData: 'SubSub1 A1',
76                 secondData: 'SubSub1 A2',
77               },
78               {
79                 firstData: 'SubSub2 A1',
80                 secondData: 'SubSub2 A2',
81               }
82             ]
83           },
84           {
85             firstData: 'Sub3 A1',
86             secondData: 'Sub3 A2'
87           }
88         ]
89       },
90       {
91         firstData: 'B1',
92         secondData: 'B2'
93       }
94     ];
95
96     var table = new TracingAnalysisNestedTable();
97     table.tableColumns = columns;
98     table.tableRows = rows;
99
100     this.addHTMLOutput(table);
101   });
102
103   test('instantiateSortingCallbacksWithNests', function() {
104     var table = new TracingAnalysisNestedTable();
105
106     var columns = [
107       {
108         title: 'First Column',
109         value: function(row) { return row.firstData; },
110         width: '50%',
111       },
112       {
113         title: 'Second Column',
114         value: function(row) { return row.secondData; },
115         width: '50%',
116         cmp: function(rowA, rowB) {
117           return rowA.secondData.toString().localeCompare(
118               rowB.secondData.toString());
119         },
120         showExpandButtons: true
121       }
122     ];
123
124     var rows = [
125       {
126         firstData: 'A1',
127         secondData: 'A2',
128         subRows: [
129           {
130             firstData: 'Sub1 A1',
131             secondData: 'Sub1 A2'
132           },
133           {
134             firstData: 'Sub2 A1',
135             secondData: 'Sub2 A2',
136             subRows: [
137               {
138                 firstData: 'SubSub1 A1',
139                 secondData: 'SubSub1 A2',
140               },
141               {
142                 firstData: 'SubSub2 A1',
143                 secondData: 'SubSub2 A2',
144               }
145             ]
146           },
147           {
148             firstData: 'Sub3 A1',
149             secondData: 'Sub3 A2'
150           }
151         ]
152       },
153       {
154         firstData: 'B1',
155         secondData: 'B2'
156       }
157     ];
158
159     var footerRows = [
160       {
161         firstData: 'F1',
162         secondData: 'F2',
163         subRows: [
164           {
165             firstData: 'Sub1F1',
166             secondData: 'Sub1F2'
167           },
168           {
169             firstData: 'Sub2F1',
170             secondData: 'Sub2F2',
171             subRows: [
172               {
173                 firstData: 'SubSub1F1',
174                 secondData: 'SubSub1F2',
175               },
176               {
177                 firstData: 'SubSub2F1',
178                 secondData: 'SubSub2F2',
179               }
180             ]
181           },
182           {
183             firstData: 'Sub3F1',
184             secondData: 'Sub3F2'
185           }
186         ]
187       },
188       {
189         firstData: 'F\'1',
190         secondData: 'F\'2'
191       }
192
193     ];
194
195     table.tableColumns = columns;
196     table.tableRows = rows;
197     table.footerRows = footerRows;
198     this.addHTMLOutput(table);
199
200     var button = THIS_DOC.createElement('button');
201     button.textContent = 'Sort By Col 0';
202     button.addEventListener('click', function() {
203       table.sortDescending = !table.sortDescending;
204       table.sortColumnIndex = 0;
205     });
206     this.addHTMLOutput(button);
207   });
208 });
209 </script>