Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6107)

Unified Diff: chrome/test/data/webui/md_bookmarks/toast_manager_test.js

Issue 2926763005: [MD Bookmarks] Refactor window timer mocking. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/md_bookmarks/toast_manager_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/toast_manager_test.js b/chrome/test/data/webui/md_bookmarks/toast_manager_test.js
index 8830c8b2272d12876227a816998375a39abc4c9c..018e020d141b371031181443bf37f8ccb839b356 100644
--- a/chrome/test/data/webui/md_bookmarks/toast_manager_test.js
+++ b/chrome/test/data/webui/md_bookmarks/toast_manager_test.js
@@ -25,24 +25,17 @@ suite('<bookmarks-toast-manager>', function() {
});
test('auto hide', function() {
- toastManager.duration = 100;
+ var timerProxy = new bookmarks.TestTimerProxy();
+ timerProxy.immediatelyResolveTimeouts = false;
+ toastManager.timerProxy_ = timerProxy;
- var timeoutFunc = null;
- var timeoutCounter = 0;
- var clearedTimeout = null;
- toastManager.setTimeout_ = function(f) {
- timeoutFunc = f;
- return timeoutCounter++;
- };
- toastManager.clearTimeout_ = function(n) {
- clearedTimeout = n;
- };
+ toastManager.duration = 100;
toastManager.show('test', false);
assertEquals(0, toastManager.hideTimeout_);
assertTrue(toastManager.open_);
- timeoutFunc();
+ timerProxy.runTimeoutFn(0);
assertEquals(null, toastManager.hideTimeout_);
assertFalse(toastManager.open_);
@@ -52,7 +45,7 @@ suite('<bookmarks-toast-manager>', function() {
assertTrue(toastManager.open_);
toastManager.show('test2', false);
- assertEquals(1, clearedTimeout);
+ assertFalse(timerProxy.hasTimeout(1));
assertEquals(2, toastManager.hideTimeout_);
assertTrue(toastManager.open_);
});

Powered by Google App Engine
This is Rietveld 408576698