OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" | 8 <link rel="import" |
9 href="/tracing/ui/extras/about_tracing/inspector_tracing_controller_client
.html"> | 9 href="/tracing/ui/extras/about_tracing/inspector_tracing_controller_client
.html"> |
10 | 10 |
11 <script> | 11 <script> |
12 'use strict'; | 12 'use strict'; |
13 | 13 |
| 14 function makeController() { |
| 15 const controller = |
| 16 new tr.ui.e.about_tracing.InspectorTracingControllerClient(); |
| 17 controller.conn_ = new (function() { |
| 18 this.req = function(method, params) { |
| 19 const msg = JSON.stringify({ |
| 20 id: 1, |
| 21 method, |
| 22 params |
| 23 }); |
| 24 return new (function() { |
| 25 this.msg = msg; |
| 26 this.then = function(m1, m2) { |
| 27 return this; |
| 28 }; |
| 29 })(); |
| 30 }; |
| 31 this.setNotificationListener = function(method, listener) { |
| 32 }; |
| 33 })(); |
| 34 return controller; |
| 35 } |
| 36 |
14 tr.b.unittest.testSuite(function() { | 37 tr.b.unittest.testSuite(function() { |
15 test('beginRecording_sendCategoriesAndOptions', function() { | 38 test('beginRecording_sendCategoriesAndOptions', function() { |
16 const controller = | 39 const controller = makeController(); |
17 new tr.ui.e.about_tracing.InspectorTracingControllerClient(); | |
18 controller.conn_ = new (function() { | |
19 this.req = function(method, params) { | |
20 const msg = JSON.stringify({ | |
21 id: 1, | |
22 method, | |
23 params | |
24 }); | |
25 return new (function() { | |
26 this.msg = msg; | |
27 this.then = function(m1, m2) { | |
28 return this; | |
29 }; | |
30 })(); | |
31 }; | |
32 this.setNotificationListener = function(method, listener) { | |
33 }; | |
34 })(); | |
35 | 40 |
36 const recordingOptions = { | 41 const recordingOptions = { |
37 categoryFilter: JSON.stringify(['a', 'b', 'c']), | 42 included_categories: ['a', 'b', 'c'], |
38 useSystemTracing: false, | 43 excluded_categories: ['e'], |
39 tracingRecordMode: 'test-mode', | 44 enable_systrace: false, |
40 useSampling: true | 45 record_mode: 'record-until-full', |
41 }; | 46 }; |
42 | 47 |
43 const result = JSON.parse(controller.beginRecording(recordingOptions).msg); | 48 const result = JSON.parse(controller.beginRecording(recordingOptions).msg); |
| 49 assert.deepEqual( |
| 50 result.params.traceConfig.includedCategories, ['a', 'b', 'c']); |
| 51 assert.deepEqual( |
| 52 result.params.traceConfig.excludedCategories, ['e']); |
44 assert.strictEqual( | 53 assert.strictEqual( |
45 result.params.categories, JSON.stringify(['a', 'b', 'c'])); | 54 result.params.traceConfig.recordMode, 'recordUntilFull'); |
46 const options = result.params.options.split(','); | 55 assert.isFalse( |
47 let tracingRecordTestMode = false; | 56 result.params.traceConfig.enableSystrace); |
48 let sampleFlag = false; | 57 assert.isTrue( |
49 for (const s in options) { | 58 result.params.traceConfig.memoryDumpConfig.triggers.length === 0); |
50 if (options[s] === 'test-mode') tracingRecordTestMode = true; | 59 }); |
51 else if (options[s] === 'enable-sampling') sampleFlag = true; | 60 |
52 else assert.strictEqual(options[s], ''); | 61 test('beginRecording_sendCategoriesAndOptionsWithMemoryInfra', function() { |
53 } | 62 const controller = makeController(); |
54 assert.isTrue(tracingRecordTestMode); | 63 |
55 assert.isTrue(sampleFlag); | 64 const recordingOptions = { |
| 65 included_categories: ['c', 'disabled-by-default-memory-infra', 'a'], |
| 66 excluded_categories: ['e'], |
| 67 enable_systrace: false, |
| 68 record_mode: 'test-mode', |
| 69 }; |
| 70 |
| 71 const result = JSON.parse(controller.beginRecording(recordingOptions).msg); |
| 72 assert.isTrue( |
| 73 result.params.traceConfig.memoryDumpConfig.triggers.length === 1); |
| 74 assert.isTrue( |
| 75 result.params.traceConfig.memoryDumpConfig.triggers.length === 1); |
| 76 assert.strictEqual(result.params.traceConfig.memoryDumpConfig. |
| 77 triggers[0].mode, 'detailed'); |
| 78 assert.strictEqual(result.params.traceConfig.memoryDumpConfig. |
| 79 triggers[0].periodic_interval_ms, 10000); |
56 }); | 80 }); |
57 | 81 |
58 test('oldFormat', function() { | 82 test('oldFormat', function() { |
59 const chunks = []; | 83 const chunks = []; |
60 tr.ui.e.about_tracing.appendTraceChunksTo(chunks, '"{ "method": "Tracing.dat
aCollected", "params": { "value": [ {"cat":"__metadata","pid":28871,"tid":0,"ts"
:0,"ph":"M","name":"num_cpus","args":{"number":4}},{"cat":"__metadata","pid":288
71,"tid":28911,"ts":0,"ph":"M","name":"process_sort_index","args":{"sort_index":
-5}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"process
_name","args":{"name":"Renderer"}},{"cat":"__metadata","pid":28871,"tid":28911,"
ts":0,"ph":"M","name":"process_labels","args":{"labels":"JS Bin"}},{"cat":"__met
adata","pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_sort_index","args"
:{"sort_index":-1}},{"cat":"__metadata","pid":28871,"tid":28917,"ts":0,"ph":"M",
"name":"thread_name","args":{"name":"Compositor"}},{"cat":"__metadata","pid":288
71,"tid":28911,"ts":0,"ph":"M","name":"thread_name","args":{"name":"Chrome_Child
IOThread"}},{"cat":"__metadata","pid":28871,"tid":28919,"ts":0,"ph":"M","name":"
thread_name","args":{"name":"CompositorRasterWorker1/28919"}},{"cat":"__metadata
","pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_name","args":{"name":"C
rRendererMain"}},{"cat":"ipc,toplevel","pid":28871,"tid":28911,"ts":22000084746,
"ph":"X","name":"ChannelReader::DispatchInputData","args":{"class":64,"line":25}
,"tdur":0,"tts":1853064},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph"
:"M","name":"overhead","args":{"average_overhead":0.015}} ] } }"'); // @suppress
longLineCheck | 84 tr.ui.e.about_tracing.appendTraceChunksTo(chunks, '"{ "method": "Tracing.dat
aCollected", "params": { "value": [ {"cat":"__metadata","pid":28871,"tid":0,"ts"
:0,"ph":"M","name":"num_cpus","args":{"number":4}},{"cat":"__metadata","pid":288
71,"tid":28911,"ts":0,"ph":"M","name":"process_sort_index","args":{"sort_index":
-5}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"process
_name","args":{"name":"Renderer"}},{"cat":"__metadata","pid":28871,"tid":28911,"
ts":0,"ph":"M","name":"process_labels","args":{"labels":"JS Bin"}},{"cat":"__met
adata","pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_sort_index","args"
:{"sort_index":-1}},{"cat":"__metadata","pid":28871,"tid":28917,"ts":0,"ph":"M",
"name":"thread_name","args":{"name":"Compositor"}},{"cat":"__metadata","pid":288
71,"tid":28911,"ts":0,"ph":"M","name":"thread_name","args":{"name":"Chrome_Child
IOThread"}},{"cat":"__metadata","pid":28871,"tid":28919,"ts":0,"ph":"M","name":"
thread_name","args":{"name":"CompositorRasterWorker1/28919"}},{"cat":"__metadata
","pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_name","args":{"name":"C
rRendererMain"}},{"cat":"ipc,toplevel","pid":28871,"tid":28911,"ts":22000084746,
"ph":"X","name":"ChannelReader::DispatchInputData","args":{"class":64,"line":25}
,"tdur":0,"tts":1853064},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph"
:"M","name":"overhead","args":{"average_overhead":0.015}} ] } }"'); // @suppress
longLineCheck |
61 assert.strictEqual(chunks.length, 1); | 85 assert.strictEqual(chunks.length, 1); |
62 JSON.parse('[' + chunks.join('') + ']'); | 86 JSON.parse('[' + chunks.join('') + ']'); |
63 }); | 87 }); |
64 | 88 |
65 test('newFormat', function() { | 89 test('newFormat', function() { |
66 const chunks = []; | 90 const chunks = []; |
67 tr.ui.e.about_tracing.appendTraceChunksTo(chunks, '"{ "method": "Tracing.dat
aCollected", "params": { "value": [{"cat":"__metadata","pid":28871,"tid":0,"ts":
0,"ph":"M","name":"num_cpus","args":{"number":4}},{"cat":"__metadata","pid":2887
1,"tid":28911,"ts":0,"ph":"M","name":"process_sort_index","args":{"sort_index":-
5}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"process_
name","args":{"name":"Renderer"}},{"cat":"__metadata","pid":28871,"tid":28911,"t
s":0,"ph":"M","name":"process_labels","args":{"labels":"JS Bin"}},{"cat":"__meta
data","pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_sort_index","args":
{"sort_index":-1}},{"cat":"__metadata","pid":28871,"tid":28917,"ts":0,"ph":"M","
name":"thread_name","args":{"name":"Compositor"}},{"cat":"__metadata","pid":2887
1,"tid":28911,"ts":0,"ph":"M","name":"thread_name","args":{"name":"Chrome_ChildI
OThread"}},{"cat":"__metadata","pid":28871,"tid":28919,"ts":0,"ph":"M","name":"t
hread_name","args":{"name":"CompositorRasterWorker1/28919"}},{"cat":"__metadata"
,"pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_name","args":{"name":"Cr
RendererMain"}},{"cat":"ipc,toplevel","pid":28871,"tid":28911,"ts":22000084746,"
ph":"X","name":"ChannelReader::DispatchInputData","args":{"class":64,"line":25},
"tdur":0,"tts":1853064},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":
"M","name":"overhead","args":{"average_overhead":0.015}}] } }"'); // @suppress l
ongLineCheck | 91 tr.ui.e.about_tracing.appendTraceChunksTo(chunks, '"{ "method": "Tracing.dat
aCollected", "params": { "value": [{"cat":"__metadata","pid":28871,"tid":0,"ts":
0,"ph":"M","name":"num_cpus","args":{"number":4}},{"cat":"__metadata","pid":2887
1,"tid":28911,"ts":0,"ph":"M","name":"process_sort_index","args":{"sort_index":-
5}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"process_
name","args":{"name":"Renderer"}},{"cat":"__metadata","pid":28871,"tid":28911,"t
s":0,"ph":"M","name":"process_labels","args":{"labels":"JS Bin"}},{"cat":"__meta
data","pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_sort_index","args":
{"sort_index":-1}},{"cat":"__metadata","pid":28871,"tid":28917,"ts":0,"ph":"M","
name":"thread_name","args":{"name":"Compositor"}},{"cat":"__metadata","pid":2887
1,"tid":28911,"ts":0,"ph":"M","name":"thread_name","args":{"name":"Chrome_ChildI
OThread"}},{"cat":"__metadata","pid":28871,"tid":28919,"ts":0,"ph":"M","name":"t
hread_name","args":{"name":"CompositorRasterWorker1/28919"}},{"cat":"__metadata"
,"pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_name","args":{"name":"Cr
RendererMain"}},{"cat":"ipc,toplevel","pid":28871,"tid":28911,"ts":22000084746,"
ph":"X","name":"ChannelReader::DispatchInputData","args":{"class":64,"line":25},
"tdur":0,"tts":1853064},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":
"M","name":"overhead","args":{"average_overhead":0.015}}] } }"'); // @suppress l
ongLineCheck |
68 assert.strictEqual(chunks.length, 1); | 92 assert.strictEqual(chunks.length, 1); |
69 JSON.parse('[' + chunks.join('') + ']'); | 93 JSON.parse('[' + chunks.join('') + ']'); |
70 }); | 94 }); |
71 | 95 |
72 test('stringAndObjectPayload', function() { | 96 test('stringAndObjectPayload', function() { |
73 const connection = new tr.ui.e.about_tracing.InspectorConnection(); | 97 const connection = new tr.ui.e.about_tracing.InspectorConnection(); |
74 connection.setNotificationListener('Tracing.dataCollected', | 98 connection.setNotificationListener('Tracing.dataCollected', |
75 function(message) { | 99 function(message) { |
76 assert.typeOf(message, 'string'); | 100 assert.typeOf(message, 'string'); |
77 JSON.parse(message); | 101 JSON.parse(message); |
78 } | 102 } |
79 ); | 103 ); |
80 connection.dispatchMessage_('{ "method": "Tracing.dataCollected", "params":
{ "value": [] } }'); // @suppress longLineCheck | 104 connection.dispatchMessage_('{ "method": "Tracing.dataCollected", "params":
{ "value": [] } }'); // @suppress longLineCheck |
81 connection.dispatchMessage_({'method': 'Tracing.dataCollected', 'params': {'
value': [] } }); // @suppress longLineCheck | 105 connection.dispatchMessage_({'method': 'Tracing.dataCollected', 'params': {'
value': [] } }); // @suppress longLineCheck |
82 }); | 106 }); |
83 }); | 107 }); |
84 </script> | 108 </script> |
OLD | NEW |