Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: chrome/test/data/webui/cr_elements/cr_toolbar_search_field_tests.js

Issue 2057353002: WebUI: cr-search-field, do not call delegate if search query did not change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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; 10 var field;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 MockInteractions.tap(field); 66 MockInteractions.tap(field);
67 assertEquals(field.$.searchInput, field.root.activeElement); 67 assertEquals(field.$.searchInput, field.root.activeElement);
68 68
69 MockInteractions.pressAndReleaseKeyOn( 69 MockInteractions.pressAndReleaseKeyOn(
70 field.$.searchInput, 27, '', 'Escape'); 70 field.$.searchInput, 27, '', 'Escape');
71 assertFalse(field.showingSearch, 'Pressing escape closes field.'); 71 assertFalse(field.showingSearch, 'Pressing escape closes field.');
72 assertNotEquals(field.$.searchInput, field.root.activeElement); 72 assertNotEquals(field.$.searchInput, field.root.activeElement);
73 }); 73 });
74 74
75 test('passes searches correctly', function() { 75 test('notifies on new searches', function() {
76 MockInteractions.tap(field); 76 MockInteractions.tap(field);
77 simulateSearch('test'); 77 simulateSearch('query1');
78 assertEquals('test', field.getValue()); 78 assertEquals('query1', field.getValue());
79 79
80 MockInteractions.tap(field.$.clearSearch); 80 MockInteractions.tap(field.$.clearSearch);
81 assertFalse(field.showingSearch); 81 assertFalse(field.showingSearch);
82 assertEquals('', field.getValue()); 82 assertEquals('', field.getValue());
83 83
84 assertEquals(['test', ''].join(), delegate.searches.join()); 84 simulateSearch('query2');
85 // Expecting identical query to be ignored.
86 simulateSearch('query2');
87
88 assertEquals(['query1', '', 'query2'].join(), delegate.searches.join());
85 }); 89 });
86 90
87 test('blur does not close field when a search is active', function() { 91 test('blur does not close field when a search is active', function() {
88 MockInteractions.tap(field); 92 MockInteractions.tap(field);
89 simulateSearch('test'); 93 simulateSearch('test');
90 MockInteractions.blur(field.$.searchInput); 94 MockInteractions.blur(field.$.searchInput);
91 95
92 assertTrue(field.showingSearch); 96 assertTrue(field.showingSearch);
93 }); 97 });
94 }); 98 });
95 } 99 }
96 100
97 return { 101 return {
98 registerTests: registerTests, 102 registerTests: registerTests,
99 }; 103 };
100 }); 104 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698