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

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

Issue 2213953003: Relanding: MD Settings: Adding some unit tests for <settings-main>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 /** 199 /**
200 * Navigates to the default search page (if necessary). 200 * Navigates to the default search page (if necessary).
201 * @private 201 * @private
202 */ 202 */
203 ensureInDefaultSearchPage_: function() { 203 ensureInDefaultSearchPage_: function() {
204 settings.navigateTo(settings.Route.BASIC); 204 settings.navigateTo(settings.Route.BASIC);
205 }, 205 },
206 206
207 /** 207 /**
208 * @param {string} query 208 * @param {string} query
209 * @return {!Promise} A promise indicating that searching finished.
209 */ 210 */
210 searchContents: function(query) { 211 searchContents: function(query) {
211 this.ensureInDefaultSearchPage_(); 212 this.ensureInDefaultSearchPage_();
212 this.toolbarSpinnerActive = true; 213 this.toolbarSpinnerActive = true;
213 214
214 // Trigger rendering of the basic and advanced pages and search once ready. 215 // Trigger rendering of the basic and advanced pages and search once ready.
215 this.showPages_ = {about: false, basic: true, advanced: true}; 216 this.showPages_ = {about: false, basic: true, advanced: true};
216 217
217 setTimeout(function() { 218 return new Promise(function(resolve, reject) {
218 settings.getSearchManager().search( 219 setTimeout(function() {
219 query, assert(this.$$('settings-basic-page'))); 220 var whenSearchDone = settings.getSearchManager().search(
220 }.bind(this), 0); 221 query, assert(this.$$('settings-basic-page')));
221 setTimeout(function() { 222 assert(
222 settings.getSearchManager().search( 223 whenSearchDone ===
223 query, assert(this.$$('settings-advanced-page'))).then( 224 settings.getSearchManager().search(
224 function(request) { 225 query, assert(this.$$('settings-advanced-page'))));
225 if (!request.finished) {
226 // Nothing to do here. A previous search request was canceled
227 // because a new search request was issued before the first one
228 // completed.
229 return;
230 }
231 226
232 this.toolbarSpinnerActive = false; 227 whenSearchDone.then(function(request) {
233 this.showNoResultsFound_ = 228 resolve();
234 !request.isSame('') && !request.didFindMatches(); 229 if (!request.finished) {
235 }.bind(this)); 230 // Nothing to do here. A previous search request was canceled
236 }.bind(this), 0); 231 // because a new search request was issued before the first one
232 // completed.
233 return;
234 }
235
236 this.toolbarSpinnerActive = false;
237 this.showNoResultsFound_ =
238 !request.isSame('') && !request.didFindMatches();
239 }.bind(this));
240 }.bind(this), 0);
241 }.bind(this));
237 }, 242 },
238 243
239 /** 244 /**
240 * @param {(boolean|undefined)} visibility 245 * @param {(boolean|undefined)} visibility
241 * @return {boolean} True unless visibility is false. 246 * @return {boolean} True unless visibility is false.
242 * @private 247 * @private
243 */ 248 */
244 showAdvancedSettings_: function(visibility) { 249 showAdvancedSettings_: function(visibility) {
245 return visibility !== false; 250 return visibility !== false;
246 }, 251 },
247 }); 252 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698