| 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 i18n-values="dir:textdirection;"> | 8 <head i18n-values="dir:textdirection;"> |
| 9 <title>Timeline tests</title> | 9 <title>Timeline tests</title> |
| 10 <link rel="stylesheet" href="overlay.css"> | 10 <link rel="stylesheet" href="overlay.css"> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 var events = [ | 46 var events = [ |
| 47 {name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'}, | 47 {name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'}, |
| 48 {name: 'a', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'E'}, | 48 {name: 'a', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'E'}, |
| 49 {name: 'b', args: {}, pid: 52, ts: 629, cat: 'foo', tid: 53, ph: 'B'}, | 49 {name: 'b', args: {}, pid: 52, ts: 629, cat: 'foo', tid: 53, ph: 'B'}, |
| 50 {name: 'b', args: {}, pid: 52, ts: 631, cat: 'foo', tid: 53, ph: 'E'} | 50 {name: 'b', args: {}, pid: 52, ts: 631, cat: 'foo', tid: 53, ph: 'E'} |
| 51 ]; | 51 ]; |
| 52 var model = new tracing.TimelineModel(); | 52 var model = new tracing.TimelineModel(); |
| 53 model.importEvents(events); | 53 model.importEvents(events); |
| 54 var timeline = new tracing.Timeline(); | 54 var timeline = new tracing.Timeline(); |
| 55 timeline.model = model; | 55 timeline.model = model; |
| 56 timeline.focusElement = timeline; |
| 57 timeline.tabIndex = 0; |
| 56 document.body.appendChild(timeline); | 58 document.body.appendChild(timeline); |
| 57 } | 59 } |
| 58 | 60 |
| 59 function testFindAllObjectsMatching() { | 61 function testAddAllObjectsMatchingFilterToSelection() { |
| 60 var model = new tracing.TimelineModel(); | 62 var model = new tracing.TimelineModel(); |
| 61 var p1 = model.getOrCreateProcess(1); | 63 var p1 = model.getOrCreateProcess(1); |
| 62 var t1 = p1.getOrCreateThread(1); | 64 var t1 = p1.getOrCreateThread(1); |
| 63 | 65 |
| 64 t1.subRows[0].push(new tracing.TimelineThreadSlice('a', 0, 1, {}, 3)); | 66 t1.subRows[0].push(new tracing.TimelineThreadSlice('a', 0, 1, {}, 3)); |
| 65 t1.subRows[0].push(new tracing.TimelineThreadSlice('b', 0, 1, {}, 3)); | 67 t1.subRows[0].push(new tracing.TimelineThreadSlice('b', 0, 1, {}, 3)); |
| 66 | 68 |
| 67 var t1asg = t1.asyncSlices; | 69 var t1asg = t1.asyncSlices; |
| 68 t1asg.slices.push(test_utils.newAsyncSliceNamed('a', 0, 1, t1, t1)); | 70 t1asg.slices.push(test_utils.newAsyncSliceNamed('a', 0, 1, t1, t1)); |
| 69 t1asg.slices.push(test_utils.newAsyncSliceNamed('b', 1, 2, t1, t1)); | 71 t1asg.slices.push(test_utils.newAsyncSliceNamed('b', 1, 2, t1, t1)); |
| 70 | 72 |
| 71 | 73 |
| 72 var timeline = new tracing.Timeline(); | 74 var timeline = new tracing.Timeline(); |
| 73 timeline.model = model; | 75 timeline.model = model; |
| 74 | 76 |
| 75 var expected = [{slice: t1asg.slices[0].subSlices[0]}, | 77 var expected = [{slice: t1asg.slices[0].subSlices[0]}, |
| 76 {slice: t1.subRows[0][0]}]; | 78 {slice: t1.subRows[0][0]}]; |
| 77 var result = timeline.findAllObjectsMatchingFilter(new tracing.TimelineFil
ter('a')); | 79 var result = new tracing.TimelineSelection(); |
| 80 timeline.addAllObjectsMatchingFilterToSelection(new tracing.TimelineFilter
('a'), result); |
| 78 assertEquals(2, result.length); | 81 assertEquals(2, result.length); |
| 79 assertEquals(expected[0].slice, result[0].slice); | 82 assertEquals(expected[0].slice, result[0].slice); |
| 80 assertEquals(expected[1].slice, result[1].slice); | 83 assertEquals(expected[1].slice, result[1].slice); |
| 81 | 84 |
| 82 var expected = [{slice: t1asg.slices[1].subSlices[0]}, | 85 var expected = [{slice: t1asg.slices[1].subSlices[0]}, |
| 83 {slice: t1.subRows[0][1]}]; | 86 {slice: t1.subRows[0][1]}]; |
| 84 var result = timeline.findAllObjectsMatchingFilter(new tracing.TimelineFil
ter('b')); | 87 var result = new tracing.TimelineSelection(); |
| 88 timeline.addAllObjectsMatchingFilterToSelection(new tracing.TimelineFilter
('b'), result); |
| 85 assertEquals(2, result.length); | 89 assertEquals(2, result.length); |
| 86 assertEquals(expected[0].slice, result[0].slice); | 90 assertEquals(expected[0].slice, result[0].slice); |
| 87 assertEquals(expected[1].slice, result[1].slice); | 91 assertEquals(expected[1].slice, result[1].slice); |
| 88 } | 92 } |
| 89 | 93 |
| 94 function testSelectionObject() { |
| 95 var model = new tracing.TimelineModel(); |
| 96 var p1 = model.getOrCreateProcess(1); |
| 97 var t1 = p1.getOrCreateThread(1); |
| 98 t1.subRows[0].push(new tracing.TimelineThreadSlice('a', 0, 1, {}, 3)); |
| 99 t1.subRows[0].push(new tracing.TimelineThreadSlice('a', 0, 5, {}, 1)); |
| 100 |
| 101 var sel = new tracing.TimelineSelection(); |
| 102 sel.addSlice({}, t1.subRows[0][0]); |
| 103 |
| 104 assertEquals(1, sel.range.min); |
| 105 assertEquals(4, sel.range.max); |
| 106 assertEquals(t1.subRows[0][0], sel[0].slice); |
| 107 |
| 108 sel.addSlice({}, t1.subRows[0][1]); |
| 109 assertEquals(1, sel.range.min); |
| 110 assertEquals(6, sel.range.max); |
| 111 assertEquals(t1.subRows[0][1], sel[1].slice); |
| 112 |
| 113 sel.clear(); |
| 114 assertEquals(0, sel.length); |
| 115 } |
| 116 |
| 117 function testShiftedSelection() { |
| 118 var model = new tracing.TimelineModel(); |
| 119 var p1 = model.getOrCreateProcess(1); |
| 120 var t1 = p1.getOrCreateThread(1); |
| 121 t1.subRows[0].push(new tracing.TimelineThreadSlice('a', 0, 1, {}, 3)); |
| 122 t1.subRows[0].push(new tracing.TimelineThreadSlice('a', 0, 5, {}, 1)); |
| 123 |
| 124 var track = new tracing.TimelineSliceTrack(); |
| 125 track.slices = t1.subRows[0]; |
| 126 |
| 127 var sel = new tracing.TimelineSelection(); |
| 128 sel.addSlice(track, t1.subRows[0][0]); |
| 129 |
| 130 var shifted = sel.getShiftedSelection(1); |
| 131 assertEquals(1, shifted.length); |
| 132 assertEquals(t1.subRows[0][1], shifted[0].slice); |
| 133 } |
| 134 |
| 90 </script> | 135 </script> |
| 91 </body> | 136 </body> |
| 92 </html> | 137 </html> |
| OLD | NEW |