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

Side by Side Diff: chrome/test/data/webui/settings/settings_main_test.js

Issue 2863213002: MD Settings: Fix and re-enable settings-main tests. (Closed)
Patch Set: Nit Created 3 years, 7 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
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cr.define('settings_main_page', function() { 5 cr.define('settings_main_page', function() {
6 /** 6 /**
7 * Extending TestBrowserProxy even though SearchManager is not a browser proxy 7 * Extending TestBrowserProxy even though SearchManager is not a browser proxy
8 * itself. Essentially TestBrowserProxy can act as a "proxy" for any external 8 * itself. Essentially TestBrowserProxy can act as a "proxy" for any external
9 * dependency, not just "browser proxies" (and maybe should be renamed to 9 * dependency, not just "browser proxies" (and maybe should be renamed to
10 * TestProxy). 10 * TestProxy).
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 Polymer.dom.flush(); 162 Polymer.dom.flush();
163 assertTrue(noSearchResults.hidden); 163 assertTrue(noSearchResults.hidden);
164 assertToggleContainerVisible(true); 164 assertToggleContainerVisible(true);
165 }); 165 });
166 }); 166 });
167 167
168 /** 168 /**
169 * Asserts the visibility of the basic and advanced pages. 169 * Asserts the visibility of the basic and advanced pages.
170 * @param {string} Expected 'display' value for the basic page. 170 * @param {string} Expected 'display' value for the basic page.
171 * @param {string} Expected 'display' value for the advanced page. 171 * @param {string} Expected 'display' value for the advanced page.
172 * @return {!Promise}
172 */ 173 */
173 function assertPageVisibility(expectedBasic, expectedAdvanced) { 174 function assertPageVisibility(expectedBasic, expectedAdvanced) {
174 Polymer.dom.flush(); 175 Polymer.dom.flush();
175 var page = settingsMain.$$('settings-basic-page'); 176 var page = settingsMain.$$('settings-basic-page');
176 assertEquals( 177 assertEquals(
177 expectedBasic, page.$$('#basicPage').style.display); 178 expectedBasic, page.$$('#basicPage').style.display);
178 assertEquals( 179
179 expectedAdvanced, 180 return page.$$('#advancedPageTemplate').get().then(
180 page.$$('#advancedPageTemplate').get().style.display); 181 function(advancedPage) {
182 assertEquals(
183 expectedAdvanced || 'block',
michaelpg 2017/05/08 18:00:04 why the || 'block'? (is it related to callers invo
dpapad 2017/05/08 19:07:52 Updated all callers to pass 'block' instead of '',
michaelpg 2017/05/08 20:01:32 Oh, I see. Thanks for updating!
184 getComputedStyle(advancedPage).display);
185 });
181 } 186 }
182 187
183 // TODO(michaelpg): It would be better not to drill into 188 // TODO(michaelpg): It would be better not to drill into
184 // settings-basic-page. If search should indeed only work in Settings 189 // settings-basic-page. If search should indeed only work in Settings
185 // (as opposed to Advanced), perhaps some of this logic should be 190 // (as opposed to Advanced), perhaps some of this logic should be
186 // delegated to settings-basic-page now instead of settings-main. 191 // delegated to settings-basic-page now instead of settings-main.
187 192
188 /** 193 /**
189 * Asserts the visibility of the basic and advanced pages after exiting 194 * Asserts the visibility of the basic and advanced pages after exiting
190 * search mode. 195 * search mode.
191 * @param {string} Expected 'display' value for the basic page. 196 * @param {string} Expected 'display' value for the basic page.
192 * @param {string} Expected 'display' value for the advanced page. 197 * @param {string} Expected 'display' value for the advanced page.
193 * @return {!Promise} 198 * @return {!Promise}
194 */ 199 */
195 function assertPageVisibilityAfterSearch( 200 function assertPageVisibilityAfterSearch(
196 expectedBasic, expectedAdvanced) { 201 expectedBasic, expectedAdvanced) {
197 searchManager.setMatchesFound(true); 202 searchManager.setMatchesFound(true);
198 return settingsMain.searchContents('Query1').then(function() { 203 return settingsMain.searchContents('Query1').then(function() {
199 searchManager.setMatchesFound(false); 204 searchManager.setMatchesFound(false);
200 return settingsMain.searchContents(''); 205 return settingsMain.searchContents('');
201 }).then(function() { 206 }).then(function() {
202 assertPageVisibility(expectedBasic, expectedAdvanced); 207 return assertPageVisibility(expectedBasic, expectedAdvanced);
203 }); 208 });
204 } 209 }
205 210
206 test('exiting search mode, advanced collapsed', function() { 211 test('exiting search mode, advanced collapsed', function() {
207 // Simulating searching while the advanced page is collapsed. 212 // Simulating searching while the advanced page is collapsed.
208 settingsMain.currentRouteChanged(settings.Route.BASIC); 213 settingsMain.currentRouteChanged(settings.Route.BASIC);
209 Polymer.dom.flush(); 214 Polymer.dom.flush();
210 return assertPageVisibilityAfterSearch('', 'none'); 215 return assertPageVisibilityAfterSearch('', 'none');
211 }); 216 });
212 217
(...skipping 15 matching lines...) Expand all
228 233
229 searchManager.setMatchesFound(true); 234 searchManager.setMatchesFound(true);
230 return settingsMain.searchContents('Query1').then(function() { 235 return settingsMain.searchContents('Query1').then(function() {
231 // Simulate navigating into a subpage. 236 // Simulate navigating into a subpage.
232 settings.navigateTo(settings.Route.SEARCH_ENGINES); 237 settings.navigateTo(settings.Route.SEARCH_ENGINES);
233 settingsMain.$$('settings-basic-page').fire('subpage-expand'); 238 settingsMain.$$('settings-basic-page').fire('subpage-expand');
234 Polymer.dom.flush(); 239 Polymer.dom.flush();
235 240
236 // Simulate clicking the left arrow to go back to the search results. 241 // Simulate clicking the left arrow to go back to the search results.
237 settings.navigateTo(settings.Route.BASIC); 242 settings.navigateTo(settings.Route.BASIC);
238 assertPageVisibility('', ''); 243 return assertPageVisibility('', '');
239 }); 244 });
240 }); 245 });
241 246
242 // TODO(michaelpg): Move these to a new test for settings-basic-page. 247 // TODO(michaelpg): Move these to a new test for settings-basic-page.
243 test('can collapse advanced on advanced section route', function() { 248 test('can collapse advanced on advanced section route', function() {
244 settings.navigateTo(settings.Route.PRIVACY); 249 settings.navigateTo(settings.Route.PRIVACY);
245 Polymer.dom.flush(); 250 Polymer.dom.flush();
246 251
247 var advancedToggle = 252 var basicPage = settingsMain.$$('settings-basic-page');
248 getToggleContainer().querySelector('#advancedToggle'); 253 var advancedPage = null;
249 assertTrue(!!advancedToggle); 254 return basicPage.$$('#advancedPageTemplate').get().then(
255 function(advanced) {
256 advancedPage = advanced;
257 return assertPageVisibility('', '');
258 }).then(function() {
259 var whenHidden = test_util.whenAttributeIs(
260 advancedPage, 'hidden', true);
michaelpg 2017/05/08 18:00:03 The 'hidden' attribute can never be a boolean; it
dpapad 2017/05/08 19:07:52 Added TODO.
250 261
251 MockInteractions.tap(advancedToggle); 262 var advancedToggle =
252 Polymer.dom.flush(); 263 getToggleContainer().querySelector('#advancedToggle');
264 assertTrue(!!advancedToggle);
265 MockInteractions.tap(advancedToggle);
253 266
254 assertPageVisibility('', 'none'); 267 return whenHidden;
268 }).then(function() {
269 return assertPageVisibility('', 'none');
270 });
255 }); 271 });
256 272
257 test('navigating to a basic page does not collapse advanced', function() { 273 test('navigating to a basic page does not collapse advanced', function() {
258 settings.navigateTo(settings.Route.PRIVACY); 274 settings.navigateTo(settings.Route.PRIVACY);
259 Polymer.dom.flush(); 275 Polymer.dom.flush();
260 276
261 assertToggleContainerVisible(true); 277 assertToggleContainerVisible(true);
262 278
263 settings.navigateTo(settings.Route.PEOPLE); 279 settings.navigateTo(settings.Route.PEOPLE);
264 Polymer.dom.flush(); 280 Polymer.dom.flush();
265 281
266 assertPageVisibility('', ''); 282 return assertPageVisibility('', '');
267 }); 283 });
268 }); 284 });
269 } 285 }
270 286
271 return { 287 return {
272 registerTests: registerTests, 288 registerTests: registerTests,
273 }; 289 };
274 }); 290 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698