interaction_track_test.html revision cef7893435aa41160dd1255c43cb8498279738cc
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/model/user_model/stub_expectation.html">
11<link rel="import" href="/tracing/ui/timeline_viewport.html">
12<link rel="import" href="/tracing/ui/tracks/interaction_track.html">
13
14<script>
15'use strict';
16
17tr.b.unittest.testSuite(function() {
18  // UserExpectations should be sorted by start time, not title, so that
19  // AsyncSliceGroupTrack.buildSubRows_ can lay them out in as few tracks as
20  // possible, so that they mesh instead of stacking unnecessarily.
21  test('instantiate', function() {
22    var div = document.createElement('div');
23    var viewport = new tr.ui.TimelineViewport(div);
24    var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport);
25    div.appendChild(drawingContainer);
26    var track = new tr.ui.tracks.InteractionTrack(viewport);
27    track.model = tr.c.TestUtils.newModel(function(model) {
28      var process = model.getOrCreateProcess(1);
29      var thread = process.getOrCreateThread(1);
30      thread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx(
31          {start: 0, duration: 200}));
32      model.userModel.expectations.push(new tr.model.um.StubExpectation(
33          {parentModel: model, start: 100, duration: 100}));
34      model.userModel.expectations.push(new tr.model.um.StubExpectation(
35          {parentModel: model, start: 0, duration: 100}));
36      model.userModel.expectations.push(new tr.model.um.StubExpectation(
37          {parentModel: model, start: 150, duration: 50}));
38      model.userModel.expectations.push(new tr.model.um.StubExpectation(
39          {parentModel: model, start: 50, duration: 100}));
40      model.userModel.expectations.push(new tr.model.um.StubExpectation(
41          {parentModel: model, start: 0, duration: 50}));
42      // Model.createImportTracesTask() automatically sorts IRs by start time.
43    });
44    assert.equal(2, track.subRows_.length);
45    assert.equal(2, track.subRows_[0].length);
46    assert.equal(3, track.subRows_[1].length);
47    drawingContainer.appendChild(track);
48    this.addHTMLOutput(div);
49  });
50});
51</script>
52