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