blob: e5f91a639f392a8360493deeee267ad5163c17e4 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/core/location.html">
<link rel="import" href="/core/timeline_track_view.html">
<link rel="import" href="/core/timeline_viewport.html">
<link rel="import" href="/core/test_utils.html">
<link rel="import" href="/model/comment_box_annotation.html">
<link rel="import" href="/model/rect_annotation.html">
<link rel="import" href="/model/model.html">
<link rel="import" href="/model/x_marker_annotation.html">
<script>
'use strict';
tr.b.unittest.testSuite(function() {
function createPopulatedTimeline() {
var model = new tr.Model();
var process = model.getOrCreateProcess(1);
var thread = process.getOrCreateThread(2);
thread.sliceGroup.pushSlice(tr.c.test_utils.newSliceNamed('a', 80, 50));
var timeline = new tr.c.TimelineTrackView();
var vp = new tr.c.TimelineViewport(timeline);
timeline.model = model;
timeline.focusElement = timeline;
timeline.tabIndex = 0;
timeline.style.maxHeight = '600px';
return timeline;
}
test('rectAnnotation', function() {
var fakeYComponents1 = [{stableId: '1.2', yPercentOffset: 0.3}];
var fakeYComponents2 = [{stableId: '1.2', yPercentOffset: 0.9}];
var start = new tr.c.Location(50, fakeYComponents1);
var end = new tr.c.Location(100, fakeYComponents2);
var rectAnnotation = new tr.model.RectAnnotation(start, end);
assert.equal(rectAnnotation.startLocation, start);
assert.equal(rectAnnotation.endLocation, end);
var timeline = createPopulatedTimeline();
timeline.model.addAnnotation(rectAnnotation);
this.addHTMLOutput(timeline);
});
test('xMarkerAnnotation', function() {
var xMarkerAnnotation = new tr.model.XMarkerAnnotation(90);
assert.equal(xMarkerAnnotation.timestamp, 90);
var timeline = createPopulatedTimeline();
var model = timeline.model;
timeline.model.addAnnotation(xMarkerAnnotation);
this.addHTMLOutput(timeline);
});
test('commentBoxAnnotation', function() {
var fakeYComponents = [{stableId: '1.2', yPercentOffset: 0.5}];
var location = new tr.c.Location(120, fakeYComponents);
var text = 'abc';
var commentBoxAnnotation =
new tr.model.CommentBoxAnnotation(location, text);
assert.equal(commentBoxAnnotation.location, location);
assert.equal(commentBoxAnnotation.text, text);
var timeline = createPopulatedTimeline();
timeline.model.addAnnotation(commentBoxAnnotation);
this.addHTMLOutput(timeline);
});
});
</script>