| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 assertEquals(['foo', '', 'bar', 'baz'].join(), searches.join()); | 79 assertEquals(['foo', '', 'bar', 'baz'].join(), searches.join()); |
| 80 }); | 80 }); |
| 81 | 81 |
| 82 test('blur does not close field when a search is active', function() { | 82 test('blur does not close field when a search is active', function() { |
| 83 MockInteractions.tap(field); | 83 MockInteractions.tap(field); |
| 84 simulateSearch('test'); | 84 simulateSearch('test'); |
| 85 MockInteractions.blur(field.$.searchInput); | 85 MockInteractions.blur(field.$.searchInput); |
| 86 | 86 |
| 87 assertTrue(field.showingSearch); | 87 assertTrue(field.showingSearch); |
| 88 }); | 88 }); |
| 89 |
| 90 test('opens when value is changed', function() { |
| 91 // Change search value without explicity opening the field first. |
| 92 // Similar to what happens when pasting or dragging into the input |
| 93 // field. |
| 94 simulateSearch('test'); |
| 95 |
| 96 assertFalse(field.$.clearSearch.hidden); |
| 97 assertTrue(field.showingSearch); |
| 98 |
| 99 MockInteractions.tap(field.$.clearSearch); |
| 100 assertFalse(field.showingSearch); |
| 101 }); |
| 89 }); | 102 }); |
| 90 } | 103 } |
| 91 | 104 |
| 92 return { | 105 return { |
| 93 registerTests: registerTests, | 106 registerTests: registerTests, |
| 94 }; | 107 }; |
| 95 }); | 108 }); |
| OLD | NEW |