diff options
Diffstat (limited to 'contexts/data/lib/closure-library/closure/goog/async/throttle_test.html')
-rw-r--r-- | contexts/data/lib/closure-library/closure/goog/async/throttle_test.html | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/contexts/data/lib/closure-library/closure/goog/async/throttle_test.html b/contexts/data/lib/closure-library/closure/goog/async/throttle_test.html deleted file mode 100644 index fb653ca..0000000 --- a/contexts/data/lib/closure-library/closure/goog/async/throttle_test.html +++ /dev/null @@ -1,102 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Copyright 2006 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.Throttle</title> -<script src="../base.js"></script> -<script> - goog.require('goog.async.Throttle'); - goog.require('goog.testing.MockClock'); - goog.require('goog.testing.jsunit'); -</script> -</head> -<body> - -<script> - -function testThrottle() { - var clock = new goog.testing.MockClock(true); - - var callBackCount = 0; - var callBackFunction = function() { - callBackCount++; - } - - var throttle = new goog.async.Throttle(callBackFunction, 100); - assertEquals(0, callBackCount); - throttle.fire(); - assertEquals(1, callBackCount); - throttle.fire(); - assertEquals(1, callBackCount); - throttle.fire(); - throttle.fire(); - assertEquals(1, callBackCount); - clock.tick(101); - assertEquals(2, callBackCount); - clock.tick(101); - assertEquals(2, callBackCount); - - throttle.fire(); - assertEquals(3, callBackCount); - throttle.fire(); - assertEquals(3, callBackCount); - throttle.stop(); - clock.tick(101); - assertEquals(3, callBackCount); - throttle.fire(); - assertEquals(4, callBackCount); - clock.tick(101); - assertEquals(4, callBackCount); - - throttle.fire(); - throttle.fire(); - assertEquals(5, callBackCount); - throttle.pause(); - throttle.resume(); - assertEquals(5, callBackCount); - throttle.pause(); - clock.tick(101); - assertEquals(5, callBackCount); - throttle.resume(); - assertEquals(6, callBackCount); - clock.tick(101); - assertEquals(6, callBackCount); - throttle.pause(); - throttle.fire(); - assertEquals(6, callBackCount); - clock.tick(101); - assertEquals(6, callBackCount); - throttle.resume(); - assertEquals(7, callBackCount); - - throttle.pause(); - throttle.pause(); - clock.tick(101); - throttle.fire(); - throttle.resume(); - assertEquals(7, callBackCount); - throttle.resume(); - assertEquals(8, callBackCount); - - throttle.pause(); - throttle.pause(); - throttle.fire(); - throttle.resume(); - clock.tick(101); - assertEquals(8, callBackCount); - throttle.resume(); - assertEquals(9, callBackCount); - - clock.uninstall(); -} - -</script> - -</body> -</html> |