summaryrefslogtreecommitdiff
path: root/chromium/third_party/catapult/tracing/tracing/ui/analysis/selection_summary_table_test.html
blob: 5c1f1691efd6b90e27230fbe4896cc2b6f745ce7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<!--
Copyright (c) 2013 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="/tracing/core/test_utils.html">
<link rel="import" href="/tracing/model/event_set.html">
<link rel="import" href="/tracing/model/model.html">
<link rel="import" href="/tracing/ui/analysis/selection_summary_table.html">
<link rel="import" href="/tracing/ui/base/deep_utils.html">
<link rel="import" href="/tracing/value/unit.html">

<script>
'use strict';

tr.b.unittest.testSuite(function() {
  var Model = tr.Model;
  var EventSet = tr.model.EventSet;
  var newSliceEx = tr.c.TestUtils.newSliceEx;

  test('noSelection', function() {
    var summaryTable =
        document.createElement('tr-ui-a-selection-summary-table');
    summaryTable.selection = undefined;
    this.addHTMLOutput(summaryTable);

    var tableEl = tr.b.findDeepElementMatching(
        summaryTable, 'tr-ui-b-table');
    assert.equal(tableEl.tableRows[0].value, '<empty>');
    assert.equal(tableEl.tableRows[1].value, '<empty>');
  });

  test('emptySelection', function() {
    var summaryTable =
        document.createElement('tr-ui-a-selection-summary-table');
    var selection = new EventSet();
    summaryTable.selection = selection;
    this.addHTMLOutput(summaryTable);

    var tableEl = tr.b.findDeepElementMatching(
        summaryTable, 'tr-ui-b-table');
    assert.equal(tableEl.tableRows[0].value, '<empty>');
    assert.equal(tableEl.tableRows[1].value, '<empty>');
  });

  test('selection', function() {
    var model = new Model();
    var thread = model.getOrCreateProcess(1).getOrCreateThread(2);
    var tsg = thread.sliceGroup;

    tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3}));
    tsg.pushSlice(newSliceEx({title: 'b', start: 1, end: 2}));

    var selection = new EventSet();
    selection.push(tsg.slices[0]);
    selection.push(tsg.slices[1]);

    var summaryTable =
        document.createElement('tr-ui-a-selection-summary-table');
    summaryTable.selection = selection;
    this.addHTMLOutput(summaryTable);

    var tableEl = tr.b.findDeepElementMatching(
        summaryTable, 'tr-ui-b-table');
    assert.equal(tableEl.tableRows[0].value.value, 0);
    assert.strictEqual(tableEl.tableRows[0].value.unit,
        tr.v.Unit.byName.timeStampInMs);
    assert.equal(tableEl.tableRows[1].value.value, 3);
    assert.strictEqual(tableEl.tableRows[1].value.unit,
        tr.v.Unit.byName.timeDurationInMs);
  });
});
</script>