2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
29 var g_revisionHint = null;
31 var g_updateTimerId = 0;
32 var g_buildersFailing = null;
34 var g_unexpectedFailuresController = null;
35 var g_failuresController = null;
37 var g_nonLayoutTestFailureBuilders = null;
39 var g_updating = false;
40 var g_updateButton = null;
42 function updatePartyTime()
44 if (!g_unexpectedFailuresController.length() && !g_nonLayoutTestFailureBuilders.hasFailures())
45 $('#onebar').addClass('partytime');
47 $('#onebar').removeClass('partytime');
50 function updateTreeStatus()
52 var oldTreeStatus = document.querySelector('.treestatus');
53 oldTreeStatus.remove();
55 var newTreeStatus = new ui.TreeStatus();
56 document.querySelector('.topbar').appendChild(newTreeStatus);
66 g_updateButton.disabled = true;
69 g_revisionHint.dismiss();
71 var gtestIframe = document.querySelector('#chromium-gtests iframe');
73 gtestIframe.src = gtestIframe.src;
75 // FIXME: This should be a button with a progress element.
76 var numberOfTestsAnalyzed = 0;
77 var updating = new ui.notifications.Info('Loading commit data ...');
81 builders.buildersFailingNonLayoutTests(function(failuresList) {
82 g_nonLayoutTestFailureBuilders.update(failuresList);
86 base.callInParallel([model.updateRecentCommits, model.updateResultsByBuilder], function() {
87 if (g_failuresController)
88 g_failuresController.update();
90 updating.update('Analyzing test failures ...');
92 model.analyzeUnexpectedFailures(function(failureAnalysis) {
93 updating.update('Analyzing test failures ... ' + ++numberOfTestsAnalyzed + ' tests analyzed.');
94 g_unexpectedFailuresController.update(failureAnalysis);
97 g_unexpectedFailuresController.purge();
99 Object.keys(config.builders).forEach(function(builderName) {
100 if (!model.state.resultsByBuilder[builderName])
101 g_info.add(new ui.notifications.Info('Could not find test results for ' + builderName + ' in the last ' + config.kBuildNumberLimit + ' runs.'));
106 g_revisionHint = new ui.notifications.Info('');
107 g_revisionHint.updateWithNode(new ui.revisionDetails());
108 g_info.add(g_revisionHint);
112 g_updateButton.disabled = false;
117 $(document).ready(function() {
118 g_updateTimerId = window.setInterval(update, config.kUpdateFrequency);
120 window.setInterval(updateTreeStatus, config.kTreeStatusUpdateFrequency);
122 pixelzoomer.installEventListeners();
124 onebar = new ui.onebar();
127 // FIXME: This doesn't belong here.
128 var onebarController = {
129 showResults: function(resultsView)
131 var resultsContainer = onebar.results();
132 $(resultsContainer).empty().append(resultsView);
133 onebar.select('results');
137 var unexpectedFailuresView = new ui.notifications.Stream();
138 g_unexpectedFailuresController = new controllers.UnexpectedFailures(model.state, unexpectedFailuresView, onebarController);
140 g_info = new ui.notifications.Stream();
141 g_nonLayoutTestFailureBuilders = new controllers.FailingBuilders(g_info);
143 var unexpected = onebar.unexpected();
144 var topBar = document.createElement('div');
145 topBar.className = 'topbar';
146 unexpected.appendChild(topBar);
148 // FIXME: This should be an Action object.
149 var updateButton = document.body.insertBefore(document.createElement('button'), document.body.firstChild);
150 updateButton.addEventListener("click", update);
151 updateButton.textContent = 'update';
152 topBar.appendChild(updateButton);
153 g_updateButton = updateButton;
155 var treeStatus = new ui.TreeStatus();
156 topBar.appendChild(treeStatus);
158 unexpected.appendChild(g_info);
159 unexpected.appendChild(unexpectedFailuresView);
161 var expected = onebar.expected();
163 var failuresView = new ui.failures.List();
164 g_failuresController = new controllers.ExpectedFailures(model.state, failuresView, onebarController);
165 expected.appendChild(failuresView);