OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * 1. Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * 2. Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * | |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
23 * THE POSSIBILITY OF SUCH DAMAGE. | |
24 */ | |
25 | |
26 var controllers = controllers || {}; | |
27 | |
28 (function(){ | |
29 | |
30 controllers.ResultsDetails = base.extends(Object, { | |
31 init: function(view, resultsByTest) | |
32 { | |
33 this._view = view; | |
34 this._resultsByTest = resultsByTest; | |
35 this._view.setResultsByTest(resultsByTest); | |
36 | |
37 this._view.firstResult(); | |
38 | |
39 $(this._view).bind('next', this.onNext.bind(this)); | |
40 $(this._view).bind('previous', this.onPrevious.bind(this)); | |
41 }, | |
42 onNext: function() | |
43 { | |
44 this._view.nextResult(); | |
45 }, | |
46 onPrevious: function() | |
47 { | |
48 this._view.previousResult(); | |
49 }, | |
50 _failureInfoList: function() | |
51 { | |
52 var testName = this._view.currentTestName(); | |
53 return Object.keys(this._resultsByTest[testName]).map(function(builderNa
me) { | |
54 return results.failureInfoForTestAndBuilder(this._resultsByTest, tes
tName, builderName); | |
55 }.bind(this)); | |
56 }, | |
57 }); | |
58 | |
59 var FailureStreamController = base.extends(Object, { | |
60 _resultsFilter: null, | |
61 _keyFor: function(failureAnalysis) { throw "Not implemented!"; }, | |
62 _createFailureView: function(failureAnalysis) { throw "Not implemented!"; }, | |
63 | |
64 init: function(model, view, delegate) | |
65 { | |
66 this._model = model; | |
67 this._view = view; | |
68 this._delegate = delegate; | |
69 this._testFailures = new base.UpdateTracker(); | |
70 }, | |
71 update: function(failureAnalysis) | |
72 { | |
73 var key = this._keyFor(failureAnalysis); | |
74 var failure = this._testFailures.get(key); | |
75 if (!failure) { | |
76 failure = this._createFailureView(failureAnalysis); | |
77 this._view.add(failure); | |
78 $(failure).bind('examine', function() { | |
79 this.onExamine(failure); | |
80 }.bind(this)); | |
81 } | |
82 failure.addFailureAnalysis(failureAnalysis); | |
83 this._testFailures.update(key, failure); | |
84 return failure; | |
85 }, | |
86 purge: function() { | |
87 this._testFailures.purge(function(failure) { | |
88 failure.dismiss(); | |
89 }); | |
90 this._testFailures.forEach(function(failure) { | |
91 failure.purge(); | |
92 }); | |
93 }, | |
94 onExamine: function(failures) | |
95 { | |
96 var resultsView = new ui.results.View({ | |
97 fetchResultsURLs: results.fetchResultsURLs | |
98 }); | |
99 | |
100 var testNameList = failures.testNameList(); | |
101 var failuresByTest = base.filterDictionary( | |
102 this._resultsFilter(this._model.resultsByBuilder), | |
103 function(key) { | |
104 return testNameList.indexOf(key) != -1; | |
105 }); | |
106 | |
107 var controller = new controllers.ResultsDetails(resultsView, failuresByT
est); | |
108 this._delegate.showResults(resultsView); | |
109 }, | |
110 _toFailureInfoList: function(failures) | |
111 { | |
112 return base.flattenArray(failures.testNameList().map(model.unexpectedFai
lureInfoForTestName)); | |
113 }, | |
114 }); | |
115 | |
116 controllers.UnexpectedFailures = base.extends(FailureStreamController, { | |
117 _resultsFilter: results.unexpectedFailuresByTest, | |
118 | |
119 _impliedFirstFailingRevision: function(failureAnalysis) | |
120 { | |
121 return failureAnalysis.newestPassingRevision + 1; | |
122 }, | |
123 _keyFor: function(failureAnalysis) | |
124 { | |
125 return failureAnalysis.newestPassingRevision + "+" + failureAnalysis.old
estFailingRevision; | |
126 }, | |
127 _createFailureView: function(failureAnalysis) | |
128 { | |
129 var failure = new ui.notifications.FailingTestsSummary(); | |
130 model.commitDataListForRevisionRange(this._impliedFirstFailingRevision(f
ailureAnalysis), failureAnalysis.oldestFailingRevision).forEach(function(commitD
ata) { | |
131 var suspiciousCommit = failure.addCommitData(commitData); | |
132 $(suspiciousCommit).bind('rollout', function() { | |
133 this.onRollout(commitData.revision, failure.testNameList()); | |
134 }.bind(this)); | |
135 }, this); | |
136 | |
137 return failure; | |
138 }, | |
139 update: function(failureAnalysis) | |
140 { | |
141 var failure = FailureStreamController.prototype.update.call(this, failur
eAnalysis); | |
142 failure.updateBuilderResults(model.buildersInFlightForRevision(this._imp
liedFirstFailingRevision(failureAnalysis))); | |
143 }, | |
144 length: function() | |
145 { | |
146 return this._testFailures.length(); | |
147 }, | |
148 }); | |
149 | |
150 controllers.FailingBuilders = base.extends(Object, { | |
151 init: function(view, message) | |
152 { | |
153 this._view = view; | |
154 this._message = message; | |
155 this._notification = null; | |
156 }, | |
157 hasFailures: function() | |
158 { | |
159 return !!this._notification; | |
160 }, | |
161 update: function(failuresList) | |
162 { | |
163 if (Object.keys(failuresList).length == 0) { | |
164 if (this._notification) { | |
165 this._notification.dismiss(); | |
166 this._notification = null; | |
167 } | |
168 return; | |
169 } | |
170 if (!this._notification) { | |
171 this._notification = new ui.notifications.BuildersFailing(this._mess
age); | |
172 this._view.add(this._notification); | |
173 } | |
174 // FIXME: We should provide regression ranges for the failing builders. | |
175 // This doesn't seem to happen often enough to worry too much about that
, however. | |
176 this._notification.setFailingBuilders(failuresList); | |
177 } | |
178 }); | |
179 | |
180 })(); | |
OLD | NEW |