Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: chrome/browser/resources/tracing/trace_event_importer_test.html

Issue 9706010: about:tracing support for TRACE_ASYNC_START/FINISH events. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: try again Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/tracing/trace_event_importer.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <!-- 3 <!--
4 Copyright (c) 2012 The Chromium Authors. All rights reserved. 4 Copyright (c) 2012 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be 5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file. 6 found in the LICENSE file.
7 --> 7 -->
8 <head> 8 <head>
9 <title>TraceEventImporter tests</title> 9 <title>TraceEventImporter tests</title>
10 <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.j s"></script> 10 <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.j s"></script>
11 <script src="../shared/js/cr.js"></script> 11 <script src="../shared/js/cr.js"></script>
12 <script src="../shared/js/cr/event_target.js"></script> 12 <script src="../shared/js/cr/event_target.js"></script>
13 <script src="test_utils.js"></script> 13 <script src="test_utils.js"></script>
14 <script src="timeline_model.js"></script> 14 <script src="timeline_model.js"></script>
15 <script src="trace_event_importer.js"></script> 15 <script src="trace_event_importer.js"></script>
16 <script> 16 <script>
17 goog.require('goog.testing.jsunit'); 17 goog.require('goog.testing.jsunit');
18 </script> 18 </script>
19 19
20 </head> 20 </head>
21 <body> 21 <body>
22 <script> 22 <script>
23 23
24 function testCanImportEmpty() { 24 function testCanImportEmpty() {
25 self.assertFalse(tracing.TraceEventImporter.canImport([])); 25 self.assertFalse(tracing.TraceEventImporter.canImport([]));
26 self.assertFalse(tracing.TraceEventImporter.canImport("")); 26 self.assertFalse(tracing.TraceEventImporter.canImport(''));
27 } 27 }
28 28
29 function testBasicSingleThreadNonnestedParsing() { 29 function testBasicSingleThreadNonnestedParsing() {
30 var events = [ 30 var events = [
31 {name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'}, 31 {name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'},
32 {name: 'a', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'E'}, 32 {name: 'a', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'E'},
33 {name: 'b', args: {}, pid: 52, ts: 629, cat: 'foo', tid: 53, ph: 'B'}, 33 {name: 'b', args: {}, pid: 52, ts: 629, cat: 'foo', tid: 53, ph: 'B'},
34 {name: 'b', args: {}, pid: 52, ts: 631, cat: 'foo', tid: 53, ph: 'E'} 34 {name: 'b', args: {}, pid: 52, ts: 631, cat: 'foo', tid: 53, ph: 'E'}
35 ]; 35 ];
36 36
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 552
553 var tmp = JSON.stringify(events); 553 var tmp = JSON.stringify(events);
554 assertEquals(']', tmp[tmp.length - 1]); 554 assertEquals(']', tmp[tmp.length - 1]);
555 555
556 // Drop off the trailing ] and add a newline 556 // Drop off the trailing ] and add a newline
557 var dropped = tmp.substring(0, tmp.length - 1); 557 var dropped = tmp.substring(0, tmp.length - 1);
558 var m = new tracing.TimelineModel(dropped + '\n'); 558 var m = new tracing.TimelineModel(dropped + '\n');
559 assertEquals(1, m.numProcesses); 559 assertEquals(1, m.numProcesses);
560 } 560 }
561 561
562 function testStartFinishOneSliceOneThread() {
563 var events = [
564 // Time is intentionally out of order.
565 {name: 'a', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53,
566 ph: 'F', id: 72},
567 {name: 'a', args: {}, pid: 52, ts: 524, cat: 'foo', tid: 53,
568 ph: 'S', id: 72, args: {foo: 'bar'}}
569 ];
570
571 var m = new tracing.TimelineModel(events);
572 var t = m.processes[52].threads[53];
573 assertNotUndefined(t);
574 assertEquals(1, t.asyncSlices.slices.length);
575 assertEquals('a', t.asyncSlices.slices[0].title);
576 assertEquals(72, t.asyncSlices.slices[0].id);
577 assertEquals('bar', t.asyncSlices.slices[0].args.foo);
578 assertEquals(0, t.asyncSlices.slices[0].start);
579 assertAlmostEquals((60 - 24) / 1000, t.asyncSlices.slices[0].duration);
580 assertEquals(t, t.asyncSlices.slices[0].startThread);
581 assertEquals(t, t.asyncSlices.slices[0].endThread);
582 }
583
584 // TODO(nduca): one slice, two threads
585 // TODO(nduca): one slice, two pids
586 // TODO(nduca): one slice that doesnt end
587 // TODO(nduca): one slice that is missing a start
588
562 </script> 589 </script>
563 </body> 590 </body>
564 </html> 591 </html>
OLDNEW
« no previous file with comments | « chrome/browser/resources/tracing/trace_event_importer.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698