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 includedCategories: ['a', 'b', 'c'], |
43 excludedCategories: ['e'], | |
44 useSystemTracing: false, | |
45 tracingRecordMode: 'recordUntilFull', | |
46 useSampling: true | |
47 }; | |
48 | |
49 const result = JSON.parse(controller.beginRecording(recordingOptions).msg); | |
50 assert.deepEqual( | |
51 result.params.traceConfig.includedCategories, ['a', 'b', 'c']); | |
52 assert.deepEqual( | |
53 result.params.traceConfig.excludedCategories, ['e']); | |
54 assert.strictEqual( | |
55 result.params.traceConfig.recordMode, 'recordUntilFull'); | |
56 assert.isFalse( | |
57 result.params.traceConfig.enableSystrace); | |
58 assert.isTrue( | |
59 result.params.traceConfig.memoryDumpConfig.triggers.length === 0); | |
60 }); | |
61 | |
62 test('beginRecording_sendCategoriesAndOptionsWithMemoryInfra', function() { | |
63 const controller = makeController(); | |
64 | |
65 const recordingOptions = { | |
66 includedCategories: ['c', 'disabled-by-default-memory-infra', 'a'], | |
67 excludedCategories: ['e'], | |
38 useSystemTracing: false, | 68 useSystemTracing: false, |
39 tracingRecordMode: 'test-mode', | 69 tracingRecordMode: 'test-mode', |
40 useSampling: true | 70 useSampling: true |
41 }; | 71 }; |
42 | 72 |
43 const result = JSON.parse(controller.beginRecording(recordingOptions).msg); | 73 const result = JSON.parse(controller.beginRecording(recordingOptions).msg); |
44 assert.strictEqual( | 74 assert.isTrue( |
45 result.params.categories, JSON.stringify(['a', 'b', 'c'])); | 75 result.params.traceConfig.memoryDumpConfig.triggers.length === 1); |
fmeawad
2017/06/21 17:22:18
nit: Should we also add a check for the default du
erikchen
2017/06/21 22:56:50
Done.
| |
46 const options = result.params.options.split(','); | |
47 let tracingRecordTestMode = false; | |
48 let sampleFlag = false; | |
49 for (const s in options) { | |
50 if (options[s] === 'test-mode') tracingRecordTestMode = true; | |
51 else if (options[s] === 'enable-sampling') sampleFlag = true; | |
52 else assert.strictEqual(options[s], ''); | |
53 } | |
54 assert.isTrue(tracingRecordTestMode); | |
55 assert.isTrue(sampleFlag); | |
56 }); | 76 }); |
57 | 77 |
58 test('oldFormat', function() { | 78 test('oldFormat', function() { |
59 const chunks = []; | 79 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 | 80 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); | 81 assert.strictEqual(chunks.length, 1); |
62 JSON.parse('[' + chunks.join('') + ']'); | 82 JSON.parse('[' + chunks.join('') + ']'); |
63 }); | 83 }); |
64 | 84 |
65 test('newFormat', function() { | 85 test('newFormat', function() { |
66 const chunks = []; | 86 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 | 87 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); | 88 assert.strictEqual(chunks.length, 1); |
69 JSON.parse('[' + chunks.join('') + ']'); | 89 JSON.parse('[' + chunks.join('') + ']'); |
70 }); | 90 }); |
71 | 91 |
72 test('stringAndObjectPayload', function() { | 92 test('stringAndObjectPayload', function() { |
73 const connection = new tr.ui.e.about_tracing.InspectorConnection(); | 93 const connection = new tr.ui.e.about_tracing.InspectorConnection(); |
74 connection.setNotificationListener('Tracing.dataCollected', | 94 connection.setNotificationListener('Tracing.dataCollected', |
75 function(message) { | 95 function(message) { |
76 assert.typeOf(message, 'string'); | 96 assert.typeOf(message, 'string'); |
77 JSON.parse(message); | 97 JSON.parse(message); |
78 } | 98 } |
79 ); | 99 ); |
80 connection.dispatchMessage_('{ "method": "Tracing.dataCollected", "params": { "value": [] } }'); // @suppress longLineCheck | 100 connection.dispatchMessage_('{ "method": "Tracing.dataCollected", "params": { "value": [] } }'); // @suppress longLineCheck |
81 connection.dispatchMessage_({'method': 'Tracing.dataCollected', 'params': {' value': [] } }); // @suppress longLineCheck | 101 connection.dispatchMessage_({'method': 'Tracing.dataCollected', 'params': {' value': [] } }); // @suppress longLineCheck |
82 }); | 102 }); |
83 }); | 103 }); |
84 </script> | 104 </script> |
OLD | NEW |