Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <!-- | 3 <!-- |
| 4 Copyright (c) 2010 The Chromium Authors. All rights reserved. | 4 Copyright (c) 2010 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> |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 var p = m.processes[1]; | 92 var p = m.processes[1]; |
| 93 var t = p.threads[1]; | 93 var t = p.threads[1]; |
| 94 var subRow = t.subRows[0]; | 94 var subRow = t.subRows[0]; |
| 95 var slice = subRow[0]; | 95 var slice = subRow[0]; |
| 96 assertEquals('a', slice.title); | 96 assertEquals('a', slice.title); |
| 97 assertTrue(slice.didNotFinish); | 97 assertTrue(slice.didNotFinish); |
| 98 assertEquals(0, slice.start); | 98 assertEquals(0, slice.start); |
| 99 assertEquals((2 - 1) / 1000, slice.duration); | 99 assertEquals((2 - 1) / 1000, slice.duration); |
| 100 } | 100 } |
| 101 | 101 |
| 102 function testAutoclosingLoneBegin() { | |
| 103 var events = [ | |
| 104 // Slice that doesn't finish. | |
| 105 {name: 'a', args: {}, pid: 1, ts: 1, cat: 'foo', tid: 1, ph: 'B'} | |
| 106 ]; | |
| 107 var m = new tracing.TimelineModel(events); | |
| 108 var p = m.processes[1]; | |
| 109 var t = p.threads[1]; | |
| 110 var subRow = t.subRows[0]; | |
| 111 var slice = subRow[0]; | |
| 112 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
| |
| 113 assertTrue(slice.didNotFinish); | |
| 114 assertEquals(0, slice.start); | |
| 115 assertEquals(0, slice.duration); | |
| 116 } | |
| 117 | |
| 118 function testAutoclosingWithSubTasks() { | |
| 119 var events = [ | |
| 120 {name: 'a', args: {}, pid: 1, ts: 1, cat: 'foo', tid: 1, ph: 'B'}, | |
| 121 {name: 'b1', args: {}, pid: 1, ts: 2, cat: 'foo', tid: 1, ph: 'B'}, | |
| 122 {name: 'b1', args: {}, pid: 1, ts: 3, cat: 'foo', tid: 1, ph: 'E'}, | |
| 123 {name: 'b2', args: {}, pid: 1, ts: 3, cat: 'foo', tid: 1, ph: 'B'} | |
| 124 ]; | |
| 125 var m = new tracing.TimelineModel(events); | |
| 126 var p = m.processes[1]; | |
| 127 var t = p.threads[1]; | |
| 128 assertEquals(2, t.subRows.length); | |
| 129 assertEquals(1, t.subRows[0].length); | |
| 130 assertEquals(2, t.subRows[1].length); | |
| 131 } | |
| 132 | |
| 133 function testAutoclosingWithEventsOutsideRange() { | |
| 134 var events = [ | |
| 135 // Slice that begins before min and ends after max of the other threads. | |
| 136 {name: 'a', args: {}, pid: 1, ts: 0, cat: 'foo', tid: 1, ph: 'B'}, | |
| 137 {name: 'a', args: {}, pid: 1, ts: 3, cat: 'foo', tid: 1, ph: 'B'}, | |
| 138 | |
| 139 // Slice that does finish to give an 'end time' to establish a basis | |
| 140 {name: 'b', args: {}, pid: 1, ts: 1, cat: 'foo', tid: 2, ph: 'B'}, | |
| 141 {name: 'b', args: {}, pid: 1, ts: 2, cat: 'foo', tid: 2, ph: 'E'} | |
| 142 ]; | |
| 143 var m = new tracing.TimelineModel(events); | |
| 144 var p = m.processes[1]; | |
| 145 var t = p.threads[1]; | |
| 146 var subRow = t.subRows[0]; | |
| 147 assertEquals('a', subRow[0].title); | |
| 148 assertEquals(0, subRow[0].start); | |
| 149 assertEquals(0.003, subRow[0].duration); | |
| 150 | |
| 151 var t = p.threads[2]; | |
| 152 var subRow = t.subRows[0]; | |
| 153 assertEquals('b', subRow[0].title); | |
| 154 assertEquals(0.001, subRow[0].start); | |
| 155 assertEquals(0.001, subRow[0].duration); | |
| 156 | |
| 157 // 0.00345 instead of 0.003 because TimelineModel bloats the world range by | |
| 158 // 15%. | |
| 159 assertEquals(-0.00045, m.minTimestamp); | |
| 160 assertEquals(0.00345, m.maxTimestamp); | |
| 161 | |
| 162 } | |
| 102 | 163 |
| 103 function testNestedAutoclosing() { | 164 function testNestedAutoclosing() { |
| 104 var events = [ | 165 var events = [ |
| 105 // Tasks that dont finish. | 166 // Tasks that dont finish. |
| 106 {name: 'a1', args: {}, pid: 1, ts: 1, cat: 'foo', tid: 1, ph: 'B'}, | 167 {name: 'a1', args: {}, pid: 1, ts: 1, cat: 'foo', tid: 1, ph: 'B'}, |
| 107 {name: 'a2', args: {}, pid: 1, ts: 1.5, cat: 'foo', tid: 1, ph: 'B'}, | 168 {name: 'a2', args: {}, pid: 1, ts: 1.5, cat: 'foo', tid: 1, ph: 'B'}, |
| 108 | 169 |
| 109 // Slice that does finish to give an 'end time' to make autoclosing work. | 170 // Slice that does finish to give an 'end time' to make autoclosing work. |
| 110 {name: 'b', args: {}, pid: 1, ts: 1, cat: 'foo', tid: 2, ph: 'B'}, | 171 {name: 'b', args: {}, pid: 1, ts: 1, cat: 'foo', tid: 2, ph: 'B'}, |
| 111 {name: 'b', args: {}, pid: 1, ts: 2, cat: 'foo', tid: 2, ph: 'E'} | 172 {name: 'b', args: {}, pid: 1, ts: 2, cat: 'foo', tid: 2, ph: 'E'} |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 0, 1], ctr.samples); | 485 0, 1], ctr.samples); |
| 425 assertArrayEquals([0, 7, | 486 assertArrayEquals([0, 7, |
| 426 10, 14, | 487 10, 14, |
| 427 0, 1], ctr.totals); | 488 0, 1], ctr.totals); |
| 428 assertEquals(14, ctr.maxTotal); | 489 assertEquals(14, ctr.maxTotal); |
| 429 } | 490 } |
| 430 | 491 |
| 431 </script> | 492 </script> |
| 432 </body> | 493 </body> |
| 433 </html> | 494 </html> |
| OLD | NEW |