interaction_track_test.html revision 46b43bff003ceda46cf9a5d40a47f7674996d2e0
1<!DOCTYPE html>
2<!--
3Copyright (c) 2015 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7
8<link rel="import" href="/tracing/core/test_utils.html">
9<link rel="import" href="/tracing/model/model.html">
10<link rel="import" href="/tracing/ui/timeline_viewport.html">
11<link rel="import" href="/tracing/ui/tracks/interaction_track.html">
12
13<script>
14'use strict';
15
16tr.b.unittest.testSuite(function() {
17  // InteractionRecords should be sorted by start time, not title, so that
18  // AsyncSliceGroupTrack.buildSubRows_ can lay them out in as few tracks as
19  // possible, so that they mesh instead of stacking unnecessarily.
20  test('instantiate', function() {
21    var div = document.createElement('div');
22    var viewport = new tr.ui.TimelineViewport(div);
23    var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport);
24    div.appendChild(drawingContainer);
25    var track = new tr.ui.tracks.InteractionTrack(viewport);
26    track.model = tr.c.TestUtils.newModel(function(model) {
27      var process = model.getOrCreateProcess(1);
28      var thread = process.getOrCreateThread(1);
29      thread.sliceGroup.pushSlice(tr.c.TestUtils.newSlice(0, 200));
30      model.interactionRecords.push(new tr.model.InteractionRecord(
31            'a', 0, 100, 100));
32      model.interactionRecords.push(new tr.model.InteractionRecord(
33            'b', 1, 0, 100));
34      model.interactionRecords.push(new tr.model.InteractionRecord(
35            'c', 2, 150, 50));
36      model.interactionRecords.push(new tr.model.InteractionRecord(
37            'd', 3, 50, 100));
38      model.interactionRecords.push(new tr.model.InteractionRecord(
39            'e', 4, 0, 50));
40      // Model.createImportTracesTask() automatically sorts IRs by start time.
41    });
42    assert.equal(2, track.subRows_.length);
43    assert.equal(2, track.subRows_[0].length);
44    assert.equal(3, track.subRows_[1].length);
45    drawingContainer.appendChild(track);
46    this.addHTMLOutput(div);
47  });
48});
49</script>
50