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

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

Issue 2372503002: MD WebUI: Change <cr-toolbar> clear button to not close the search field (Closed)
Patch Set: Vulcanize Created 4 years, 2 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 = null; 10 var field = null;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 MockInteractions.tap(field); 46 MockInteractions.tap(field);
47 assertEquals(field.$.searchInput, field.root.activeElement); 47 assertEquals(field.$.searchInput, field.root.activeElement);
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('clear search button clears and refocuses input', function() {
56 MockInteractions.tap(field);
57 simulateSearch('query1');
58 Polymer.dom.flush();
59
60 var clearSearch = field.$$('#clearSearch');
61 clearSearch.focus();
62 MockInteractions.tap(clearSearch);
63 assertTrue(field.showingSearch);
64 assertEquals('', field.getValue());
65 assertEquals(field.$.searchInput, field.root.activeElement);
66 });
67
55 test('notifies on new searches', function() { 68 test('notifies on new searches', function() {
56 MockInteractions.tap(field); 69 MockInteractions.tap(field);
57 simulateSearch('query1'); 70 simulateSearch('query1');
58 Polymer.dom.flush(); 71 Polymer.dom.flush();
59 assertEquals('query1', field.getValue()); 72 assertEquals('query1', field.getValue());
60 73
61 MockInteractions.tap(field.$$('#clearSearch')); 74 MockInteractions.tap(field.$$('#clearSearch'));
62 assertFalse(field.showingSearch); 75 assertTrue(field.showingSearch);
63 assertEquals('', field.getValue()); 76 assertEquals('', field.getValue());
64 77
65 simulateSearch('query2'); 78 simulateSearch('query2');
66 // Expecting identical query to be ignored. 79 // Expecting identical query to be ignored.
67 simulateSearch('query2'); 80 simulateSearch('query2');
68 81
69 assertEquals(['query1', '', 'query2'].join(), searches.join()); 82 assertEquals(['query1', '', 'query2'].join(), searches.join());
70 }); 83 });
71 84
72 test('notifies on setValue', function() { 85 test('notifies on setValue', function() {
(...skipping 18 matching lines...) Expand all
91 test('opens when value is changed', function() { 104 test('opens when value is changed', function() {
92 // Change search value without explicity opening the field first. 105 // Change search value without explicity opening the field first.
93 // Similar to what happens when pasting or dragging into the input 106 // Similar to what happens when pasting or dragging into the input
94 // field. 107 // field.
95 simulateSearch('test'); 108 simulateSearch('test');
96 Polymer.dom.flush(); 109 Polymer.dom.flush();
97 110
98 var clearSearch = field.$$('#clearSearch'); 111 var clearSearch = field.$$('#clearSearch');
99 assertFalse(clearSearch.hidden); 112 assertFalse(clearSearch.hidden);
100 assertTrue(field.showingSearch); 113 assertTrue(field.showingSearch);
101
102 MockInteractions.tap(clearSearch);
103 assertFalse(field.showingSearch);
104 }); 114 });
105 }); 115 });
106 } 116 }
107 117
108 return { 118 return {
109 registerTests: registerTests, 119 registerTests: registerTests,
110 }; 120 };
111 }); 121 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698