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 module('ui.results'); 29 30 asyncTest('FlakinessData', 1, function() { 31 var dashboard = new ui.results.FlakinessData(); 32 dashboard.addEventListener('load', function() { 33 // setTimeout to be after the FlakinessData's load handler. 34 setTimeout(function() { 35 window.postMessage({command: 'heightChanged', height: 15}, '*'); 36 // setTimeout to be after the postMessage has been handled. 37 setTimeout(function() { 38 equals(dashboard.offsetHeight, 15); 39 dashboard.remove(); 40 start(); 41 }, 0); 42 }, 0); 43 }); 44 document.body.appendChild(dashboard); 45 }); 46 47 var kExampleResultsByTest = { 48 "scrollbars/custom-scrollbar-with-incomplete-style.html": { 49 "Mock Builder": { 50 "expected": "IMAGE", 51 "actual": "CRASH" 52 }, 53 "Mock Linux": { 54 "expected": "TEXT", 55 "actual": "CRASH" 56 } 57 }, 58 "userscripts/another-test.html": { 59 "Mock Builder": { 60 "expected": "PASS", 61 "actual": "TEXT" 62 } 63 } 64 }; 65 66 var kExampleReftestResults = { 67 "reftest.html": { 68 "Mock Builder": { 69 "expected": "PASS", 70 "actual": "IMAGE", 71 "reftest_type": ["=="] 72 } 73 }, 74 "mismatch-reftest.html": { 75 "Mock Builder": { 76 "expected": "PASS", 77 "actual": "IMAGE", 78 "reftest_type": ["!="] 79 } 80 } 81 }; 82 83 var kExampleResultsWithTimeoutByTest = { 84 "fast/not-fast-test.html": { 85 "Mock Builder": { 86 "expected": "PASS", 87 "actual": "TIMEOUT" 88 } 89 } 90 }; 91 92 var kExampleGreaterThanFourResultsByTest = { 93 "scrollbars/custom-scrollbar-with-incomplete-style.html": { 94 "Mock Linux": { 95 "expected": "TEXT", 96 "actual": "CRASH" 97 } 98 }, 99 "scrollbars/1.html": { 100 "Mock Linux": { 101 "expected": "TEXT", 102 "actual": "CRASH" 103 } 104 }, 105 "scrollbars/2.html": { 106 "Mock Linux": { 107 "expected": "TEXT", 108 "actual": "CRASH" 109 } 110 }, 111 "scrollbars/3.html": { 112 "Mock Linux": { 113 "expected": "TEXT", 114 "actual": "CRASH" 115 } 116 }, 117 "userscripts/another-test.html": { 118 "Mock Builder": { 119 "expected": "PASS", 120 "actual": "TEXT" 121 } 122 } 123 }; 124 125 test('View', 18, function() { 126 var delegate = { 127 fetchResultsURLs: function(failureInfo, callback) { return; } 128 }; 129 130 var view = new ui.results.View(delegate); 131 view.setResultsByTest(kExampleResultsByTest); 132 133 view.firstResult(); 134 var testSelector = view.querySelector('.test-selector'); 135 var topPanel = testSelector.querySelector('.top-panel'); 136 equals(topPanel.childNodes[0], topPanel.querySelector('.active'));; 137 equals($($('.builder-selector', view)[0]).tabs('option', 'selected'), 0); 138 139 view.nextResult(); 140 equals(topPanel.childNodes[0], topPanel.querySelector('.active'));; 141 equals($($('.builder-selector', view)[0]).tabs('option', 'selected'), 1); 142 equals(view.currentTestName(), 'scrollbars/custom-scrollbar-with-incomplete-style.html'); 143 144 view.nextResult(); 145 equals(topPanel.childNodes[1], topPanel.querySelector('.active'));; 146 equals($($('.builder-selector', view)[0]).tabs('option', 'selected'), 0); 147 equals(view.currentTestName(), 'userscripts/another-test.html'); 148 149 view.previousResult(); 150 equals(topPanel.childNodes[0], topPanel.querySelector('.active'));; 151 equals($($('.builder-selector', view)[0]).tabs('option', 'selected'), 1); 152 153 view.nextTest(); 154 equals(topPanel.childNodes[1], topPanel.querySelector('.active'));; 155 equals($($('.builder-selector', view)[0]).tabs('option', 'selected'), 0); 156 equals(view.currentTestName(), 'userscripts/another-test.html'); 157 158 view.previousTest(); 159 equals(topPanel.childNodes[0], topPanel.querySelector('.active'));; 160 equals($($('.builder-selector', view)[0]).tabs('option', 'selected'), 1); 161 equals(view.currentTestName(), 'scrollbars/custom-scrollbar-with-incomplete-style.html'); 162 163 ok(!testSelector.querySelector('.resize-handle')); 164 equals(topPanel.style.minHeight, ''); 165 }); 166 167 test('View with more than four tests', 2, function() { 168 var delegate = { 169 fetchResultsURLs: function(failureInfo, callback) { return; } 170 }; 171 172 var view = new ui.results.View(delegate); 173 view.setResultsByTest(kExampleGreaterThanFourResultsByTest); 174 175 var testSelector = view.querySelector('.test-selector'); 176 var topPanel = testSelector.querySelector('.top-panel'); 177 178 ok(testSelector.querySelector('.resize-handle')); 179 equals(topPanel.style.minHeight, '100px'); 180 }); 181 182 test('View with reftests', 2, function() { 183 var delegate = { 184 fetchResultsURLs: function(failureInfo, callback) { return; } 185 }; 186 187 var view = new ui.results.View(delegate); 188 view.setResultsByTest(kExampleReftestResults); 189 view.firstResult(); 190 191 equals($('.non-action-button', view).length, 1); 192 equals($('.action', view).length, 0); 193 }); 194 195 test('View of timeouts', 1, function() { 196 var delegate = { 197 fetchResultsURLs: function(failureInfo, callback) { callback([]); } 198 }; 199 200 var view = new ui.results.View(delegate); 201 view.setResultsByTest(kExampleResultsWithTimeoutByTest); 202 view.firstResult(); 203 204 equals($('.results-grid', view).html(), 'No results to display.'); 205 }); 206 207 })(); 208