Index: chrome/browser/resources/tracing/timeline_test.html |
diff --git a/chrome/browser/resources/tracing/timeline_test.html b/chrome/browser/resources/tracing/timeline_test.html |
index f6b718ce02f1f83dfcc9d9490996d34e87120894..0f1424fa85cb5e68af9d08aa8b1d222a2c4dcec8 100644 |
--- a/chrome/browser/resources/tracing/timeline_test.html |
+++ b/chrome/browser/resources/tracing/timeline_test.html |
@@ -53,10 +53,12 @@ found in the LICENSE file. |
model.importEvents(events); |
var timeline = new tracing.Timeline(); |
timeline.model = model; |
+ timeline.focusElement = timeline; |
+ timeline.tabIndex = 0; |
document.body.appendChild(timeline); |
} |
- function testFindAllObjectsMatching() { |
+ function testAddAllObjectsMatchingFilterToSelection() { |
var model = new tracing.TimelineModel(); |
var p1 = model.getOrCreateProcess(1); |
var t1 = p1.getOrCreateThread(1); |
@@ -74,19 +76,62 @@ found in the LICENSE file. |
var expected = [{slice: t1asg.slices[0].subSlices[0]}, |
{slice: t1.subRows[0][0]}]; |
- var result = timeline.findAllObjectsMatchingFilter(new tracing.TimelineFilter('a')); |
+ var result = new tracing.TimelineSelection(); |
+ timeline.addAllObjectsMatchingFilterToSelection(new tracing.TimelineFilter('a'), result); |
assertEquals(2, result.length); |
assertEquals(expected[0].slice, result[0].slice); |
assertEquals(expected[1].slice, result[1].slice); |
var expected = [{slice: t1asg.slices[1].subSlices[0]}, |
{slice: t1.subRows[0][1]}]; |
- var result = timeline.findAllObjectsMatchingFilter(new tracing.TimelineFilter('b')); |
+ var result = new tracing.TimelineSelection(); |
+ timeline.addAllObjectsMatchingFilterToSelection(new tracing.TimelineFilter('b'), result); |
assertEquals(2, result.length); |
assertEquals(expected[0].slice, result[0].slice); |
assertEquals(expected[1].slice, result[1].slice); |
} |
+ function testSelectionObject() { |
+ var model = new tracing.TimelineModel(); |
+ var p1 = model.getOrCreateProcess(1); |
+ var t1 = p1.getOrCreateThread(1); |
+ t1.subRows[0].push(new tracing.TimelineThreadSlice('a', 0, 1, {}, 3)); |
+ t1.subRows[0].push(new tracing.TimelineThreadSlice('a', 0, 5, {}, 1)); |
+ |
+ var sel = new tracing.TimelineSelection(); |
+ sel.addSlice({}, t1.subRows[0][0]); |
+ |
+ assertEquals(1, sel.range.min); |
+ assertEquals(4, sel.range.max); |
+ assertEquals(t1.subRows[0][0], sel[0].slice); |
+ |
+ sel.addSlice({}, t1.subRows[0][1]); |
+ assertEquals(1, sel.range.min); |
+ assertEquals(6, sel.range.max); |
+ assertEquals(t1.subRows[0][1], sel[1].slice); |
+ |
+ sel.clear(); |
+ assertEquals(0, sel.length); |
+ } |
+ |
+ function testShiftedSelection() { |
+ var model = new tracing.TimelineModel(); |
+ var p1 = model.getOrCreateProcess(1); |
+ var t1 = p1.getOrCreateThread(1); |
+ t1.subRows[0].push(new tracing.TimelineThreadSlice('a', 0, 1, {}, 3)); |
+ t1.subRows[0].push(new tracing.TimelineThreadSlice('a', 0, 5, {}, 1)); |
+ |
+ var track = new tracing.TimelineSliceTrack(); |
+ track.slices = t1.subRows[0]; |
+ |
+ var sel = new tracing.TimelineSelection(); |
+ sel.addSlice(track, t1.subRows[0][0]); |
+ |
+ var shifted = sel.getShiftedSelection(1); |
+ assertEquals(1, shifted.length); |
+ assertEquals(t1.subRows[0][1], shifted[0].slice); |
+ } |
+ |
</script> |
</body> |
</html> |