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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 suite('<bookmarks-toast-manager>', function() {
6 var toastManager;
7 var store;
8
9 setup(function() {
10 toastManager = document.createElement('bookmarks-toast-manager');
11 replaceBody(toastManager);
12 });
13
14 test('simple show/hide', function() {
15 toastManager.show('test', false);
16 assertTrue(toastManager.open_);
17 assertEquals('test', toastManager.$.content.textContent);
18 assertTrue(toastManager.$$('paper-button').hidden);
19
20 toastManager.hide();
21 assertFalse(toastManager.open_);
22
23 toastManager.show('test', true);
24 assertFalse(toastManager.$$('paper-button').hidden);
25 });
26
27 test('auto hide', function() {
28 toastManager.duration = 100;
29
30 var timeoutFunc = null;
31 var timeoutCounter = 0;
32 var clearedTimeout = null;
33 toastManager.setTimeout_ = function(f) {
34 timeoutFunc = f;
35 return timeoutCounter++;
36 };
37 toastManager.clearTimeout_ = function(n) {
38 clearedTimeout = n;
39 };
40
41 toastManager.show('test', false);
42 assertEquals(0, toastManager.hideTimeout_);
43 assertTrue(toastManager.open_);
44
45 timeoutFunc();
46 assertEquals(null, toastManager.hideTimeout_);
47 assertFalse(toastManager.open_);
48
49 // Check that multiple shows reset the timeout.
50 toastManager.show('test', false);
51 assertEquals(1, toastManager.hideTimeout_);
52 assertTrue(toastManager.open_);
53
54 toastManager.show('test2', false);
55 assertEquals(1, clearedTimeout);
56 assertEquals(2, toastManager.hideTimeout_);
57 assertTrue(toastManager.open_);
58 });
59 });
OLDNEW
« 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