| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE HTML> | |
| 2 <html> | |
| 3 <!-- | |
| 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 | |
| 6 found in the LICENSE file. | |
| 7 --> | |
| 8 <head i18n-values="dir:textdirection;"> | |
| 9 <title>ProfilingView tests</title> | |
| 10 <link rel="stylesheet" href="profiling_view.css"> | |
| 11 <link rel="stylesheet" href="timeline_view.css"> | |
| 12 <link rel="stylesheet" href="overlay.css"> | |
| 13 <link rel="stylesheet" href="timeline_analysis.css"> | |
| 14 <link rel="stylesheet" href="timeline.css"> | |
| 15 <link rel="stylesheet" href="../shared/css/tabs.css"> | |
| 16 <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.j
s"></script> | |
| 17 <script src="../shared/js/cr.js"></script> | |
| 18 <script src="../shared/js/cr/event_target.js"></script> | |
| 19 <script src="../shared/js/cr/ui.js"></script> | |
| 20 <script src="../shared/js/cr/ui/tabs.js"></script> | |
| 21 <script src="overlay.js"></script> | |
| 22 <script src="measuring_stick.js"></script> | |
| 23 <script src="profiling_view.js"></script> | |
| 24 <script src="timeline_analysis.js"></script> | |
| 25 <script src="timeline_view.js"></script> | |
| 26 <script src="timeline_model.js"></script> | |
| 27 <script src="linux_perf_importer.js"></script> | |
| 28 <script src="trace_event_importer.js"></script> | |
| 29 <script src="timeline.js"></script> | |
| 30 <script src="timeline_track.js"></script> | |
| 31 <script src="sorted_array_utils.js"></script> | |
| 32 <script src="fast_rect_renderer.js"></script> | |
| 33 <script src="test_utils.js"></script> | |
| 34 <script> | |
| 35 goog.require('goog.testing.jsunit'); | |
| 36 </script> | |
| 37 <style> | |
| 38 .profiling-view { | |
| 39 border: 1px solid black; | |
| 40 } | |
| 41 </style> | |
| 42 </head> | |
| 43 <body> | |
| 44 <script> | |
| 45 'use strict'; | |
| 46 | |
| 47 /* | |
| 48 * Just enough of the TracingController to support the tests below. | |
| 49 */ | |
| 50 function FakeTracingController() { | |
| 51 } | |
| 52 | |
| 53 FakeTracingController.prototype = { | |
| 54 __proto__: cr.EventTarget.prototype, | |
| 55 | |
| 56 beginTracing: function(opt_systemTracingEnabled) { | |
| 57 this.wasBeginTracingCalled = true; | |
| 58 this.wasBeginTracingCalledWithSystemTracingEnabled = opt_systemTracingEn
abled; | |
| 59 }, | |
| 60 | |
| 61 get traceEvents() { | |
| 62 if (!this.wasBeginTracingCalled) | |
| 63 return undefined; | |
| 64 return FakeTracingController.testData; | |
| 65 }, | |
| 66 | |
| 67 get systemTraceEvents() { | |
| 68 if (!this.wasBeginTracingCalled) | |
| 69 return []; | |
| 70 if (!this.wasBeginTracingCalledWithSystemTracingEnabled) | |
| 71 return []; | |
| 72 return FakeTracingController.systemTraceTestData; | |
| 73 } | |
| 74 | |
| 75 }; | |
| 76 FakeTracingController.testData = [ | |
| 77 {name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'}, | |
| 78 {name: 'a', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'E'}, | |
| 79 {name: 'b', args: {}, pid: 52, ts: 629, cat: 'foo', tid: 53, ph: 'B'}, | |
| 80 {name: 'b', args: {}, pid: 52, ts: 631, cat: 'foo', tid: 53, ph: 'E'} | |
| 81 ]; | |
| 82 FakeTracingController.systemTraceTestData = [ | |
| 83 'systrace.sh-8170 [001] 15180.978813: sched_switch: ' + | |
| 84 'prev_comm=systrace.sh prev_pid=8170 prev_prio=120 ' + | |
| 85 'prev_state=x ==> next_comm=kworker/1:0 next_pid=7873 ' + | |
| 86 'next_prio=120', | |
| 87 ' kworker/1:0-7873 [001] 15180.978836: sched_switch: ' + | |
| 88 'prev_comm=kworker/1:0 prev_pid=7873 prev_prio=120 ' + | |
| 89 'prev_state=S ==> next_comm=debugd next_pid=4404 next_prio=120', | |
| 90 ' debugd-4404 [001] 15180.979010: sched_switch: prev_comm=debugd ' + | |
| 91 'prev_pid=4404 prev_prio=120 prev_state=S ==> ' + | |
| 92 'next_comm=dbus-daemon next_pid=510 next_prio=120', | |
| 93 'systrace.sh-8182 [000] 15186.203900: tracing_mark_write: ' + | |
| 94 'trace_event_clock_sync: parent_ts=0.0' | |
| 95 ].join('\n'); | |
| 96 | |
| 97 /* This test just instantiates a ProflingView and adds it to the DOM | |
| 98 * to help with non-unittest UI work. | |
| 99 */ | |
| 100 function testInstantiate() { | |
| 101 var view = new tracing.ProfilingView(); | |
| 102 view.tracingController = new FakeTracingController(); | |
| 103 view.focusElement = view; | |
| 104 document.body.appendChild(view); | |
| 105 } | |
| 106 | |
| 107 function recordTestCommon() { | |
| 108 var view = new tracing.ProfilingView(); | |
| 109 var tracingController = new FakeTracingController() | |
| 110 view.tracingController = tracingController; | |
| 111 view.querySelector('button.record').click(); | |
| 112 assertTrue(tracingController.wasBeginTracingCalled); | |
| 113 assertEquals(cr.isChromeOS, | |
| 114 tracingController.wasBeginTracingCalledWithSystemTracingEnabl
ed); | |
| 115 | |
| 116 var e = new cr.Event('traceEnded'); | |
| 117 var didRefresh = false; | |
| 118 e.events = tracingController.traceEvents; | |
| 119 tracingController.dispatchEvent(e); | |
| 120 assertTrue(!!view.timelineView.model); | |
| 121 } | |
| 122 | |
| 123 function testRecordNonCros() { | |
| 124 var old = cr.isChromeOS; | |
| 125 cr.isChromeOS = false; | |
| 126 try { | |
| 127 recordTestCommon(); | |
| 128 } finally { | |
| 129 cr.isChromeOS = old; | |
| 130 } | |
| 131 } | |
| 132 | |
| 133 function testRecordCros() { | |
| 134 var old = cr.isChromeOS; | |
| 135 cr.isChromeOS = true; | |
| 136 try { | |
| 137 recordTestCommon(); | |
| 138 } finally { | |
| 139 cr.isChromeOS = old; | |
| 140 } | |
| 141 } | |
| 142 | |
| 143 </script> | |
| 144 </body> | |
| 145 </html> | |
| OLD | NEW |