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

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

Issue 2898303004: [MD Bookmarks] Add toasts. (Closed)
Patch Set: fix nits 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
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/md_bookmarks_browsertest.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..8830c8b2272d12876227a816998375a39abc4c9c
--- /dev/null
+++ b/chrome/test/data/webui/md_bookmarks/toast_manager_test.js
@@ -0,0 +1,59 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+suite('<bookmarks-toast-manager>', function() {
+ var toastManager;
+ var store;
+
+ setup(function() {
+ toastManager = document.createElement('bookmarks-toast-manager');
+ replaceBody(toastManager);
+ });
+
+ test('simple show/hide', function() {
+ toastManager.show('test', false);
+ assertTrue(toastManager.open_);
+ assertEquals('test', toastManager.$.content.textContent);
+ assertTrue(toastManager.$$('paper-button').hidden);
+
+ toastManager.hide();
+ assertFalse(toastManager.open_);
+
+ toastManager.show('test', true);
+ assertFalse(toastManager.$$('paper-button').hidden);
+ });
+
+ test('auto hide', function() {
+ toastManager.duration = 100;
+
+ var timeoutFunc = null;
+ var timeoutCounter = 0;
+ var clearedTimeout = null;
+ toastManager.setTimeout_ = function(f) {
+ timeoutFunc = f;
+ return timeoutCounter++;
+ };
+ toastManager.clearTimeout_ = function(n) {
+ clearedTimeout = n;
+ };
+
+ toastManager.show('test', false);
+ assertEquals(0, toastManager.hideTimeout_);
+ assertTrue(toastManager.open_);
+
+ timeoutFunc();
+ assertEquals(null, toastManager.hideTimeout_);
+ assertFalse(toastManager.open_);
+
+ // Check that multiple shows reset the timeout.
+ toastManager.show('test', false);
+ assertEquals(1, toastManager.hideTimeout_);
+ assertTrue(toastManager.open_);
+
+ toastManager.show('test2', false);
+ assertEquals(1, clearedTimeout);
+ assertEquals(2, toastManager.hideTimeout_);
+ assertTrue(toastManager.open_);
+ });
+});
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/md_bookmarks_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698