| 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. | |
| 197 * @param {string} Expected 'display' value for the advanced page. | 196 * @param {string} Expected 'display' value for the advanced page. |
| 198 * @return {!Promise} | 197 * @return {!Promise} |
| 199 */ | 198 */ |
| 200 function assertPageVisibilityAfterSearch( | 199 function assertAdvancedVisibilityAfterSearch(expectedAdvanced) { |
| 201 expectedBasic, expectedAdvanced) { | |
| 202 searchManager.setMatchesFound(true); | 200 searchManager.setMatchesFound(true); |
| 203 return settingsMain.searchContents('Query1').then(function() { | 201 return settingsMain.searchContents('Query1') |
| 204 searchManager.setMatchesFound(false); | 202 .then(function() { |
| 205 return settingsMain.searchContents(''); | 203 searchManager.setMatchesFound(false); |
| 206 }).then(function() { | 204 return settingsMain.searchContents(''); |
| 207 return assertPageVisibility(expectedBasic, expectedAdvanced); | 205 }) |
| 208 }); | 206 .then(function() { |
| 207 // Imitate behavior of clearing search. |
| 208 settings.navigateTo(settings.Route.BASIC); |
| 209 Polymer.dom.flush(); |
| 210 return assertPageVisibility('block', expectedAdvanced); |
| 211 }); |
| 209 } | 212 } |
| 210 | 213 |
| 211 test('exiting search mode, advanced collapsed', function() { | 214 test('exiting search mode, advanced collapsed', function() { |
| 212 // Simulating searching while the advanced page is collapsed. | 215 // Simulating searching while the advanced page is collapsed. |
| 213 settingsMain.currentRouteChanged(settings.Route.BASIC); | 216 settingsMain.currentRouteChanged(settings.Route.BASIC); |
| 214 Polymer.dom.flush(); | 217 Polymer.dom.flush(); |
| 215 return assertPageVisibilityAfterSearch('block', 'none'); | 218 return assertAdvancedVisibilityAfterSearch('none'); |
| 216 }); | 219 }); |
| 217 | 220 |
| 218 // Ensure that clearing the search results restores both "basic" and | 221 // Ensure that clearing the search results restores both "basic" and |
| 219 // "advanced" page, when the search has been initiated from a subpage | 222 // "advanced" page, when the search has been initiated from a subpage |
| 220 // whose parent is the "advanced" page. | 223 // whose parent is the "advanced" page. |
| 221 test('exiting search mode, advanced expanded', function() { | 224 test('exiting search mode, advanced expanded', function() { |
| 222 settings.navigateTo(settings.Route.SITE_SETTINGS); | 225 settings.navigateTo(settings.Route.SITE_SETTINGS); |
| 223 Polymer.dom.flush(); | 226 Polymer.dom.flush(); |
| 224 return assertPageVisibilityAfterSearch('block', 'block'); | 227 return assertAdvancedVisibilityAfterSearch('block'); |
| 225 }); | 228 }); |
| 226 | 229 |
| 227 // Ensure that searching, then entering a subpage, then going back | 230 // Ensure that searching, then entering a subpage, then going back |
| 228 // lands the user in a page where both basic and advanced sections are | 231 // lands the user in a page where both basic and advanced sections are |
| 229 // visible, because the page is still in search mode. | 232 // visible, because the page is still in search mode. |
| 230 test('returning from subpage to search results', function() { | 233 test('returning from subpage to search results', function() { |
| 231 settings.navigateTo(settings.Route.BASIC); | 234 settings.navigateTo(settings.Route.BASIC); |
| 232 Polymer.dom.flush(); | 235 Polymer.dom.flush(); |
| 233 | 236 |
| 234 searchManager.setMatchesFound(true); | 237 searchManager.setMatchesFound(true); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 284 |
| 282 return assertPageVisibility('block', 'block'); | 285 return assertPageVisibility('block', 'block'); |
| 283 }); | 286 }); |
| 284 }); | 287 }); |
| 285 } | 288 } |
| 286 | 289 |
| 287 return { | 290 return { |
| 288 registerTests: registerTests, | 291 registerTests: registerTests, |
| 289 }; | 292 }; |
| 290 }); | 293 }); |
| OLD | NEW |