diff options
Diffstat (limited to 'contexts/data/lib/closure-library/closure/goog/testing/asynctestcase_noasync_test.html')
-rw-r--r-- | contexts/data/lib/closure-library/closure/goog/testing/asynctestcase_noasync_test.html | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/asynctestcase_noasync_test.html b/contexts/data/lib/closure-library/closure/goog/testing/asynctestcase_noasync_test.html deleted file mode 100644 index edbf55d..0000000 --- a/contexts/data/lib/closure-library/closure/goog/testing/asynctestcase_noasync_test.html +++ /dev/null @@ -1,98 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Copyright 2009 The Closure Library Authors. All Rights Reserved. - -Use of this source code is governed by the Apache License, Version 2.0. -See the COPYING file for details. ---> -<!-- -Author: agrieve@google.com (Andrew Grieve) - -This tests that the AsyncTestCase can handle synchronous behaviour in: - setUpPage(), - setUp(), - test*(), - tearDown() -It is the same test as asynctestcase_async_test.html, except that it uses a mock -version of window.setTimeout() to eliminate all asynchronous calls. ---> -<head> -<meta http-equiv="X-UA-Compatible" content="IE=edge"> - <title>Closure Unit Tests - goog.testing.AsyncTestCase Synchronous Tests</title> - <script src="../base.js"></script> - <script type="text/javascript"> - goog.require('goog.testing.AsyncTestCase'); - goog.require('goog.testing.jsunit'); - </script> -</head> -<body> - <script> - // Has the setUp() function been called. - var setUpCalled = false; - // Has the current test function completed. This helps us to ensure that the - // next test is not started before the previous completed. - var curTestIsDone = true; - // For restoring it later. - var oldTimeout = window.setTimeout; - // Use an asynchronous test runner for our tests. - var asyncTestCase = - goog.testing.AsyncTestCase.createAndInstall(document.title); - - /** - * Uses window.setTimeout() to perform asynchronous behaviour and uses - * asyncTestCase.waitForAsync() and asyncTestCase.continueTesting() to mark - * the beginning and end of it. - * @param {number} numAsyncCalls The number of asynchronous calls to make. - * @param {string} name The name of the current step. - */ - function doAsyncStuff(numAsyncCalls, name) { - if (numAsyncCalls > 0) { - curTestIsDone = false; - asyncTestCase.waitForAsync('doAsyncStuff-' + name + '(' + numAsyncCalls - + ')'); - window.setTimeout(function() { - doAsyncStuff(numAsyncCalls - 1, name); - }, 0); - } else { - curTestIsDone = true; - asyncTestCase.continueTesting(); - } - } - - function setUpPage() { - debug('setUpPage was called.'); - // Don't do anything asynchronously. - window.setTimeout = function(callback, time) { - callback(); - }; - doAsyncStuff(3, 'setUpPage'); - } - function setUp() { - assertTrue(curTestIsDone); - doAsyncStuff(3, 'setUp'); - } - function tearDown() { - assertTrue(curTestIsDone); - } - function test1() { - assertTrue(curTestIsDone); - doAsyncStuff(1, 'test1'); - } - function test2() { - assertTrue(curTestIsDone); - doAsyncStuff(2, 'test2'); - } - function test3() { - assertTrue(curTestIsDone); - doAsyncStuff(5, 'test3'); - } - function tearDownPage() { - debug('tearDownPage was called.'); - assertTrue(curTestIsDone); - window.setTimeout = oldTimeout; - } - - </script> -</body> -</html> |