OLD | NEW |
(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 }); |
OLD | NEW |