OLD | NEW |
| (Empty) |
1 <!-- | |
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. | |
5 --> | |
6 | |
7 <link rel="import" href="ct-results-comparison.html"> | |
8 | |
9 <polymer-element name="ct-results-detail" attributes="failure builder"> | |
10 <template> | |
11 <style> | |
12 :host { | |
13 display: block; | |
14 } | |
15 </style> | |
16 <template if="{{!_urlGroups.length}}"> | |
17 No results to display. | |
18 </template> | |
19 <template repeat="{{urlGroup in _urlGroups}}"> | |
20 <template if="{{urlGroup.urls[_kUnknownKind]}}"> | |
21 <ct-test-output type="{{urlGroup.type}}" url="{{urlGroup.urls[_kUnknownK
ind]}}"></ct-test-output> | |
22 </template> | |
23 <template if="{{!urlGroup.urls[_kUnknownKind]}}"> | |
24 <ct-results-comparison type="{{urlGroup.type}}" expectedUrl="{{urlGroup.
urls[_kExpectedKind]}}" | |
25 actualUrl="{{urlGroup.urls[_kActualKind]}}" diffUrl="{{urlGroup.urls
[_kDiffKind]}}"></ct-results-comparison> | |
26 </template> | |
27 </template> | |
28 </template> | |
29 <script> | |
30 Polymer({ | |
31 failure: null, | |
32 // FIXME: Initializing builder gives a JS error. Presumably because | |
33 // ct-results-by-builder sets builder="{{builders[selected]}}". But, | |
34 // it seems wrong that the way the parent uses this element constrains | |
35 // what the element can do. Polymer bug? | |
36 // builder: '', | |
37 | |
38 _urlGroups: [], | |
39 _kExpectedKind: results.kExpectedKind, | |
40 _kActualKind: results.kActualKind, | |
41 _kDiffKind: results.kDiffKind, | |
42 _kUnknownKind: results.kUnknownKind, | |
43 | |
44 observe: { | |
45 failure: '_update', | |
46 builder: '_update', | |
47 }, | |
48 | |
49 _isStdioStep: function(result, step) { | |
50 return result.actual == 'UNKNOWN' || step == 'compile'; | |
51 }, | |
52 | |
53 _update: function() { | |
54 if (!this.failure || !this.builder) | |
55 return; | |
56 | |
57 // FIXME: If the types of groups doesn't change, then it'd be better to
do this | |
58 // update in place so that the user doesn't see a flicker. | |
59 this._urlGroups = []; | |
60 | |
61 var result = this.failure.resultNodesByBuilder[this.builder]; | |
62 // FIXME: There's probably a less hacky way to check this. | |
63 if (result.actual == 'FAIL' || this._isStdioStep(result, this.failure.st
ep)) | |
64 this._updateUrls(); | |
65 else | |
66 this._updateWebkitTestUrls(); | |
67 }, | |
68 | |
69 _updateWebkitTestUrls: function() { | |
70 var result = this.failure.resultNodesByBuilder[this.builder]; | |
71 var failureInfo = results.failureInfo(this.failure.testName, this.builde
r, result.actual); | |
72 | |
73 // FIXME: Move this logic to a proper model class so that the network re
quests this makes | |
74 // can be easily mocked out in tests. | |
75 results.fetchResultsURLs(failureInfo).then(function(resultsUrls) { | |
76 var resultsUrlsByTypeAndKind = {}; | |
77 resultsUrls.forEach(function(url) { | |
78 var resultType = results.resultType(url); | |
79 if (!resultsUrlsByTypeAndKind[resultType]) | |
80 resultsUrlsByTypeAndKind[resultType] = {}; | |
81 resultsUrlsByTypeAndKind[resultType][results.resultKind(url)] = ur
l; | |
82 }); | |
83 | |
84 Object.keys(resultsUrlsByTypeAndKind, function(resultType, resultsUrls
ByKind) { | |
85 this._urlGroups.push({ | |
86 type: resultType, | |
87 urls: resultsUrlsByKind, | |
88 }); | |
89 }.bind(this)); | |
90 }.bind(this)); | |
91 }, | |
92 | |
93 _updateUrls: function() { | |
94 // FIXME: Along with _updateWebkitTestUrls, move this logic to a proper
model class | |
95 // so that the network requests this makes can be easily mocked out in t
ests. | |
96 | |
97 var result = this.failure.resultNodesByBuilder[this.builder]; | |
98 | |
99 // FIXME: We only store build logs by the test name, not the testsuite.t
estname, | |
100 // which means that two failing tests from different test suites conflic
t! | |
101 var testPart = this._isStdioStep(result, this.failure.step) ? 'stdio' :
this.failure.testName.split('.')[1]; | |
102 // Fix url for parameterized gtests, e.g.: /2 -> _2. | |
103 testPart = testPart.replace(/\/(\d+)$/, "_$1"); | |
104 var url = result.masterUrl + | |
105 '/builders/' + encodeURIComponent(this.builder); | |
106 | |
107 // FIXME: Make failure groups aware of their own url | |
108 if (this.failure.testName) | |
109 url += | |
110 '/builds/' + result.lastFailingBuild + | |
111 '/steps/' + this.failure.step + | |
112 '/logs/' + testPart; | |
113 | |
114 var resultsUrlsByKind = {}; | |
115 resultsUrlsByKind[this._kUnknownKind] = url; | |
116 | |
117 this._urlGroups.push({ | |
118 type: results.kTextType, | |
119 urls: resultsUrlsByKind, | |
120 }); | |
121 }, | |
122 }); | |
123 </script> | |
124 </polymer-element> | |
OLD | NEW |