| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 MockInteractions.pressAndReleaseKeyOn( | 49 MockInteractions.pressAndReleaseKeyOn( |
| 50 field.$.searchInput, 27, '', 'Escape'); | 50 field.$.searchInput, 27, '', 'Escape'); |
| 51 assertFalse(field.showingSearch, 'Pressing escape closes field.'); | 51 assertFalse(field.showingSearch, 'Pressing escape closes field.'); |
| 52 assertNotEquals(field.$.searchInput, field.root.activeElement); | 52 assertNotEquals(field.$.searchInput, field.root.activeElement); |
| 53 }); | 53 }); |
| 54 | 54 |
| 55 test('notifies on new searches', function() { | 55 test('notifies on new searches', function() { |
| 56 MockInteractions.tap(field); | 56 MockInteractions.tap(field); |
| 57 simulateSearch('query1'); | 57 simulateSearch('query1'); |
| 58 Polymer.dom.flush(); |
| 58 assertEquals('query1', field.getValue()); | 59 assertEquals('query1', field.getValue()); |
| 59 | 60 |
| 60 MockInteractions.tap(field.$.clearSearch); | 61 MockInteractions.tap(field.$$('#clearSearch')); |
| 61 assertFalse(field.showingSearch); | 62 assertFalse(field.showingSearch); |
| 62 assertEquals('', field.getValue()); | 63 assertEquals('', field.getValue()); |
| 63 | 64 |
| 64 simulateSearch('query2'); | 65 simulateSearch('query2'); |
| 65 // Expecting identical query to be ignored. | 66 // Expecting identical query to be ignored. |
| 66 simulateSearch('query2'); | 67 simulateSearch('query2'); |
| 67 | 68 |
| 68 assertEquals(['query1', '', 'query2'].join(), searches.join()); | 69 assertEquals(['query1', '', 'query2'].join(), searches.join()); |
| 69 }); | 70 }); |
| 70 | 71 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 85 MockInteractions.blur(field.$.searchInput); | 86 MockInteractions.blur(field.$.searchInput); |
| 86 | 87 |
| 87 assertTrue(field.showingSearch); | 88 assertTrue(field.showingSearch); |
| 88 }); | 89 }); |
| 89 | 90 |
| 90 test('opens when value is changed', function() { | 91 test('opens when value is changed', function() { |
| 91 // Change search value without explicity opening the field first. | 92 // Change search value without explicity opening the field first. |
| 92 // Similar to what happens when pasting or dragging into the input | 93 // Similar to what happens when pasting or dragging into the input |
| 93 // field. | 94 // field. |
| 94 simulateSearch('test'); | 95 simulateSearch('test'); |
| 96 Polymer.dom.flush(); |
| 95 | 97 |
| 96 assertFalse(field.$.clearSearch.hidden); | 98 var clearSearch = field.$$('#clearSearch'); |
| 99 assertFalse(clearSearch.hidden); |
| 97 assertTrue(field.showingSearch); | 100 assertTrue(field.showingSearch); |
| 98 | 101 |
| 99 MockInteractions.tap(field.$.clearSearch); | 102 MockInteractions.tap(clearSearch); |
| 100 assertFalse(field.showingSearch); | 103 assertFalse(field.showingSearch); |
| 101 }); | 104 }); |
| 102 }); | 105 }); |
| 103 } | 106 } |
| 104 | 107 |
| 105 return { | 108 return { |
| 106 registerTests: registerTests, | 109 registerTests: registerTests, |
| 107 }; | 110 }; |
| 108 }); | 111 }); |
| OLD | NEW |