aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/async/conditionaldelay_test.html
diff options
context:
space:
mode:
Diffstat (limited to 'contexts/data/lib/closure-library/closure/goog/async/conditionaldelay_test.html')
-rw-r--r--contexts/data/lib/closure-library/closure/goog/async/conditionaldelay_test.html227
1 files changed, 0 insertions, 227 deletions
diff --git a/contexts/data/lib/closure-library/closure/goog/async/conditionaldelay_test.html b/contexts/data/lib/closure-library/closure/goog/async/conditionaldelay_test.html
deleted file mode 100644
index ce33dfd..0000000
--- a/contexts/data/lib/closure-library/closure/goog/async/conditionaldelay_test.html
+++ /dev/null
@@ -1,227 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 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.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.async.ConditionalDelay</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.async.ConditionalDelay');
- goog.require('goog.testing.MockClock');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-var invoked = false;
-var delay = null;
-var clock = null;
-var returnValue = true;
-var onSuccessCalled = false;
-var onFailureCalled = false;
-
-
-function callback() {
- invoked = true;
- return returnValue;
-}
-
-
-function setUp() {
- clock = new goog.testing.MockClock(true);
- invoked = false;
- returnValue = true;
- onSuccessCalled = false;
- onFailureCalled = false;
- delay = new goog.async.ConditionalDelay(callback);
- delay.onSuccess = function() {
- onSuccessCalled = true;
- }
- delay.onFailure = function() {
- onFailureCalled = true;
- }
-}
-
-
-function tearDown() {
- clock.dispose();
- delay.dispose();
-}
-
-
-function testDelay() {
- delay.start(200, 200);
- assertFalse(invoked);
-
- clock.tick(100);
- assertFalse(invoked);
-
- clock.tick(100);
- assertTrue(invoked);
-}
-
-
-function testStop() {
- delay.start(200, 500);
- assertTrue(delay.isActive());
-
- clock.tick(100);
- assertFalse(invoked);
-
- delay.stop();
- clock.tick(100);
- assertFalse(invoked);
-
- assertFalse(delay.isActive());
-}
-
-
-function testIsActive() {
- assertFalse(delay.isActive());
- delay.start(200, 200);
- assertTrue(delay.isActive());
- clock.tick(200);
- assertFalse(delay.isActive());
-}
-
-
-function testRestart() {
- delay.start(200, 50000);
- clock.tick(100);
-
- delay.stop();
- assertFalse(invoked);
-
- delay.start(200, 50000);
- clock.tick(199);
- assertFalse(invoked);
-
- clock.tick(1);
- assertTrue(invoked);
-
- invoked = false;
- delay.start(200, 200);
- clock.tick(200);
- assertTrue(invoked);
-
- assertFalse(delay.isActive());
-}
-
-
-function testDispose() {
- delay.start(200, 200);
- delay.dispose();
- assertTrue(delay.isDisposed());
-
- clock.tick(500);
- assertFalse(invoked);
-}
-
-
-function testConditionalDelay_Success() {
- returnValue = false;
- delay.start(100, 300);
-
- clock.tick(99);
- assertFalse(invoked);
- clock.tick(1);
- assertTrue(invoked);
-
- assertTrue(delay.isActive());
- assertFalse(delay.isDone());
- assertFalse(onSuccessCalled);
- assertFalse(onFailureCalled);
-
- returnValue = true;
-
- invoked = false;
- clock.tick(100);
- assertTrue(invoked);
-
- assertFalse(delay.isActive());
- assertTrue(delay.isDone());
- assertTrue(onSuccessCalled);
- assertFalse(onFailureCalled);
-
- invoked = false;
- clock.tick(200);
- assertFalse(invoked);
-}
-
-
-function testConditionalDelay_Failure() {
- returnValue = false;
- delay.start(100, 300);
-
- clock.tick(99);
- assertFalse(invoked);
- clock.tick(1);
- assertTrue(invoked);
-
- assertTrue(delay.isActive());
- assertFalse(delay.isDone());
- assertFalse(onSuccessCalled);
- assertFalse(onFailureCalled);
-
- invoked = false;
- clock.tick(100);
- assertTrue(invoked);
- assertFalse(onSuccessCalled);
- assertFalse(onFailureCalled);
-
- invoked = false;
- clock.tick(90);
- assertFalse(invoked);
- clock.tick(10);
- assertTrue(invoked);
-
- assertFalse(delay.isActive());
- assertFalse(delay.isDone());
- assertFalse(onSuccessCalled);
- assertTrue(onFailureCalled);
-}
-
-
-function testInfiniteDelay() {
- returnValue = false;
- delay.start(100, -1);
-
- // Test in a big enough loop.
- for (var i = 0; i < 1000; ++i) {
- clock.tick(80);
- assertTrue(delay.isActive());
- assertFalse(delay.isDone());
- assertFalse(onSuccessCalled);
- assertFalse(onFailureCalled);
- }
-
- delay.stop();
- assertFalse(delay.isActive());
- assertFalse(delay.isDone());
- assertFalse(onSuccessCalled);
- assertFalse(onFailureCalled);
-}
-
-function testCallbackScope() {
- var callbackCalled = false;
- var scopeObject = {};
- function internalCallback() {
- assertEquals(this, scopeObject);
- callbackCalled = true;
- return true;
- }
- delay = new goog.async.ConditionalDelay(internalCallback, scopeObject);
- delay.start(200, 200);
- clock.tick(201);
- assertTrue(callbackCalled);
-}
-
-</script>
-</body>
-</html>