Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 } | 186 } |
| 187 | 187 |
| 188 // TODO(michaelpg): It would be better not to drill into | 188 // TODO(michaelpg): It would be better not to drill into |
| 189 // settings-basic-page. If search should indeed only work in Settings | 189 // settings-basic-page. If search should indeed only work in Settings |
| 190 // (as opposed to Advanced), perhaps some of this logic should be | 190 // (as opposed to Advanced), perhaps some of this logic should be |
| 191 // delegated to settings-basic-page now instead of settings-main. | 191 // delegated to settings-basic-page now instead of settings-main. |
| 192 | 192 |
| 193 /** | 193 /** |
| 194 * Asserts the visibility of the basic and advanced pages after exiting | 194 * Asserts the visibility of the basic and advanced pages after exiting |
| 195 * search mode. | 195 * search mode. |
| 196 * @param {string} Expected 'display' value for the basic page. | 196 * @param {string} Expected 'display' value for the basic page. |
|
dpapad
2017/05/31 00:40:42
Obsolete parameter.
scottchen
2017/05/31 18:25:28
Done.
| |
| 197 * @param {string} Expected 'display' value for the advanced page. | 197 * @param {string} Expected 'display' value for the advanced page. |
| 198 * @return {!Promise} | 198 * @return {!Promise} |
| 199 */ | 199 */ |
| 200 function assertPageVisibilityAfterSearch( | 200 function assertAdvancedVisibilityAfterSearch(expectedAdvanced) { |
| 201 expectedBasic, expectedAdvanced) { | |
| 202 searchManager.setMatchesFound(true); | 201 searchManager.setMatchesFound(true); |
| 203 return settingsMain.searchContents('Query1').then(function() { | 202 return settingsMain.searchContents('Query1') |
| 204 searchManager.setMatchesFound(false); | 203 .then(function() { |
| 205 return settingsMain.searchContents(''); | 204 searchManager.setMatchesFound(false); |
| 206 }).then(function() { | 205 return settingsMain.searchContents(''); |
| 207 return assertPageVisibility(expectedBasic, expectedAdvanced); | 206 }) |
| 208 }); | 207 .then(function() { |
| 208 settings.navigateTo( | |
| 209 settings.Route.BASIC); // Imitate clear search. | |
|
dpapad
2017/05/31 00:40:42
// Imitate clear search.
settings.navigateTo(setti
scottchen
2017/05/31 18:25:28
Done.
| |
| 210 Polymer.dom.flush(); | |
| 211 return assertPageVisibility('block', expectedAdvanced); | |
| 212 }); | |
| 209 } | 213 } |
| 210 | 214 |
| 211 test('exiting search mode, advanced collapsed', function() { | 215 test('exiting search mode, advanced collapsed', function() { |
| 212 // Simulating searching while the advanced page is collapsed. | 216 // Simulating searching while the advanced page is collapsed. |
| 213 settingsMain.currentRouteChanged(settings.Route.BASIC); | 217 settingsMain.currentRouteChanged(settings.Route.BASIC); |
| 214 Polymer.dom.flush(); | 218 Polymer.dom.flush(); |
| 215 return assertPageVisibilityAfterSearch('block', 'none'); | 219 return assertAdvancedVisibilityAfterSearch('none'); |
| 216 }); | 220 }); |
| 217 | 221 |
| 218 // Ensure that clearing the search results restores both "basic" and | 222 // Ensure that clearing the search results restores both "basic" and |
| 219 // "advanced" page, when the search has been initiated from a subpage | 223 // "advanced" page, when the search has been initiated from a subpage |
| 220 // whose parent is the "advanced" page. | 224 // whose parent is the "advanced" page. |
| 221 test('exiting search mode, advanced expanded', function() { | 225 test('exiting search mode, advanced expanded', function() { |
| 222 settings.navigateTo(settings.Route.SITE_SETTINGS); | 226 settings.navigateTo(settings.Route.SITE_SETTINGS); |
| 223 Polymer.dom.flush(); | 227 Polymer.dom.flush(); |
| 224 return assertPageVisibilityAfterSearch('block', 'block'); | 228 return assertAdvancedVisibilityAfterSearch('block'); |
| 225 }); | 229 }); |
| 226 | 230 |
| 227 // Ensure that searching, then entering a subpage, then going back | 231 // Ensure that searching, then entering a subpage, then going back |
| 228 // lands the user in a page where both basic and advanced sections are | 232 // lands the user in a page where both basic and advanced sections are |
| 229 // visible, because the page is still in search mode. | 233 // visible, because the page is still in search mode. |
| 230 test('returning from subpage to search results', function() { | 234 test('returning from subpage to search results', function() { |
| 231 settings.navigateTo(settings.Route.BASIC); | 235 settings.navigateTo(settings.Route.BASIC); |
| 232 Polymer.dom.flush(); | 236 Polymer.dom.flush(); |
| 233 | 237 |
| 234 searchManager.setMatchesFound(true); | 238 searchManager.setMatchesFound(true); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 | 285 |
| 282 return assertPageVisibility('block', 'block'); | 286 return assertPageVisibility('block', 'block'); |
| 283 }); | 287 }); |
| 284 }); | 288 }); |
| 285 } | 289 } |
| 286 | 290 |
| 287 return { | 291 return { |
| 288 registerTests: registerTests, | 292 registerTests: registerTests, |
| 289 }; | 293 }; |
| 290 }); | 294 }); |
| OLD | NEW |