| 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 * @implements {SearchManager} | 7 * @implements {SearchManager} |
| 8 */ | 8 */ |
| 9 var TestSearchManager = function() { | 9 var TestSearchManager = function() { |
| 10 /** @private {boolean} */ | 10 /** @private {boolean} */ |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 searchManager.setMatchesFound(false); | 99 searchManager.setMatchesFound(false); |
| 100 // Clearing the search box is effectively a search for the empty string. | 100 // Clearing the search box is effectively a search for the empty string. |
| 101 return settingsMain.searchContents('').then(function() { | 101 return settingsMain.searchContents('').then(function() { |
| 102 Polymer.dom.flush(); | 102 Polymer.dom.flush(); |
| 103 assertTrue(noSearchResults.hidden); | 103 assertTrue(noSearchResults.hidden); |
| 104 assertNotEquals('none', toggleContainer.style.display); | 104 assertNotEquals('none', toggleContainer.style.display); |
| 105 }); | 105 }); |
| 106 }); | 106 }); |
| 107 | 107 |
| 108 test('advanced page restored after search results cleared', function() { | 108 /** |
| 109 // Simulating searching while the advanced page is collapsed. | 109 * Asserts the visibility of the basic and advanced pages after exiting |
| 110 settingsMain.currentRouteChanged(settings.Route.BASIC); | 110 * search mode. |
| 111 Polymer.dom.flush(); | 111 * @param {string} Expected 'display' value for the basic page. |
| 112 | 112 * @param {string} Expected 'display' value for the advanced page. |
| 113 assertFalse(!!settingsMain.$$('settings-advanced-page')); | 113 * @return {!Promise} |
| 114 | 114 */ |
| 115 function assertPageVisibilityAfterSearch( |
| 116 expectedBasic, expectedAdvanced) { |
| 115 searchManager.setMatchesFound(true); | 117 searchManager.setMatchesFound(true); |
| 116 return settingsMain.searchContents('Query1').then(function() { | 118 return settingsMain.searchContents('Query1').then(function() { |
| 117 searchManager.setMatchesFound(false); | 119 searchManager.setMatchesFound(false); |
| 118 return settingsMain.searchContents(''); | 120 return settingsMain.searchContents(''); |
| 119 }).then(function() { | 121 }).then(function() { |
| 120 Polymer.dom.flush(); | 122 Polymer.dom.flush(); |
| 121 // Checking that it remains hidden after results are cleared. | |
| 122 assertEquals( | 123 assertEquals( |
| 123 'none', settingsMain.$$('settings-advanced-page').style.display); | 124 expectedBasic, |
| 125 settingsMain.$$('settings-basic-page').style.display); |
| 126 assertEquals( |
| 127 expectedAdvanced, |
| 128 settingsMain.$$('settings-advanced-page').style.display); |
| 124 }); | 129 }); |
| 130 } |
| 131 |
| 132 test('exiting search mode, advanced collapsed', function() { |
| 133 // Simulating searching while the advanced page is collapsed. |
| 134 settingsMain.currentRouteChanged(settings.Route.BASIC); |
| 135 Polymer.dom.flush(); |
| 136 return assertPageVisibilityAfterSearch('', 'none'); |
| 137 }); |
| 138 |
| 139 // Ensure that clearing the search results restores both "basic" and |
| 140 // "advanced" page, when the search has been initiated from a subpage |
| 141 // whose parent is the "advanced" page. |
| 142 test('exiting search mode, advanced expanded', function() { |
| 143 settings.navigateTo(settings.Route.SITE_SETTINGS); |
| 144 Polymer.dom.flush(); |
| 145 return assertPageVisibilityAfterSearch('', ''); |
| 125 }); | 146 }); |
| 126 | 147 |
| 127 test('can collapse advanced on advanced section route', function() { | 148 test('can collapse advanced on advanced section route', function() { |
| 128 settings.navigateTo(settings.Route.PRIVACY); | 149 settings.navigateTo(settings.Route.PRIVACY); |
| 129 Polymer.dom.flush(); | 150 Polymer.dom.flush(); |
| 130 | 151 |
| 131 var advancedToggle = settingsMain.$$('#advancedToggle'); | 152 var advancedToggle = settingsMain.$$('#advancedToggle'); |
| 132 assertTrue(!!advancedToggle); | 153 assertTrue(!!advancedToggle); |
| 133 | 154 |
| 134 MockInteractions.tap(advancedToggle); | 155 MockInteractions.tap(advancedToggle); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 149 | 170 |
| 150 assertTrue(settingsMain.showPages_.advanced); | 171 assertTrue(settingsMain.showPages_.advanced); |
| 151 }); | 172 }); |
| 152 }); | 173 }); |
| 153 } | 174 } |
| 154 | 175 |
| 155 return { | 176 return { |
| 156 registerTests: registerTests, | 177 registerTests: registerTests, |
| 157 }; | 178 }; |
| 158 }); | 179 }); |
| OLD | NEW |