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 (function() { | |
27 | |
28 var g_info = null; | |
29 var g_revisionHint = null; | |
30 | |
31 var g_updateTimerId = 0; | |
32 | |
33 var g_unexpectedFailuresController = null; | |
34 var g_nonLayoutTestFailureBuilders = null; | |
35 | |
36 var g_updating = false; | |
37 var g_updateButton = null; | |
38 | |
39 function updatePartyTime() | |
40 { | |
41 if (!g_unexpectedFailuresController.length() && !g_nonLayoutTestFailureBuild
ers.hasFailures()) | |
42 document.getElementById('onebar').classList.add('partytime'); | |
43 else | |
44 document.getElementById('onebar').classList.remove('partytime'); | |
45 } | |
46 | |
47 function updateTreeStatus() | |
48 { | |
49 var oldTreeStatus = document.querySelector('.treestatus'); | |
50 oldTreeStatus.remove(); | |
51 | |
52 var newTreeStatus = new ui.TreeStatus(); | |
53 document.querySelector('.topbar').appendChild(newTreeStatus); | |
54 } | |
55 | |
56 function update() | |
57 { | |
58 if (g_updating) | |
59 return; | |
60 | |
61 g_updating = true; | |
62 if (g_updateButton) | |
63 g_updateButton.disabled = true; | |
64 | |
65 if (g_revisionHint) | |
66 g_revisionHint.dismiss(); | |
67 | |
68 // FIXME: This should be a button with a progress element. | |
69 var numberOfTestsAnalyzed = 0; | |
70 var updating = new ui.notifications.Info('Loading commit data ...'); | |
71 | |
72 g_info.add(updating); | |
73 | |
74 builders.buildersFailingNonLayoutTests().then(function(failuresList) { | |
75 g_nonLayoutTestFailureBuilders.update(failuresList); | |
76 updatePartyTime(); | |
77 }); | |
78 | |
79 Promise.all([model.updateRecentCommits(), model.updateResultsByBuilder()]).t
hen(function() { | |
80 updating.update('Analyzing test failures ...'); | |
81 | |
82 model.analyzeUnexpectedFailures(function(failureAnalysis, total) { | |
83 updating.update('Analyzing test failures ... ' + ++numberOfTestsAnal
yzed + '/' + total + ' tests analyzed.'); | |
84 g_unexpectedFailuresController.update(failureAnalysis); | |
85 }).then(function() { | |
86 updatePartyTime(); | |
87 g_unexpectedFailuresController.purge(); | |
88 | |
89 Object.keys(config.builders).forEach(function(builderName) { | |
90 if (!model.state.resultsByBuilder[builderName]) | |
91 g_info.add(new ui.notifications.Info('Could not find test re
sults for ' + builderName + '.')); | |
92 }); | |
93 | |
94 updating.dismiss(); | |
95 | |
96 g_revisionHint = new ui.notifications.Info(''); | |
97 g_revisionHint.updateWithNode(new ui.revisionDetails()); | |
98 g_info.add(g_revisionHint); | |
99 | |
100 g_updating = false; | |
101 if (g_updateButton) | |
102 g_updateButton.disabled = false; | |
103 }); | |
104 }); | |
105 } | |
106 | |
107 window.addEventListener('DOMContentLoaded', function() { | |
108 g_updateTimerId = window.setInterval(update, config.kUpdateFrequency); | |
109 | |
110 window.setInterval(updateTreeStatus, config.kTreeStatusUpdateFrequency); | |
111 | |
112 pixelzoomer.installEventListeners(); | |
113 | |
114 onebar = new ui.onebar(); | |
115 onebar.attach(); | |
116 | |
117 // FIXME: This doesn't belong here. | |
118 var onebarController = { | |
119 showResults: function(resultsView) | |
120 { | |
121 var resultsContainer = onebar.results(); | |
122 resultsContainer.innerHTML = ''; | |
123 resultsContainer.appendChild(resultsView) | |
124 onebar.select('results'); | |
125 } | |
126 }; | |
127 | |
128 var unexpectedFailuresView = new ui.notifications.Stream(); | |
129 g_unexpectedFailuresController = new controllers.UnexpectedFailures(model.st
ate, unexpectedFailuresView, onebarController); | |
130 | |
131 g_info = new ui.notifications.Stream(); | |
132 g_nonLayoutTestFailureBuilders = new controllers.FailingBuilders(g_info); | |
133 | |
134 var unexpected = onebar.unexpected(); | |
135 var topBar = document.createElement('div'); | |
136 topBar.className = 'topbar'; | |
137 unexpected.appendChild(topBar); | |
138 | |
139 // FIXME: This should be an Action object. | |
140 var updateButton = document.body.insertBefore(document.createElement('button
'), document.body.firstChild); | |
141 updateButton.addEventListener("click", update); | |
142 updateButton.textContent = 'update'; | |
143 topBar.appendChild(updateButton); | |
144 g_updateButton = updateButton; | |
145 | |
146 var treeStatus = new ui.TreeStatus(); | |
147 topBar.appendChild(treeStatus); | |
148 | |
149 unexpected.appendChild(g_info); | |
150 unexpected.appendChild(unexpectedFailuresView); | |
151 | |
152 update(); | |
153 }); | |
154 | |
155 })(); | |
OLD | NEW |