| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_reset_page', function() { | 5 cr.define('settings_reset_page', function() { |
| 6 /** @enum {string} */ | 6 /** @enum {string} */ |
| 7 var TestNames = { | 7 var TestNames = { |
| 8 PowerwashDialogAction: 'PowerwashDialogAction', | 8 PowerwashDialogAction: 'PowerwashDialogAction', |
| 9 PowerwashDialogOpenClose: 'PowerwashDialogOpenClose', | 9 PowerwashDialogOpenClose: 'PowerwashDialogOpenClose', |
| 10 ResetBannerClose: 'ResetBannerClose', | 10 ResetBannerClose: 'ResetBannerClose', |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 * @param {function(SettingsResetProfileDialogElemeent)} | 142 * @param {function(SettingsResetProfileDialogElemeent)} |
| 143 * closeDialogFn A function to call for closing the dialog. | 143 * closeDialogFn A function to call for closing the dialog. |
| 144 * @return {!Promise} | 144 * @return {!Promise} |
| 145 */ | 145 */ |
| 146 function testOpenCloseResetProfileDialog(closeDialogFn) { | 146 function testOpenCloseResetProfileDialog(closeDialogFn) { |
| 147 resetPageBrowserProxy.resetResolver('onShowResetProfileDialog'); | 147 resetPageBrowserProxy.resetResolver('onShowResetProfileDialog'); |
| 148 resetPageBrowserProxy.resetResolver('onHideResetProfileDialog'); | 148 resetPageBrowserProxy.resetResolver('onHideResetProfileDialog'); |
| 149 | 149 |
| 150 // Open reset profile dialog. | 150 // Open reset profile dialog. |
| 151 MockInteractions.tap(resetPage.$.resetProfile); | 151 MockInteractions.tap(resetPage.$.resetProfile); |
| 152 Polymer.dom.flush(); |
| 152 var dialog = resetPage.$$('settings-reset-profile-dialog'); | 153 var dialog = resetPage.$$('settings-reset-profile-dialog'); |
| 153 assertTrue(!!dialog); | 154 assertTrue(!!dialog); |
| 154 assertTrue(dialog.$.dialog.open); | |
| 155 var onDialogClosed = new Promise( | 155 var onDialogClosed = new Promise( |
| 156 function(resolve, reject) { | 156 function(resolve, reject) { |
| 157 dialog.addEventListener('close', function() { | 157 dialog.addEventListener('close', function() { |
| 158 assertFalse(dialog.$.dialog.open); | 158 assertFalse(dialog.$.dialog.open); |
| 159 resolve(); | 159 resolve(); |
| 160 }); | 160 }); |
| 161 }); | 161 }); |
| 162 | 162 |
| 163 return resetPageBrowserProxy.whenCalled( | 163 return resetPageBrowserProxy.whenCalled( |
| 164 'onShowResetProfileDialog').then(function() { | 164 'onShowResetProfileDialog').then(function() { |
| 165 assertTrue(dialog.$.dialog.open); |
| 165 closeDialogFn(dialog); | 166 closeDialogFn(dialog); |
| 166 return Promise.all([ | 167 return Promise.all([ |
| 167 onDialogClosed, | 168 onDialogClosed, |
| 168 resetPageBrowserProxy.whenCalled('onHideResetProfileDialog'), | 169 resetPageBrowserProxy.whenCalled('onHideResetProfileDialog'), |
| 169 ]); | 170 ]); |
| 170 }); | 171 }); |
| 171 } | 172 } |
| 172 | 173 |
| 173 // Tests that the reset profile dialog opens and closes correctly and that | 174 // Tests that the reset profile dialog opens and closes correctly and that |
| 174 // resetPageBrowserProxy calls are occurring as expected. | 175 // resetPageBrowserProxy calls are occurring as expected. |
| 175 test(TestNames.ResetProfileDialogOpenClose, function() { | 176 test(TestNames.ResetProfileDialogOpenClose, function() { |
| 176 return testOpenCloseResetProfileDialog(function(dialog) { | 177 return testOpenCloseResetProfileDialog(function(dialog) { |
| 177 // Test case where the 'cancel' button is clicked. | 178 // Test case where the 'cancel' button is clicked. |
| 178 MockInteractions.tap(dialog.$.cancel); | 179 MockInteractions.tap(dialog.$.cancel); |
| 179 }).then(function() { | 180 }).then(function() { |
| 180 return testOpenCloseResetProfileDialog(function(dialog) { | 181 return testOpenCloseResetProfileDialog(function(dialog) { |
| 181 // Test case where the 'close' button is clicked. | 182 // Test case where the 'close' button is clicked. |
| 182 MockInteractions.tap(dialog.$.dialog.getCloseButton()); | 183 MockInteractions.tap(dialog.$.dialog.getCloseButton()); |
| 183 }); | 184 }); |
| 184 }); | 185 }); |
| 185 }); | 186 }); |
| 186 | 187 |
| 187 // Tests that when user request to reset the profile the appropriate | 188 // Tests that when user request to reset the profile the appropriate |
| 188 // message is sent to the browser. | 189 // message is sent to the browser. |
| 189 test(TestNames.ResetProfileDialogAction, function() { | 190 test(TestNames.ResetProfileDialogAction, function() { |
| 190 // Open reset profile dialog. | 191 // Open reset profile dialog. |
| 191 MockInteractions.tap(resetPage.$.resetProfile); | 192 MockInteractions.tap(resetPage.$.resetProfile); |
| 193 Polymer.dom.flush(); |
| 192 var dialog = resetPage.$$('settings-reset-profile-dialog'); | 194 var dialog = resetPage.$$('settings-reset-profile-dialog'); |
| 193 assertTrue(!!dialog); | 195 assertTrue(!!dialog); |
| 194 | 196 |
| 195 var showReportedSettingsLink = dialog.$$('.footer a'); | 197 var showReportedSettingsLink = dialog.$$('.footer a'); |
| 196 assertTrue(!!showReportedSettingsLink); | 198 assertTrue(!!showReportedSettingsLink); |
| 197 MockInteractions.tap(showReportedSettingsLink); | 199 MockInteractions.tap(showReportedSettingsLink); |
| 198 | 200 |
| 199 return resetPageBrowserProxy.whenCalled('showReportedSettings').then( | 201 return resetPageBrowserProxy.whenCalled('showReportedSettings').then( |
| 200 function() { | 202 function() { |
| 201 assertFalse(dialog.$.reset.disabled); | 203 assertFalse(dialog.$.reset.disabled); |
| 202 assertFalse(dialog.$.resetSpinner.active); | 204 assertFalse(dialog.$.resetSpinner.active); |
| 203 MockInteractions.tap(dialog.$.reset); | 205 MockInteractions.tap(dialog.$.reset); |
| 204 assertTrue(dialog.$.reset.disabled); | 206 assertTrue(dialog.$.reset.disabled); |
| 207 assertTrue(dialog.$.cancel.disabled); |
| 205 assertTrue(dialog.$.resetSpinner.active); | 208 assertTrue(dialog.$.resetSpinner.active); |
| 206 return resetPageBrowserProxy.whenCalled( | 209 return resetPageBrowserProxy.whenCalled( |
| 207 'performResetProfileSettings'); | 210 'performResetProfileSettings'); |
| 208 }); | 211 }); |
| 209 }); | 212 }); |
| 210 | 213 |
| 211 if (cr.isChromeOS) { | 214 if (cr.isChromeOS) { |
| 212 /** | 215 /** |
| 213 * @param {function(SettingsPowerwashDialogElemeent):!Element} | 216 * @param {function(SettingsPowerwashDialogElemeent):!Element} |
| 214 * closeButtonFn A function that returns the button to be used for | 217 * closeButtonFn A function that returns the button to be used for |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 }); | 266 }); |
| 264 } | 267 } |
| 265 | 268 |
| 266 return { | 269 return { |
| 267 registerTests: function() { | 270 registerTests: function() { |
| 268 registerBannerTests(); | 271 registerBannerTests(); |
| 269 registerDialogTests(); | 272 registerDialogTests(); |
| 270 }, | 273 }, |
| 271 }; | 274 }; |
| 272 }); | 275 }); |
| OLD | NEW |