| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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('toolbar tests', function() { | 5 suite('toolbar tests', function() { |
| 6 /** @type {!downloads.Toolbar} */ | 6 /** @type {!downloads.Toolbar} */ |
| 7 var toolbar; | 7 var toolbar; |
| 8 | 8 |
| 9 setup(function() { | 9 setup(function() { |
| 10 /** |
| 11 * @constructor |
| 12 * @extends {downloads.ActionService} |
| 13 */ |
| 14 function TestActionService() { |
| 15 downloads.ActionService.call(this); |
| 16 } |
| 17 |
| 18 TestActionService.prototype = { |
| 19 __proto__: downloads.ActionService.prototype, |
| 20 loadMore: function() { /* Prevent chrome.send(). */ }, |
| 21 }; |
| 22 |
| 10 toolbar = document.createElement('downloads-toolbar'); | 23 toolbar = document.createElement('downloads-toolbar'); |
| 24 downloads.ActionService.instance_ = new TestActionService; |
| 11 document.body.appendChild(toolbar); | 25 document.body.appendChild(toolbar); |
| 12 }); | 26 }); |
| 13 | 27 |
| 14 test('resize closes more options menu', function() { | 28 test('resize closes more options menu', function() { |
| 15 MockInteractions.tap(toolbar.$$('paper-icon-button')); | 29 MockInteractions.tap(toolbar.$$('paper-icon-button')); |
| 16 assertTrue(toolbar.$.more.opened); | 30 assertTrue(toolbar.$.more.opened); |
| 17 | 31 |
| 18 window.dispatchEvent(new CustomEvent('resize')); | 32 window.dispatchEvent(new CustomEvent('resize')); |
| 19 assertFalse(toolbar.$.more.opened); | 33 assertFalse(toolbar.$.more.opened); |
| 20 }); | 34 }); |
| 35 |
| 36 test('search starts spinner', function() { |
| 37 toolbar.$.toolbar.fire('search-changed', 'a'); |
| 38 assertTrue(toolbar.spinnerActive); |
| 39 |
| 40 // Pretend the manager got results and set this to false. |
| 41 toolbar.spinnerActive = false; |
| 42 |
| 43 toolbar.$.toolbar.fire('search-changed', 'a '); // Same term plus a space. |
| 44 assertFalse(toolbar.spinnerActive); |
| 45 }); |
| 21 }); | 46 }); |
| OLD | NEW |