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

Side by Side Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2185493003: MD Settings: Adding some unit tests for <settings-main>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@search_no_results
Patch Set: Nit. Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'settings-main' displays the selected settings page. 7 * 'settings-main' displays the selected settings page.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-main', 10 is: 'settings-main',
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 /** 186 /**
187 * Navigates to the default search page (if necessary). 187 * Navigates to the default search page (if necessary).
188 * @private 188 * @private
189 */ 189 */
190 ensureInDefaultSearchPage_: function() { 190 ensureInDefaultSearchPage_: function() {
191 settings.navigateTo(settings.Route.BASIC); 191 settings.navigateTo(settings.Route.BASIC);
192 }, 192 },
193 193
194 /** 194 /**
195 * @param {string} query 195 * @param {string} query
michaelpg 2016/07/30 05:38:44 @return
dpapad 2016/08/01 21:23:06 Done.
196 */ 196 */
197 searchContents: function(query) { 197 searchContents: function(query) {
198 var promiseResolver = new PromiseResolver();
michaelpg 2016/07/30 05:38:44 this promise/setTimeout business is scary, if we'r
michaelpg 2016/07/30 05:38:44 ok, after looking over it... we're resolving this
dpapad 2016/08/01 21:23:06 Removed PromiseResolver. Yes, it was used to avoid
199
198 this.ensureInDefaultSearchPage_(); 200 this.ensureInDefaultSearchPage_();
199 this.toolbarSpinnerActive = true; 201 this.toolbarSpinnerActive = true;
200 202
201 // Trigger rendering of the basic and advanced pages and search once ready. 203 // Trigger rendering of the basic and advanced pages and search once ready.
202 this.showPages_ = {about: false, basic: true, advanced: true}; 204 this.showPages_ = {about: false, basic: true, advanced: true};
203 205
204 setTimeout(function() { 206 setTimeout(function() {
205 settings.getSearchManager().search( 207 settings.getSearchManager().search(
206 query, assert(this.$$('settings-basic-page'))); 208 query, assert(this.$$('settings-basic-page')));
michaelpg 2016/07/30 05:38:44 We've gotten into trouble by assuming that doing s
dpapad 2016/08/01 21:23:06 Ack. If the asserts break, we should find a more c
207 }.bind(this), 0); 209 }.bind(this), 0);
208 setTimeout(function() { 210 setTimeout(function() {
michaelpg 2016/07/30 05:38:44 SearchManager is a singleton, has only one task qu
dpapad 2016/08/01 21:23:06 Merged the two setTimeouts to a single call.
209 settings.getSearchManager().search( 211 settings.getSearchManager().search(
210 query, assert(this.$$('settings-advanced-page'))).then( 212 query, assert(this.$$('settings-advanced-page'))).then(
michaelpg 2016/07/30 05:38:44 this ".then" is okay (I think) because this line a
dpapad 2016/08/01 21:23:06 Cleaned up the code a bit to address your points.
211 function(request) { 213 function(request) {
212 if (!request.finished) { 214 if (!request.finished) {
213 // Nothing to do here. A previous search request was canceled 215 // Nothing to do here. A previous search request was canceled
214 // because a new search request was issued before the first one 216 // because a new search request was issued before the first one
215 // completed. 217 // completed.
218 promiseResolver.resolve();
michaelpg 2016/07/30 05:38:44 we should just resolve this before the if so we do
dpapad 2016/08/01 21:23:06 Done.
216 return; 219 return;
217 } 220 }
218 221
219 this.toolbarSpinnerActive = false; 222 this.toolbarSpinnerActive = false;
220 this.showNoResultsFound_ = 223 this.showNoResultsFound_ =
221 !request.isSame('') && !request.didFindMatches(); 224 !request.isSame('') && !request.didFindMatches();
225 promiseResolver.resolve();
222 }.bind(this)); 226 }.bind(this));
223 }.bind(this), 0); 227 }.bind(this), 0);
228
229 return promiseResolver.promise;
224 }, 230 },
225 231
226 /** 232 /**
227 * @param {(boolean|undefined)} visibility 233 * @param {(boolean|undefined)} visibility
228 * @return {boolean} True unless visibility is false. 234 * @return {boolean} True unless visibility is false.
229 * @private 235 * @private
230 */ 236 */
231 showAdvancedSettings_: function(visibility) { 237 showAdvancedSettings_: function(visibility) {
232 return visibility !== false; 238 return visibility !== false;
233 }, 239 },
234 }); 240 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698