Reland "Non-SFI mode: Switch to newlib. (patchset #4 id:60001 of https://codereview...
[chromium-blink-merge.git] / chrome / test / data / webui / assertions.js
blobf8d7f19f88b192991ece2a62dac2c00b6068c95e
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() {
13 expectTrue(false);
14 expectTrue(0);
17 TEST_F('WebUIAssertionsTest', 'testTwoExpects', function() {
18 var result = runTestFunction('testTwoExpects', testTwoExpects, []);
19 resetTestState();
21 expectFalse(result[0]);
22 expectTrue(!!result[1].match(/expectTrue\(false\): false/));
23 expectTrue(!!result[1].match(/expectTrue\(0\): 0/));
24 });
26 function twoExpects() {
27 expectTrue(false, 'message1');
28 expectTrue(false, 'message2');
31 function testCallTestTwice() {
32 twoExpects();
33 twoExpects();
36 TEST_F('WebUIAssertionsTest', 'testCallTestTwice', function() {
37 var result = runTestFunction('testCallTestTwice', testCallTestTwice, []);
38 resetTestState();
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);
45 });
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, []);
55 resetTestState();
57 expectEquals(
58 1, result[1].match(/assertTrue\(false, message\): 1 2: false/g).length);
59 });
61 /**
62 * Failing version of WebUIAssertionsTest.
63 * @extends WebUIAssertionsTest
64 * @constructor
66 function WebUIAssertionsTestFail() {}
68 WebUIAssertionsTestFail.prototype = {
69 __proto__: WebUIAssertionsTest.prototype,
71 /** @inheritDoc */
72 testShouldFail: true,
75 // Test that an assertion failure fails test.
76 TEST_F('WebUIAssertionsTestFail', 'testAssertFailFails', function() {
77 assertNotReached();
78 });
80 // Test that an expect failure fails test.
81 TEST_F('WebUIAssertionsTestFail', 'testExpectFailFails', function() {
82 expectNotReached();
83 });
85 /**
86 * Async version of WebUIAssertionsTestFail.
87 * @extends WebUIAssertionsTest
88 * @constructor
90 function WebUIAssertionsTestAsyncFail() {}
92 WebUIAssertionsTestAsyncFail.prototype = {
93 __proto__: WebUIAssertionsTestFail.prototype,
95 /** @inheritDoc */
96 isAsync: true,
99 // Test that an assertion failure doesn't hang forever.
100 TEST_F('WebUIAssertionsTestAsyncFail', 'testAsyncFailCallsDone', function() {
101 assertNotReached();