• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2013 Google Inc. All rights reserved.
2//
3// Redistribution and use in source and binary forms, with or without
4// modification, are permitted provided that the following conditions are
5// met:
6//
7//         * Redistributions of source code must retain the above copyright
8// notice, this list of conditions and the following disclaimer.
9//         * Redistributions in binary form must reproduce the above
10// copyright notice, this list of conditions and the following disclaimer
11// in the documentation and/or other materials provided with the
12// distribution.
13//         * Neither the name of Google Inc. nor the names of its
14// contributors may be used to endorse or promote products derived from
15// this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29module('aggregate_results');
30
31function setupAggregateResultsData(includeRevisonNumbers)
32{
33    var historyInstance = new history.History(flakinessConfig);
34    // FIXME(jparent): Remove this once global isn't used.
35    g_history = historyInstance;
36    for (var key in history.DEFAULT_CROSS_DASHBOARD_STATE_VALUES)
37        historyInstance.crossDashboardState[key] = history.DEFAULT_CROSS_DASHBOARD_STATE_VALUES[key];
38
39    var builderName = 'Blink Linux';
40    LOAD_BUILDBOT_DATA({
41        "no_upload_test_types": [],
42        "masters": [
43            {
44                "groups": [ "@ToT Blink" ],
45                "name": "ChromiumWebkit",
46                "url_name": "chromium.webkit",
47                "tests": {
48                    "layout-tests": {
49                        "builders": [builderName]
50                    }
51                },
52            }
53        ]
54    });
55    builders.loadBuildersList('@ToT Blink', 'layout-tests');
56
57    g_resultsByBuilder[builderName] = {
58        "num_failures_by_type": {
59            "CRASH": [ 13, 10 ],
60            "MISSING": [ 6, 8 ],
61            "IMAGE+TEXT": [ 17, 17 ],
62            "IMAGE": [ 81, 68 ],
63            "SKIP": [ 1167, 748 ],
64            "TEXT": [ 89, 60 ],
65            "TIMEOUT": [ 72, 48 ],
66            "PASS": [ 28104, 28586 ],
67            "AUDIO": [ 0, 0 ],
68            "WONTFIX": [ 2, 2 ],
69        },
70        "buildNumbers": [5, 3]
71    }
72
73    if (includeRevisonNumbers) {
74        g_resultsByBuilder[builderName][results.BLINK_REVISIONS] = [1234, 1233];
75        g_resultsByBuilder[builderName][results.CHROME_REVISIONS] = [4567, 4566];
76    }
77
78    g_totalFailureCounts = {};
79}
80
81test('htmlForBuilderIncludeRevisionNumbers', 1, function() {
82    var includeRevisonNumbers = true;
83    setupAggregateResultsData(includeRevisonNumbers);
84    g_history.dashboardSpecificState.rawValues = false;
85
86    var expectedHtml = '<div class=container>' +
87        '<h2>Blink Linux</h2>' +
88        '<a href="timeline_explorer.html#useTestData=true&builder=Blink Linux">' +
89            '<img src="http://chart.apis.google.com/chart?cht=lc&chs=600x400&chd=e:qe..&chg=15,15,1,3&chxt=x,x,y&chxl=1:||Blink Revision|&chxr=0,1233,1234|2,0,1445&chtt=Total failing">' +
90            '<img src="http://chart.apis.google.com/chart?cht=lc&chs=600x400&chd=e:AjAt,AcAV,A7A7,DuEc,pB..,DSE4,CoD8&chg=15,15,1,3&chxt=x,x,y&chxl=1:||Blink Revision|&chxr=0,1233,1234|2,0,1167&chtt=Detailed breakdown&chdl=CRASH|MISSING|IMAGE+TEXT|IMAGE|SKIP|TEXT|TIMEOUT&chco=FF0000,00FF00,0000FF,000000,FF6EB4,FFA812,9B30FF">' +
91        '</a>' +
92    '</div>';
93    equal(expectedHtml, htmlForBuilder('Blink Linux'));
94});
95
96test('htmlForBuilder', 1, function() {
97    var includeRevisonNumbers = false;
98    setupAggregateResultsData(includeRevisonNumbers);
99    g_history.dashboardSpecificState.rawValues = false;
100
101    var expectedHtml = '<div class=container>' +
102        '<h2>Blink Linux</h2>' +
103        '<a href="timeline_explorer.html#useTestData=true&builder=Blink Linux">' +
104            '<img src="http://chart.apis.google.com/chart?cht=lc&chs=600x400&chd=e:qe..&chg=15,15,1,3&chxt=x,x,y&chxl=1:||Build Number|&chxr=0,3,5|2,0,1445&chtt=Total failing">' +
105            '<img src="http://chart.apis.google.com/chart?cht=lc&chs=600x400&chd=e:AjAt,AcAV,A7A7,DuEc,pB..,DSE4,CoD8&chg=15,15,1,3&chxt=x,x,y&chxl=1:||Build Number|&chxr=0,3,5|2,0,1167&chtt=Detailed breakdown&chdl=CRASH|MISSING|IMAGE+TEXT|IMAGE|SKIP|TEXT|TIMEOUT&chco=FF0000,00FF00,0000FF,000000,FF6EB4,FFA812,9B30FF">' +
106        '</a>' +
107    '</div>';
108    equal(expectedHtml, htmlForBuilder('Blink Linux'));
109});
110
111test('htmlForBuilderRawResultsIncludeRevisionNumbers', 1, function() {
112    var includeRevisonNumbers = true;
113    setupAggregateResultsData(includeRevisonNumbers);
114    g_history.dashboardSpecificState.rawValues = true;
115
116    var expectedHtml = '<div class=container>' +
117        '<h2>Blink Linux</h2>' +
118        '<table>' +
119            '<tbody>' +
120                '<tr><td>Blink Revision</td><td>1234</td><td>1233</td></tr>' +
121                '<tr><td>Chrome Revision</td><td>4567</td><td>4566</td></tr>' +
122                '<tr><td>Percent passed</td><td>95.1%</td><td>96.8%</td></tr>' +
123                '<tr><td>Failures</td><td>1445</td><td>959</td></tr>' +
124                '<tr><td>Total Tests</td><td>29549</td><td>29545</td></tr>' +
125                '<tr><td>CRASH</td><td>13</td><td>10</td></tr>' +
126                '<tr><td>MISSING</td><td>6</td><td>8</td></tr>' +
127                '<tr><td>IMAGE+TEXT</td><td>17</td><td>17</td></tr>' +
128                '<tr><td>IMAGE</td><td>81</td><td>68</td></tr>' +
129                '<tr><td>SKIP</td><td>1167</td><td>748</td></tr>' +
130                '<tr><td>TEXT</td><td>89</td><td>60</td></tr>' +
131                '<tr><td>TIMEOUT</td><td>72</td><td>48</td></tr>' +
132                '<tr><td>PASS</td><td>28104</td><td>28586</td></tr>' +
133                '<tr><td>AUDIO</td><td>0</td><td>0</td></tr>' +
134                '<tr><td>WONTFIX</td><td>2</td><td>2</td></tr>' +
135            '</tbody>' +
136        '</table>' +
137    '</div>';
138    equal(expectedHtml, htmlForBuilder('Blink Linux'));
139});
140
141test('htmlForBuilderRawResults', 1, function() {
142    var includeRevisonNumbers = false;
143    setupAggregateResultsData(includeRevisonNumbers);
144    g_history.dashboardSpecificState.rawValues = true;
145
146    var expectedHtml = '<div class=container>' +
147        '<h2>Blink Linux</h2>' +
148        '<table>' +
149            '<tbody>' +
150                '<tr><td>Percent passed</td><td>95.1%</td><td>96.8%</td></tr>' +
151                '<tr><td>Failures</td><td>1445</td><td>959</td></tr>' +
152                '<tr><td>Total Tests</td><td>29549</td><td>29545</td></tr>' +
153                '<tr><td>CRASH</td><td>13</td><td>10</td></tr>' +
154                '<tr><td>MISSING</td><td>6</td><td>8</td></tr>' +
155                '<tr><td>IMAGE+TEXT</td><td>17</td><td>17</td></tr>' +
156                '<tr><td>IMAGE</td><td>81</td><td>68</td></tr>' +
157                '<tr><td>SKIP</td><td>1167</td><td>748</td></tr>' +
158                '<tr><td>TEXT</td><td>89</td><td>60</td></tr>' +
159                '<tr><td>TIMEOUT</td><td>72</td><td>48</td></tr>' +
160                '<tr><td>PASS</td><td>28104</td><td>28586</td></tr>' +
161                '<tr><td>AUDIO</td><td>0</td><td>0</td></tr>' +
162                '<tr><td>WONTFIX</td><td>2</td><td>2</td></tr>' +
163            '</tbody>' +
164        '</table>' +
165    '</div>';
166    equal(expectedHtml, htmlForBuilder('Blink Linux'));
167});
168