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.
8 <link rel="import" href="/tracing/side_panel/sampling_summary.html">
9 <link rel="import" href="/tracing/test_utils.html">
10 <link rel="import" href="/tracing/trace_model.html">
15 tvcm.unittest.testSuite(function() {
16 var StackFrame = tracing.trace_model.StackFrame;
17 var Sample = tracing.trace_model.Sample;
19 var newSliceNamed = tracing.test_utils.newSliceNamed;
21 function createSelection() {
22 var selection = new tracing.Selection();
23 var model = new tracing.TraceModel();
24 var thread = model.getOrCreateProcess(1).getOrCreateThread(2);
25 thread.name = 'The Thread';
27 var fA = new StackFrame(undefined, 1, 'Chrome', 'a', 7);
28 var fAB = new StackFrame(fA, 2, 'Chrome', 'b', 7);
29 var fABC = new StackFrame(fAB, 3, 'Chrome', 'c', 7);
30 var fAD = new StackFrame(fA, 4, 'GPU Driver', 'd', 7);
32 selection.push(new Sample(undefined, thread, 'cycles',
34 selection.push(new Sample(undefined, thread, 'cycles',
36 selection.push(new Sample(undefined, thread, 'cycles',
38 selection.push(new Sample(undefined, thread, 'cycles',
40 selection.push(new Sample(undefined, thread, 'cycles',
42 selection.push(new Sample(undefined, thread, 'cycles',
44 selection.push(new Sample(undefined, thread, 'cycles',
46 selection.push(new Sample(undefined, thread, 'page_misses',
48 selection.push(new Sample(undefined, thread, 'page_misses',
53 test('createSunburstDataBasic', function() {
54 var s = createSelection();
57 name: '<All Threads>',
61 name: 'Thread 2: The Thread',
91 category: 'GPU Driver',
105 var sunburstData = tracing.createSunburstData(s, 'cycles');
106 assertEquals(JSON.stringify(expect), JSON.stringify(sunburstData));
109 test('processOnlySamples', function() {
110 var selection = new tracing.Selection();
111 var model = new tracing.TraceModel();
112 var thread = model.getOrCreateProcess(1).getOrCreateThread(2);
113 thread.name = 'The Thread';
115 var fA = new StackFrame(undefined, 1, 'Chrome', 'a', 7);
116 var fAB = new StackFrame(fA, 2, 'Chrome', 'b', 7);
117 var fABC = new StackFrame(fAB, 3, 'Chrome', 'c', 7);
118 var fAD = new StackFrame(fA, 4, 'GPU Driver', 'd', 7);
120 selection.push(new Sample(undefined, thread, 'cycles',
122 selection.push(new Sample(undefined, thread, 'cycles',
124 selection.push(new Sample(undefined, thread, 'page_misses',
127 name: '<All Threads>',
131 name: 'Thread 2: The Thread',
143 category: 'GPU Driver',
157 // Along with the samples, push some slices too.
158 // The panel should completely ignore these.
159 selection.push(newSliceNamed('a', 1, 2));
160 selection.push(newSliceNamed('f', 9, 7));
162 var sunburstData = tracing.createSunburstData(selection, 'page_misses');
163 assertEquals(JSON.stringify(expect), JSON.stringify(sunburstData));
166 test('createSunburstDataSampleType', function() {
167 var s = createSelection();
170 name: '<All Threads>',
174 name: 'Thread 2: The Thread',
186 category: 'GPU Driver',
200 var sunburstData = tracing.createSunburstData(s, 'page_misses');
201 assertEquals(JSON.stringify(expect), JSON.stringify(sunburstData));
204 test('instantiate', function() {
205 var s = createSelection();
207 var panel = new tracing.SamplingSummaryPanel();
208 this.addHTMLOutput(panel);
209 panel.style.border = '1px solid black';