| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. | 4 found in the LICENSE file. |
| 5 --> | 5 --><html><head><link rel="import" href="../bower_components/paper-icon-button/pa
per-icon-button.html"> |
| 6 | |
| 7 <link rel="import" href="../bower_components/paper-icon-button/paper-icon-button
.html"> | |
| 8 <link rel="import" href="ct-user-prefs.html"> | 6 <link rel="import" href="ct-user-prefs.html"> |
| 9 | 7 |
| 10 <polymer-element name="ct-test-list" attributes="tests"> | 8 <dom-module id="ct-test-list"> |
| 11 <template> | 9 <style> |
| 12 <style> | |
| 13 :host { | 10 :host { |
| 14 display: block; | 11 display: block; |
| 15 } | 12 } |
| 16 | 13 |
| 17 :host > div { | 14 :host > div { |
| 18 /* Be at least the height of a paper-icon-button. | 15 /* Be at least the height of a paper-icon-button. |
| 19 So things line up nicely. */ | 16 So things line up nicely. */ |
| 20 min-height: 24px; | 17 min-height: 24px; |
| 21 } | 18 } |
| 22 | 19 |
| 23 .test-failures { | 20 .test-failures { |
| 24 margin-left: 15px; | 21 margin-left: 15px; |
| 25 } | 22 } |
| 26 | 23 |
| 27 paper-icon-button { | 24 paper-icon-button { |
| 28 vertical-align: middle; | 25 vertical-align: middle; |
| 29 } | 26 } |
| 30 | 27 |
| 31 paper-icon-button::shadow #icon { | 28 paper-icon-button::shadow #icon { |
| 32 margin: 0; | 29 margin: 0; |
| 33 } | 30 } |
| 34 </style> | 31 </style> |
| 32 <template> |
| 35 <ct-user-prefs id="userPrefs"></ct-user-prefs> | 33 <ct-user-prefs id="userPrefs"></ct-user-prefs> |
| 36 <template repeat="{{ groups in testGroups_ }}"> | 34 <template is="dom-repeat" items="{{testGroups_}}" as="groups"> |
| 37 <template if="{{ groups.tests.length }}"> | 35 <template is="dom-if" if="{{ groups.tests.length }}"> |
| 38 <div><span style="font-weight: bold">Step:</span> {{ groups.step }}</div
> | 36 <div><span style="font-weight: bold">Step:</span> <span>{{ groups.step }
}</span></div> |
| 39 </template> | 37 </template> |
| 40 | 38 |
| 41 <template repeat="{{ group in groups.tests | maybeTruncate(groups.expanded
) }}"> | 39 <template is="dom-repeat" items="{{maybeTruncate(groups.tests, groups.expa
nded)}}" as="group"> |
| 42 <!-- Case 1: single test failure --> | 40 <!-- Case 1: single test failure --> |
| 43 <template if="{{ group.name && (group.tests.length == 1 || group.expande
d) }}"> | 41 <template is="dom-if" if="{{computeIf(group)}}"> |
| 44 <template repeat="{{ test in group.tests }}"> | 42 <template is="dom-repeat" items="{{group.tests}}" as="test"> |
| 45 <div class="test-failures"> | 43 <div class="test-failures"> |
| 46 <a target="{{ $.userPrefs.values.linkTarget }}" href="{{ test | fl
akinessDashboardURL }}">{{ test.testName }}</a> | 44 <a target="{{ $.userPrefs.values.linkTarget }}" href$="{{flakiness
DashboardURL ( test)}}">{{ test.testName }}</a> |
| 47 </div> | 45 </div> |
| 48 </template> | 46 </template> |
| 49 </template> | 47 </template> |
| 50 <!-- Case 2: group of tests failed --> | 48 <!-- Case 2: group of tests failed --> |
| 51 <template if="{{ group.name && group.tests.length > 1 && !group.expanded
}}"> | 49 <template is="dom-if" if="{{computeIf2(group)}}"> |
| 52 <div class="test-failures"> | 50 <div class="test-failures"> |
| 53 {{ group.name }} ({{ group.tests.length }} Tests) | 51 <span>{{ group.name }}</span> (<span>{{ group.tests.length }}</span>
Tests) |
| 54 <paper-icon-button id="expand" icon="unfold-more" step="{{ groups.st
ep }}" group="{{ group.name }}" on-click="{{ _innerExpand }}"></paper-icon-butto
n> | 52 <paper-icon-button id="expand" icon="unfold-more" step="{{ groups.st
ep }}" group="{{ group.name }}" on-click=" _innerExpand "></paper-icon-button> |
| 55 </div> | 53 </div> |
| 56 </template> | 54 </template> |
| 57 </template> | 55 </template> |
| 58 <template if="{{ !groups.expanded }}"> | 56 <template is="dom-if" if="{{ !groups.expanded }}"> |
| 59 <div class="test-failures"> | 57 <div class="test-failures"> |
| 60 {{ groups.tests.length - kMaxTestsPerStep }} more | 58 <span>{{computeExpression5(groups, kMaxTestsPerStep)}}</span> more |
| 61 <paper-icon-button id="outerExpand" icon="unfold-more" step="{{ groups
.step }}" on-click="{{ _outerExpand }}"></paper-icon-button> | 59 <paper-icon-button id="outerExpand" icon="unfold-more" step="{{ groups
.step }}" on-click=" _outerExpand "></paper-icon-button> |
| 62 </div> | 60 </div> |
| 63 </template> | 61 </template> |
| 64 </template> | 62 </template> |
| 65 </template> | 63 </template> |
| 66 <script> | 64 <script> |
| 67 Polymer('ct-test-list', { | 65 Polymer({ |
| 68 kMaxTestsPerStep: 10, | 66 is: 'ct-test-list', |
| 69 testsChanged: function() { | 67 properties: { |
| 68 kMaxTestsPerStep: { |
| 69 type: Number, |
| 70 value: 10 |
| 71 }, |
| 72 tests: { |
| 73 notify: true, |
| 74 observer: 'testsChanged' |
| 75 } |
| 76 }, |
| 77 testsChanged: function () { |
| 70 var groups = {}; | 78 var groups = {}; |
| 71 if (this.tests) { | 79 if (this.tests) { |
| 72 this.tests.forEach(function(test) { | 80 this.tests.forEach(function (test) { |
| 73 if (!groups[test.step]) | 81 if (!groups[test.step]) |
| 74 groups[test.step] = {}; | 82 groups[test.step] = {}; |
| 75 var testName = test.reasonGroupName(); | 83 var testName = test.reasonGroupName(); |
| 76 if (!groups[test.step][testName]) | 84 if (!groups[test.step][testName]) |
| 77 groups[test.step][testName] = []; | 85 groups[test.step][testName] = []; |
| 78 groups[test.step][testName].push(test); | 86 groups[test.step][testName].push(test); |
| 79 }.bind(this)); | 87 }.bind(this)); |
| 80 } | 88 } |
| 81 this.testGroups_ = []; | 89 this.testGroups_ = []; |
| 82 Object.keys(groups, function(step, testsByName) { | 90 Object.keys(groups, function (step, testsByName) { |
| 83 var tests = []; | 91 var tests = []; |
| 84 Object.keys(testsByName, function(name, testList) { | 92 Object.keys(testsByName, function (name, testList) { |
| 85 if (name == 'undefined') | 93 if (name == 'undefined') |
| 86 name = undefined; | 94 name = undefined; |
| 87 tests.push({'name': name, 'tests': testList, 'expanded': false}); | 95 tests.push({ |
| 96 'name': name, |
| 97 'tests': testList, |
| 98 'expanded': false |
| 99 }); |
| 88 }.bind(this)); | 100 }.bind(this)); |
| 89 tests.sortBy('name'); | 101 tests.sortBy('name'); |
| 90 // The + 1 is to make sure at least 2 tests are hidden by the message. | 102 // The + 1 is to make sure at least 2 tests are hidden by the message. |
| 91 this.testGroups_.push({'step': step, 'tests': tests, 'expanded': tests
.length <= (this.kMaxTestsPerStep + 1)}); | 103 this.testGroups_.push({ |
| 104 'step': step, |
| 105 'tests': tests, |
| 106 'expanded': tests.length <= this.kMaxTestsPerStep + 1 |
| 107 }); |
| 92 }.bind(this)); | 108 }.bind(this)); |
| 93 this.testGroups_.sortBy('step'); | 109 this.testGroups_.sortBy('step'); |
| 94 }, | 110 }, |
| 95 | 111 _innerExpand: function (evt) { |
| 96 _innerExpand: function(evt) { | |
| 97 step = evt.target.attributes['step'].value; | 112 step = evt.target.attributes['step'].value; |
| 98 name = evt.target.attributes['group'].value; | 113 name = evt.target.attributes['group'].value; |
| 99 this.testGroups_.forEach(function(testGroup) { | 114 this.testGroups_.forEach(function (testGroup) { |
| 100 if (testGroup.step == step) { | 115 if (testGroup.step == step) { |
| 101 testGroup.tests.forEach(function(test) { | 116 testGroup.tests.forEach(function (test) { |
| 102 // FIXME: This attribute should be persisted over reloads. | 117 // FIXME: This attribute should be persisted over reloads. |
| 103 if (test.name == name) | 118 if (test.name == name) |
| 104 test.expanded = true; | 119 test.expanded = true; |
| 105 }); | 120 }); |
| 106 } | 121 } |
| 107 }); | 122 }); |
| 108 }, | 123 }, |
| 109 | 124 _outerExpand: function (evt) { |
| 110 _outerExpand: function(evt) { | |
| 111 var step = evt.target.attributes['step'].value; | 125 var step = evt.target.attributes['step'].value; |
| 112 this.testGroups_.forEach(function(testGroup) { | 126 this.testGroups_.forEach(function (testGroup) { |
| 113 if (testGroup.step == step) { | 127 if (testGroup.step == step) { |
| 114 testGroup.expanded = true; | 128 testGroup.expanded = true; |
| 115 } | 129 } |
| 116 }); | 130 }); |
| 117 }, | 131 }, |
| 118 | 132 flakinessDashboardURL: function (test) { |
| 119 flakinessDashboardURL: function(test) { | |
| 120 return test.flakinessDashboardURL(); | 133 return test.flakinessDashboardURL(); |
| 121 }, | 134 }, |
| 122 | |
| 123 // FIXME: Remove maybeTruncate. Persist the expanded list as described in | 135 // FIXME: Remove maybeTruncate. Persist the expanded list as described in |
| 124 // http://crbug.com/417159. | 136 // http://crbug.com/417159. |
| 125 maybeTruncate: function(input, expanded) { | 137 maybeTruncate: function (input, expanded) { |
| 126 if (expanded) | 138 if (expanded) |
| 127 return input; | 139 return input; |
| 128 return input.slice(0, this.kMaxTestsPerStep); | 140 return input.slice(0, this.kMaxTestsPerStep); |
| 129 }, | 141 }, |
| 142 computeIf: function (group) { |
| 143 return group.name && (group.tests.length == 1 || group.expanded); |
| 144 }, |
| 145 computeIf2: function (group) { |
| 146 return group.name && group.tests.length > 1 && !group.expanded; |
| 147 }, |
| 148 computeExpression5: function (groups, kMaxTestsPerStep) { |
| 149 return groups.tests.length - kMaxTestsPerStep; |
| 150 } |
| 130 }); | 151 }); |
| 131 </script> | 152 </script> |
| 132 </polymer-element> | 153 </dom-module> |
| OLD | NEW |