1 // Copyright (c) 2012 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.
6 * Asserts the value is true.
7 * @param {*} x The value to assert.
15 * Asserts the values are equal.
16 * @param {*} x The value to assert.
18 function assertEquals(x
, y
) {
20 throw new Error(x
+ ' != ' + y
);
24 * Runs the given test.
25 * @param {function()} test The test to run.
26 * @param {function()} onPass The function to call if and when the
29 function runTest(test
, onPass
) {
30 var shouldContinue
= true;
32 waitForAsync: function(description
) {
33 shouldContinue
= false;
34 console
.log('Waiting for ', description
);
37 continueTesting: function() {
38 shouldContinue
= true;
39 window
.setTimeout(function() {
52 * Runs all tests and reports the results via the console.
56 for (var i
in window
) {
57 if (i
.indexOf('test') == 0)
58 tests
.push(window
[i
]);
60 console
.log('Running %d tests...', tests
.length
);
63 function runNextTest() {
64 if (testNo
>= tests
.length
) {
65 console
.log('All tests passed');
74 var test
= tests
[testNo
];
75 console
.log('Running (%d/%d) -- %s', testNo
+ 1, tests
.length
, test
.name
);
76 runTest(test
, onPass
);
81 window
.addEventListener('load', function() {