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 --> |
6 | 6 |
7 <link rel="import" href="../bower_components/paper-icon-button/paper-icon-button .html"> | |
8 | |
7 <polymer-element name="ct-test-list" attributes="tests tree"> | 9 <polymer-element name="ct-test-list" attributes="tests tree"> |
8 <template> | 10 <template> |
9 <style> | 11 <style> |
10 :host { | 12 :host { |
11 display: block; | 13 display: block; |
12 } | 14 } |
15 | |
16 paper-icon-button { | |
17 vertical-align: middle; | |
18 } | |
13 </style> | 19 </style> |
14 <template repeat="{{ test in tests }}"> | 20 <template repeat="{{ groups in testGroups_ }}"> |
15 <!-- FIXME: Find a less redundant UI than repeating the step on each line. --> | 21 <!-- FIXME: Find a less redundant UI than repeating the step on each line. --> |
16 <div> | 22 <template repeat="{{ group in groups.tests }}"> |
17 {{ test.step }} | 23 <!-- Case 1: entire step failed --> |
18 <template if="{{ test.testName }}"><a href="{{ test | flakinessDashboard URL }}">{{ test.testName }}</a></template> | 24 <template if="{{ !group.name }}"> |
19 <template if="{{ !test.testName }}"><b>whole step failed</b></template> | 25 <div>{{ groups.step }} <b>whole step failed</b></div> |
20 </div> | 26 </template> |
27 <!-- Case 2: single test failure --> | |
28 <template if="{{ group.name && (group.tests.length == 1 || group.expande d) }}"> | |
29 <template repeat="{{ test in group.tests }}"> | |
30 <div> | |
31 {{ groups.step }} | |
32 <a href="{{ test | flakinessDashboardURL }}">{{ test.testName }}</ a> | |
33 </div> | |
34 </template> | |
35 </template> | |
36 <!-- Case 3: group of tests failed --> | |
37 <template if="{{ group.name && group.tests.length > 1 && !group.expanded }}"> | |
38 <div> | |
39 {{ groups.step }} {{ group.name }} ({{ group.tests.length }} Tests) | |
40 <paper-icon-button id="expand" icon="more-vert" step="{{ groups.step }}" group="{{ group.name }}" on-click="{{ _expand }}"></paper-icon-button> | |
41 </div> | |
42 </template> | |
43 </template> | |
21 </template> | 44 </template> |
22 </template> | 45 </template> |
23 <script> | 46 <script> |
24 Polymer({ | 47 Polymer('ct-test-list', { |
48 testsChanged: function() { | |
49 var groups = {}; | |
50 if (this.tests) { | |
51 this.tests.forEach(function(test) { | |
52 if (!groups[test.step]) | |
53 groups[test.step] = {}; | |
54 var testName = test.reasonGroupName(); | |
55 if (!groups[test.step][testName]) | |
56 groups[test.step][testName] = []; | |
57 groups[test.step][testName].push(test); | |
58 }.bind(this)); | |
59 } | |
60 this.testGroups_ = []; | |
61 Object.keys(groups, function(step, testsByName) { | |
62 var tests = []; | |
63 Object.keys(testsByName, function(name, testList) { | |
64 if (name == 'undefined') | |
65 name = undefined; | |
66 tests.push({'name': name, 'tests': testList, 'expanded': false}); | |
67 }.bind(this)); | |
68 tests.sort(this._comparator.bind(this, 'name')); | |
ojan
2014/08/11 19:41:05
Turns out sugarjs, which we're using, has a method
jochen (gone - plz use gerrit)
2014/08/12 11:55:51
done
| |
69 this.testGroups_.push({'step': step, 'tests': tests}); | |
70 }.bind(this)); | |
71 this.testGroups_.sort(this._comparator.bind(this, 'step')); | |
ojan
2014/08/11 19:41:05
Ditto
| |
72 }, | |
73 | |
74 _comparator: function(key, a, b) { | |
75 if (a[key] == b[key]) | |
76 return 0; | |
77 if (a[key] < b[key]) | |
78 return -1; | |
79 return 1; | |
80 }, | |
81 | |
82 _expand: function(evt) { | |
83 step = evt.target.attributes['step'].value; | |
84 name = evt.target.attributes['group'].value; | |
85 this.testGroups_.forEach(function(testGroup) { | |
86 if (testGroup.step == step) { | |
87 testGroup.tests.forEach(function(test) { | |
88 // FIXME: This attribute should be persisted over reloads. | |
89 if (test.name == name) | |
90 test.expanded = true; | |
91 }); | |
92 } | |
93 }); | |
94 }, | |
95 | |
25 flakinessDashboardURL: function(test) { | 96 flakinessDashboardURL: function(test) { |
26 return ui.urlForFlakinessDashboard(test.testName, test.step, this.tree); | 97 return ui.urlForFlakinessDashboard(test.testName, test.step, this.tree); |
27 }, | 98 }, |
28 }); | 99 }); |
29 </script> | 100 </script> |
30 </polymer-element> | 101 </polymer-element> |
OLD | NEW |