Index: chrome/browser/resources/tracing/timeline_model_test.html |
diff --git a/chrome/browser/resources/tracing/timeline_model_test.html b/chrome/browser/resources/tracing/timeline_model_test.html |
index b6bb2c8b30151f7d6a0a60cb465ef930dab9ab01..f0a7a5aa22bc34dfe74d5513720240f503b09a36 100644 |
--- a/chrome/browser/resources/tracing/timeline_model_test.html |
+++ b/chrome/browser/resources/tracing/timeline_model_test.html |
@@ -99,6 +99,67 @@ function testAutoclosing() { |
assertEquals((2 - 1) / 1000, slice.duration); |
} |
+function testAutoclosingLoneBegin() { |
+ var events = [ |
+ // Slice that doesn't finish. |
+ {name: 'a', args: {}, pid: 1, ts: 1, cat: 'foo', tid: 1, ph: 'B'} |
+ ]; |
+ var m = new tracing.TimelineModel(events); |
+ var p = m.processes[1]; |
+ var t = p.threads[1]; |
+ var subRow = t.subRows[0]; |
+ var slice = subRow[0]; |
+ assertEquals('a', slice.title); |
James Hawkins
2011/12/01 17:12:49
expectX for all of these.
nduca
2011/12/01 17:30:33
Closure jsunit doesn't have expect. :'(
James Hawkins
2011/12/01 17:49:24
Hmm, expectEquals is used on line 29 of this file
|
+ assertTrue(slice.didNotFinish); |
+ assertEquals(0, slice.start); |
+ assertEquals(0, slice.duration); |
+} |
+ |
+function testAutoclosingWithSubTasks() { |
+ var events = [ |
+ {name: 'a', args: {}, pid: 1, ts: 1, cat: 'foo', tid: 1, ph: 'B'}, |
+ {name: 'b1', args: {}, pid: 1, ts: 2, cat: 'foo', tid: 1, ph: 'B'}, |
+ {name: 'b1', args: {}, pid: 1, ts: 3, cat: 'foo', tid: 1, ph: 'E'}, |
+ {name: 'b2', args: {}, pid: 1, ts: 3, cat: 'foo', tid: 1, ph: 'B'} |
+ ]; |
+ var m = new tracing.TimelineModel(events); |
+ var p = m.processes[1]; |
+ var t = p.threads[1]; |
+ assertEquals(2, t.subRows.length); |
+ assertEquals(1, t.subRows[0].length); |
+ assertEquals(2, t.subRows[1].length); |
+} |
+ |
+function testAutoclosingWithEventsOutsideRange() { |
+ var events = [ |
+ // Slice that begins before min and ends after max of the other threads. |
+ {name: 'a', args: {}, pid: 1, ts: 0, cat: 'foo', tid: 1, ph: 'B'}, |
+ {name: 'a', args: {}, pid: 1, ts: 3, cat: 'foo', tid: 1, ph: 'B'}, |
+ |
+ // Slice that does finish to give an 'end time' to establish a basis |
+ {name: 'b', args: {}, pid: 1, ts: 1, cat: 'foo', tid: 2, ph: 'B'}, |
+ {name: 'b', args: {}, pid: 1, ts: 2, cat: 'foo', tid: 2, ph: 'E'} |
+ ]; |
+ var m = new tracing.TimelineModel(events); |
+ var p = m.processes[1]; |
+ var t = p.threads[1]; |
+ var subRow = t.subRows[0]; |
+ assertEquals('a', subRow[0].title); |
+ assertEquals(0, subRow[0].start); |
+ assertEquals(0.003, subRow[0].duration); |
+ |
+ var t = p.threads[2]; |
+ var subRow = t.subRows[0]; |
+ assertEquals('b', subRow[0].title); |
+ assertEquals(0.001, subRow[0].start); |
+ assertEquals(0.001, subRow[0].duration); |
+ |
+ // 0.00345 instead of 0.003 because TimelineModel bloats the world range by |
+ // 15%. |
+ assertEquals(-0.00045, m.minTimestamp); |
+ assertEquals(0.00345, m.maxTimestamp); |
+ |
+} |
function testNestedAutoclosing() { |
var events = [ |