| OLD | NEW |
| 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>TimelineModel tests</title> | 9 <title>TimelineModel 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="timeline_model.js"></script> | 14 <script src="timeline_model.js"></script> |
| 14 <script> | 15 <script> |
| 15 goog.require('goog.testing.jsunit'); | 16 goog.require('goog.testing.jsunit'); |
| 16 </script> | 17 </script> |
| 17 | 18 |
| 18 </head> | 19 </head> |
| 19 <body> | 20 <body> |
| 20 <script> | 21 <script> |
| 21 'use strict'; | 22 'use strict'; |
| 22 var TimelineCpu = tracing.TimelineCpu; | 23 var TimelineCpu = tracing.TimelineCpu; |
| 23 var TimelineSlice = tracing.TimelineSlice; | 24 var TimelineSlice = tracing.TimelineSlice; |
| 24 var TimelineThreadSlice = tracing.TimelineThreadSlice; | 25 var TimelineThreadSlice = tracing.TimelineThreadSlice; |
| 25 var TimelineProcess = tracing.TimelineProcess; | 26 var TimelineProcess = tracing.TimelineProcess; |
| 26 var TimelineThread = tracing.TimelineThread; | 27 var TimelineThread = tracing.TimelineThread; |
| 27 var TimelineModel = tracing.TimelineModel; | 28 var TimelineModel = tracing.TimelineModel; |
| 29 var TimelineFilter = tracing.TimelineFilter; |
| 28 var TimelineAsyncSlice = tracing.TimelineAsyncSlice; | 30 var TimelineAsyncSlice = tracing.TimelineAsyncSlice; |
| 29 var TimelineAsyncSliceGroup = tracing.TimelineAsyncSliceGroup; | 31 var TimelineAsyncSliceGroup = tracing.TimelineAsyncSliceGroup; |
| 30 | 32 var newAsyncSlice = test_utils.newAsyncSlice; |
| 31 // Helper function to create a slice. | |
| 32 function newAsyncSlice(start, duration, startThread, endThread) { | |
| 33 var s = new TimelineAsyncSlice('a', 0, start); | |
| 34 s.duration = duration; | |
| 35 s.startThread = startThread; | |
| 36 s.endThread = endThread; | |
| 37 var subSlice = new TimelineAsyncSlice('a', 0, start); | |
| 38 subSlice.duration = duration; | |
| 39 subSlice.startThread = startThread; | |
| 40 subSlice.endThread = endThread; | |
| 41 s.subSlices = [subSlice]; | |
| 42 return s; | |
| 43 } | |
| 44 | 33 |
| 45 function testThreadBounds_Empty() { | 34 function testThreadBounds_Empty() { |
| 46 var t = new TimelineThread(new TimelineProcess(7), 1); | 35 var t = new TimelineThread(new TimelineProcess(7), 1); |
| 47 t.updateBounds(); | 36 t.updateBounds(); |
| 48 assertEquals(undefined, t.minTimestamp); | 37 assertEquals(undefined, t.minTimestamp); |
| 49 assertEquals(undefined, t.maxTimestamp); | 38 assertEquals(undefined, t.maxTimestamp); |
| 50 } | 39 } |
| 51 | 40 |
| 52 function testThreadBounds_SubRow() { | 41 function testThreadBounds_SubRow() { |
| 53 var t = new TimelineThread(new TimelineProcess(7), 1); | 42 var t = new TimelineThread(new TimelineProcess(7), 1); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 assertEquals(g.name, subGroups[1].name); | 230 assertEquals(g.name, subGroups[1].name); |
| 242 assertEquals(1, subGroups[1].slices.length); | 231 assertEquals(1, subGroups[1].slices.length); |
| 243 assertEquals(g.slices[1], subGroups[1].slices[0]); | 232 assertEquals(g.slices[1], subGroups[1].slices[0]); |
| 244 } | 233 } |
| 245 | 234 |
| 246 function testModelCanImportEmpty() { | 235 function testModelCanImportEmpty() { |
| 247 var m; | 236 var m; |
| 248 m = new TimelineModel([]); | 237 m = new TimelineModel([]); |
| 249 m = new TimelineModel(''); | 238 m = new TimelineModel(''); |
| 250 } | 239 } |
| 240 |
| 241 function testTimelineFilter() { |
| 242 var s0 = new TimelineSlice('a', 0, 1, {}, 3); |
| 243 assertFalse(new TimelineFilter('').matchSlice(s0)); |
| 244 |
| 245 assertTrue(new TimelineFilter('a').matchSlice(s0)); |
| 246 assertFalse(new TimelineFilter('x').matchSlice(s0)); |
| 247 |
| 248 var s1 = new TimelineSlice('ba', 0, 1, {}, 3); |
| 249 assertTrue(new TimelineFilter('a').matchSlice(s1)); |
| 250 assertTrue(new TimelineFilter('ba').matchSlice(s1)); |
| 251 assertFalse(new TimelineFilter('x').matchSlice(s1)); |
| 252 } |
| 253 |
| 251 </script> | 254 </script> |
| 252 </body> | 255 </body> |
| 253 </html> | 256 </html> |
| OLD | NEW |