OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 suite('<bookmarks-toast-manager>', function() { | 5 suite('<bookmarks-toast-manager>', function() { |
6 var toastManager; | 6 var toastManager; |
7 var store; | 7 var store; |
8 | 8 |
9 setup(function() { | 9 setup(function() { |
10 toastManager = document.createElement('bookmarks-toast-manager'); | 10 toastManager = document.createElement('bookmarks-toast-manager'); |
11 replaceBody(toastManager); | 11 replaceBody(toastManager); |
12 }); | 12 }); |
13 | 13 |
14 test('simple show/hide', function() { | 14 test('simple show/hide', function() { |
15 toastManager.show('test', false); | 15 toastManager.show('test', false); |
16 assertTrue(toastManager.open_); | 16 assertTrue(toastManager.open_); |
17 assertEquals('test', toastManager.$.content.textContent); | 17 assertEquals('test', toastManager.$.content.textContent); |
18 assertTrue(toastManager.$$('paper-button').hidden); | 18 assertTrue(toastManager.$$('paper-button').hidden); |
19 | 19 |
20 toastManager.hide(); | 20 toastManager.hide(); |
21 assertFalse(toastManager.open_); | 21 assertFalse(toastManager.open_); |
22 | 22 |
23 toastManager.show('test', true); | 23 toastManager.show('test', true); |
24 assertFalse(toastManager.$$('paper-button').hidden); | 24 assertFalse(toastManager.$$('paper-button').hidden); |
| 25 |
| 26 toastManager.hide(); |
| 27 assertTrue(toastManager.$.button.hidden); |
25 }); | 28 }); |
26 | 29 |
27 test('auto hide', function() { | 30 test('auto hide', function() { |
28 var timerProxy = new bookmarks.TestTimerProxy(); | 31 var timerProxy = new bookmarks.TestTimerProxy(); |
29 timerProxy.immediatelyResolveTimeouts = false; | 32 timerProxy.immediatelyResolveTimeouts = false; |
30 toastManager.timerProxy_ = timerProxy; | 33 toastManager.timerProxy_ = timerProxy; |
31 | 34 |
32 toastManager.duration = 100; | 35 toastManager.duration = 100; |
33 | 36 |
34 toastManager.show('test', false); | 37 toastManager.show('test', false); |
35 assertEquals(0, toastManager.hideTimeoutId_); | 38 assertEquals(0, toastManager.hideTimeoutId_); |
36 assertTrue(toastManager.open_); | 39 assertTrue(toastManager.open_); |
37 | 40 |
38 timerProxy.runTimeoutFn(0); | 41 timerProxy.runTimeoutFn(0); |
39 assertEquals(null, toastManager.hideTimeoutId_); | 42 assertEquals(null, toastManager.hideTimeoutId_); |
40 assertFalse(toastManager.open_); | 43 assertFalse(toastManager.open_); |
41 | 44 |
42 // Check that multiple shows reset the timeout. | 45 // Check that multiple shows reset the timeout. |
43 toastManager.show('test', false); | 46 toastManager.show('test', false); |
44 assertEquals(1, toastManager.hideTimeoutId_); | 47 assertEquals(1, toastManager.hideTimeoutId_); |
45 assertTrue(toastManager.open_); | 48 assertTrue(toastManager.open_); |
46 | 49 |
47 toastManager.show('test2', false); | 50 toastManager.show('test2', false); |
48 assertFalse(timerProxy.hasTimeout(1)); | 51 assertFalse(timerProxy.hasTimeout(1)); |
49 assertEquals(2, toastManager.hideTimeoutId_); | 52 assertEquals(2, toastManager.hideTimeoutId_); |
50 assertTrue(toastManager.open_); | 53 assertTrue(toastManager.open_); |
51 }); | 54 }); |
52 }); | 55 }); |
OLD | NEW |