Chromium Code Reviews| 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 /** @fileoverview Suite of tests for cr-toolbar-search-field. */ | 5 /** @fileoverview Suite of tests for cr-toolbar-search-field. */ |
| 6 cr.define('cr_toolbar_search_field', function() { | 6 cr.define('cr_toolbar_search_field', function() { |
| 7 function registerTests() { | 7 function registerTests() { |
| 8 suite('cr-toolbar-search-field', function() { | 8 suite('cr-toolbar-search-field', function() { |
| 9 /** @type {?CrToolbarSearchFieldElement} */ | 9 /** @type {?CrToolbarSearchFieldElement} */ |
| 10 var field = null; | 10 var field = null; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 }); | 27 }); |
| 28 document.body.appendChild(field); | 28 document.body.appendChild(field); |
| 29 }); | 29 }); |
| 30 | 30 |
| 31 teardown(function() { | 31 teardown(function() { |
| 32 field.remove(); | 32 field.remove(); |
| 33 field = null; | 33 field = null; |
| 34 searches = null; | 34 searches = null; |
| 35 }); | 35 }); |
| 36 | 36 |
| 37 // Test that no bogus 'search-changed' event is fired during construction | |
|
Dan Beam
2016/10/28 20:54:06
s/bogus/initial
dpapad
2016/10/28 21:12:13
Done.
| |
| 38 // and initialization of the cr-toolbar-search-field element. | |
| 39 test('no bogus search-changed event', function() { | |
| 40 var didFire = false; | |
| 41 var onSearchChanged = function () { didFire = true; }; | |
| 42 | |
| 43 // Need to attach listener event before the element is created, to catch | |
| 44 // the bogus event. | |
| 45 document.body.addEventListener('search-changed', onSearchChanged); | |
| 46 document.body.innerHTML = | |
| 47 '<cr-toolbar-search-field></cr-toolbar-search-field>'; | |
| 48 // Remove event listener on |body| so that other tests are not affected. | |
| 49 document.body.removeEventListener('search-changed', onSearchChanged); | |
| 50 | |
| 51 assertFalse(didFire, 'Should not have fired search-changed event'); | |
| 52 }); | |
| 53 | |
| 37 test('opens and closes correctly', function() { | 54 test('opens and closes correctly', function() { |
| 38 assertFalse(field.showingSearch); | 55 assertFalse(field.showingSearch); |
| 39 MockInteractions.tap(field); | 56 MockInteractions.tap(field); |
| 40 assertTrue(field.showingSearch); | 57 assertTrue(field.showingSearch); |
| 41 assertEquals(field.$.searchInput, field.root.activeElement); | 58 assertEquals(field.$.searchInput, field.root.activeElement); |
| 42 | 59 |
| 43 MockInteractions.blur(field.$.searchInput); | 60 MockInteractions.blur(field.$.searchInput); |
| 44 assertFalse(field.showingSearch); | 61 assertFalse(field.showingSearch); |
| 45 | 62 |
| 46 MockInteractions.tap(field); | 63 MockInteractions.tap(field); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 assertFalse(clearSearch.hidden); | 146 assertFalse(clearSearch.hidden); |
| 130 assertTrue(field.showingSearch); | 147 assertTrue(field.showingSearch); |
| 131 }); | 148 }); |
| 132 }); | 149 }); |
| 133 } | 150 } |
| 134 | 151 |
| 135 return { | 152 return { |
| 136 registerTests: registerTests, | 153 registerTests: registerTests, |
| 137 }; | 154 }; |
| 138 }); | 155 }); |
| OLD | NEW |