/* * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ (function () { module("ui"); var kExampleResultsByTest = { "scrollbars/custom-scrollbar-with-incomplete-style.html": { "Mock Builder": { "expected": "IMAGE", "actual": "CRASH" }, "Mock Linux": { "expected": "TEXT", "actual": "CRASH" } }, "userscripts/another-test.html": { "Mock Builder": { "expected": "PASS", "actual": "TEXT" } } } test("ui.onebar", 3, function() { if (window.location.hash) { window.location.hash = ''; } onebar = new ui.onebar(); onebar.attach(); equal(onebar.innerHTML, '' + '
' + '
' + '
'); onebar.select('expected'); equal(window.location.hash, '#expected'); onebar.select('unexpected'); equal(window.location.hash, '#unexpected'); $(onebar).detach(); }); test("results.ResultsGrid", 1, function() { var grid = new ui.results.ResultsGrid() grid.addResults([ 'http://example.com/layout-test-results/foo-bar-diff.txt', 'http://example.com/layout-test-results/foo-bar-expected.png', 'http://example.com/layout-test-results/foo-bar-actual.png', 'http://example.com/layout-test-results/foo-bar-diff.png', ]); equal(grid.innerHTML, '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
ExpectedActualDiff
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
ExpectedActualDiff
'); }); test("results.ResultsGrid (crashlog)", 1, function() { var grid = new ui.results.ResultsGrid() grid.addResults(['http://example.com/layout-test-results/foo-bar-crash-log.txt']); equal(grid.innerHTML, ''); }); test("results.ResultsGrid (empty)", 1, function() { var grid = new ui.results.ResultsGrid() grid.addResults([]); equal(grid.innerHTML, 'No results to display.'); }); test("time", 6, function() { var time = new ui.RelativeTime(); equal(time.tagName, 'TIME'); equal(time.className, 'relative'); deepEqual(Object.getOwnPropertyNames(time.__proto__).sort(), [ 'date', 'init', 'setDate', 'update', ]); equal(time.outerHTML, ''); var tenMinutesAgo = new Date(); tenMinutesAgo.setMinutes(tenMinutesAgo.getMinutes() - 10); time.setDate(tenMinutesAgo); equal(time.outerHTML, ''); equal(time.date().getTime(), tenMinutesAgo.getTime()); }); test("StatusArea", 3, function() { var statusArea = new ui.StatusArea(); var id = statusArea.newId(); statusArea.addMessage(id, 'First Message'); statusArea.addMessage(id, 'Second Message'); equal(statusArea.outerHTML, '
' + '' + 'Processing...' + '
' + '
First Message
' + '
Second Message
' + '
' + '
'); var secondStatusArea = new ui.StatusArea(); var secondId = secondStatusArea.newId(); secondStatusArea.addMessage(secondId, 'First Message second id'); equal(statusArea.outerHTML, '
' + '' + 'Processing...' + '
' + '
First Message
' + '
Second Message
' + '
' + '
' + '
First Message second id
' + '
' + '
'); statusArea.addFinalMessage(id, 'Final Message 1'); statusArea.addFinalMessage(secondId, 'Final Message 2'); equal(statusArea.outerHTML, '
' + '' + 'Processing...' + '
' + '
First Message
' + '
Second Message
' + '
Final Message 1
' + '
' + '
' + '
First Message second id
' + '
Final Message 2
' + '
' + '
'); statusArea.close(); }); var openTreeJson = { "username": "erg@chromium.org", "date": "2013-10-14 20:22:00.887390", "message": "Tree is open", "can_commit_freely": true, "general_state": "open" }; test("TreeStatus", 2, function() { var simulator = new NetworkSimulator(); simulator.get = function(url, callback) { simulator.scheduleCallback(function() { callback(openTreeJson); }); }; var treestatus; simulator.runTest(function() { treeStatus = new ui.TreeStatus(); }); equal(treeStatus.innerHTML, '
blink status: OPEN
chromium status: OPEN
'); }); })();