1 // Copyright (C) 2013 Google Inc. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
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
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.
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.
31 test('getFlakyData', 2, function() {
32 var testTypes = ['MockTestType'];
40 var resultsByTestType = {
44 'TestSuite.NotFlaky': {
45 'results': [[1, 'T'], [1, 'C']]
48 'results': [[1, 'T'], [1, 'C'], [1, 'T']]
50 'TestSuite.VeryFlaky': {
51 'results': [[1, 'T'], [1, 'C'], [1, 'T'], [1, 'C'], [1, 'T'], [1, 'C'], [1, 'T']]
54 'num_failures_by_type': {
58 'failure_map': failureMap
63 var flipCountThreshold = 1;
64 deepEqual(overview._getFlakyData(testTypes, resultsByTestType, flipCountThreshold), {
66 "flakyBelowThreshold": {
67 "TestSuite.Flaky": true,
68 "TestSuite.VeryFlaky": true
71 'TestSuite.Flaky': true,
72 'TestSuite.VeryFlaky': true
79 flipCountThreshold = 5;
80 deepEqual(overview._getFlakyData(testTypes, resultsByTestType, flipCountThreshold), {
82 "flakyBelowThreshold": {
83 "TestSuite.VeryFlaky": true
86 "TestSuite.Flaky": true,
87 'TestSuite.VeryFlaky': true
94 test('htmlForFlakyTests', 6, function() {
98 "flakyBelowThreshold": {},
103 "flakyBelowThreshold": {
104 'css3/foo.html': true,
105 'css3/bar.html': true
108 'css3/foo.html': true,
109 'css3/bar.html': true
114 var container = document.createElement('div');
115 container.innerHTML = overview._htmlForFlakyTests(flakyData, 'MockGroup');
117 // There should only be one row other than the header since browser_tests
118 // have testCount of 0.
119 ok(!container.querySelectorAll('tr')[2]);
121 var firstRow = container.querySelectorAll('tr')[1];
122 equal(firstRow.querySelector('td:nth-child(1)').textContent, 'layout-tests');
123 equal(firstRow.querySelector('td:nth-child(1) a').hash, '#group=MockGroup&testType=layout-tests&tests=css3/foo.html,css3/bar.html');
124 equal(firstRow.querySelector('td:nth-child(2)').textContent, '2 / 4');
125 equal(firstRow.querySelector('td:nth-child(3)').textContent, '50%');
126 equal(firstRow.querySelector('td:nth-child(4)').innerHTML, '<div class="flaky-bar" style="width:250px"></div>');
129 test('handleValidHashParameter', 5, function() {
130 var historyInstance = new history.History();
132 ok(overview.handleValidHashParameter(historyInstance, 'flipCount', "5"))
133 ok(overview.handleValidHashParameter(historyInstance, 'flipCount', 5))
134 ok(!overview.handleValidHashParameter(historyInstance, 'flipCount', "notanumber"))
135 ok(!overview.handleValidHashParameter(historyInstance, 'flipCount', "5notanumber"))
136 ok(!overview.handleValidHashParameter(historyInstance, 'randomKey', "5"))
139 test('navbar', 3, function() {
141 var container = document.createElement('div');
142 container.innerHTML = overview._htmlForNavBar(flipCount);
144 ok(container.querySelector('select'));
146 var sliderContainer = container.querySelector('#flip-slider-container');
149 var range = sliderContainer.querySelector('input');
150 equal(range.value, "5");