1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 function WebUIAssertionsTest() {}
7 WebUIAssertionsTest.prototype = {
8 __proto__: testing.Test.prototype,
9 browsePreload: DUMMY_URL,
12 function testTwoExpects() {
17 TEST_F('WebUIAssertionsTest', 'testTwoExpects', function() {
18 var result = runTestFunction('testTwoExpects', testTwoExpects, []);
21 expectFalse(result[0]);
22 expectTrue(!!result[1].match(/expectTrue\(false\): false/));
23 expectTrue(!!result[1].match(/expectTrue\(0\): 0/));
26 function twoExpects() {
27 expectTrue(false, 'message1');
28 expectTrue(false, 'message2');
31 function testCallTestTwice() {
36 TEST_F('WebUIAssertionsTest', 'testCallTestTwice', function() {
37 var result = runTestFunction('testCallTestTwice', testCallTestTwice, []);
40 expectFalse(result[0]);
41 expectEquals(2, result[1].match(
42 /expectTrue\(false, 'message1'\): message1: false/g).length);
43 expectEquals(2, result[1].match(
44 /expectTrue\(false, 'message2'\): message2: false/g).length);
47 function testConstructMessage() {
48 var message = 1 + ' ' + 2;
49 assertTrue(false, message);
52 TEST_F('WebUIAssertionsTest', 'testConstructedMessage', function() {
53 var result = runTestFunction(
54 'testConstructMessage', testConstructMessage, []);
58 1, result[1].match(/assertTrue\(false, message\): 1 2: false/g).length);
62 * Failing version of WebUIAssertionsTest.
63 * @extends WebUIAssertionsTest
66 function WebUIAssertionsTestFail() {}
68 WebUIAssertionsTestFail.prototype = {
69 __proto__: WebUIAssertionsTest.prototype,
75 // Test that an assertion failure fails test.
76 TEST_F('WebUIAssertionsTestFail', 'testAssertFailFails', function() {
80 // Test that an expect failure fails test.
81 TEST_F('WebUIAssertionsTestFail', 'testExpectFailFails', function() {
86 * Async version of WebUIAssertionsTestFail.
87 * @extends WebUIAssertionsTest
90 function WebUIAssertionsTestAsyncFail() {}
92 WebUIAssertionsTestAsyncFail.prototype = {
93 __proto__: WebUIAssertionsTestFail.prototype,
99 // Test that an assertion failure doesn't hang forever.
100 TEST_F('WebUIAssertionsTestAsyncFail', 'testAsyncFailCallsDone', function() {