2 Copyright 2014 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
7 <link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html">
9 <polymer-element name="ct-test-list" attributes="tests">
17 /* Be at least the height of a paper-icon-button.
18 So things line up nicely. */
27 vertical-align: middle;
30 paper-icon-button::shadow #icon {
34 <template repeat="{{ groups in testGroups_ }}">
35 <template if="{{ groups.tests.length }}">
36 <div><span style="font-weight: bold">Step:</span> {{ groups.step }}</div>
39 <template repeat="{{ group in groups.tests | maybeTruncate(groups.expanded) }}">
40 <!-- Case 1: single test failure -->
41 <template if="{{ group.name && (group.tests.length == 1 || group.expanded) }}">
42 <template repeat="{{ test in group.tests }}">
43 <div class="test-failures">
44 <a href="{{ test | flakinessDashboardURL }}">{{ test.testName }}</a>
48 <!-- Case 2: group of tests failed -->
49 <template if="{{ group.name && group.tests.length > 1 && !group.expanded }}">
50 <div class="test-failures">
51 {{ group.name }} ({{ group.tests.length }} Tests)
52 <paper-icon-button id="expand" icon="unfold-more" step="{{ groups.step }}" group="{{ group.name }}" on-click="{{ _innerExpand }}"></paper-icon-button>
56 <template if="{{ !groups.expanded }}">
57 <div class="test-failures">
58 {{ groups.tests.length - kMaxTestsPerStep }} more
59 <paper-icon-button id="outerExpand" icon="unfold-more" step="{{ groups.step }}" on-click="{{ _outerExpand }}"></paper-icon-button>
65 Polymer('ct-test-list', {
68 testsChanged: function() {
71 this.tests.forEach(function(test) {
72 if (!groups[test.step])
73 groups[test.step] = {};
74 var testName = test.reasonGroupName();
75 if (!groups[test.step][testName])
76 groups[test.step][testName] = [];
77 groups[test.step][testName].push(test);
80 this.testGroups_ = [];
81 Object.keys(groups, function(step, testsByName) {
83 Object.keys(testsByName, function(name, testList) {
84 if (name == 'undefined')
86 tests.push({'name': name, 'tests': testList, 'expanded': false});
89 // The + 1 is to make sure at least 2 tests are hidden by the message.
90 this.testGroups_.push({'step': step, 'tests': tests, 'expanded': tests.length <= (this.kMaxTestsPerStep + 1)});
92 this.testGroups_.sortBy('step');
95 _innerExpand: function(evt) {
96 step = evt.target.attributes['step'].value;
97 name = evt.target.attributes['group'].value;
98 this.testGroups_.forEach(function(testGroup) {
99 if (testGroup.step == step) {
100 testGroup.tests.forEach(function(test) {
101 // FIXME: This attribute should be persisted over reloads.
102 if (test.name == name)
103 test.expanded = true;
109 _outerExpand: function(evt) {
110 var step = evt.target.attributes['step'].value;
111 this.testGroups_.forEach(function(testGroup) {
112 if (testGroup.step == step) {
113 testGroup.expanded = true;
118 flakinessDashboardURL: function(test) {
119 return test.flakinessDashboardURL();
122 // FIXME: Remove maybeTruncate. Persist the expanded list as described in
123 // http://crbug.com/417159.
124 maybeTruncate: function(input, expanded) {
127 return input.slice(0, this.kMaxTestsPerStep);