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

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: Address comments. 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
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, getComputedStyle(page.$$('#basicPage')).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,
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('block', 'none');
211 }); 216 });
212 217
213 // Ensure that clearing the search results restores both "basic" and 218 // Ensure that clearing the search results restores both "basic" and
214 // "advanced" page, when the search has been initiated from a subpage 219 // "advanced" page, when the search has been initiated from a subpage
215 // whose parent is the "advanced" page. 220 // whose parent is the "advanced" page.
216 test('exiting search mode, advanced expanded', function() { 221 test('exiting search mode, advanced expanded', function() {
217 settings.navigateTo(settings.Route.SITE_SETTINGS); 222 settings.navigateTo(settings.Route.SITE_SETTINGS);
218 Polymer.dom.flush(); 223 Polymer.dom.flush();
219 return assertPageVisibilityAfterSearch('', ''); 224 return assertPageVisibilityAfterSearch('block', 'block');
220 }); 225 });
221 226
222 // Ensure that searching, then entering a subpage, then going back 227 // Ensure that searching, then entering a subpage, then going back
223 // lands the user in a page where both basic and advanced sections are 228 // lands the user in a page where both basic and advanced sections are
224 // visible, because the page is still in search mode. 229 // visible, because the page is still in search mode.
225 test('returning from subpage to search results', function() { 230 test('returning from subpage to search results', function() {
226 settings.navigateTo(settings.Route.BASIC); 231 settings.navigateTo(settings.Route.BASIC);
227 Polymer.dom.flush(); 232 Polymer.dom.flush();
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('block', 'block');
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('block', 'block');
258 }).then(function() {
259 var whenHidden = test_util.whenAttributeIs(
260 advancedPage, 'hidden', true);
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('block', '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('block', 'block');
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') | chrome/test/data/webui/settings/test_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698