| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 settings.ResetBrowserProxyImpl.instance_ = browserProxy; | 79 settings.ResetBrowserProxyImpl.instance_ = browserProxy; |
| 80 PolymerTest.clearBody(); | 80 PolymerTest.clearBody(); |
| 81 resetBanner = document.createElement('settings-reset-profile-banner'); | 81 resetBanner = document.createElement('settings-reset-profile-banner'); |
| 82 document.body.appendChild(resetBanner); | 82 document.body.appendChild(resetBanner); |
| 83 }); | 83 }); |
| 84 | 84 |
| 85 teardown(function() { resetBanner.remove(); }); | 85 teardown(function() { resetBanner.remove(); }); |
| 86 | 86 |
| 87 // Tests that the reset profile banner | 87 // Tests that the reset profile banner |
| 88 // - opens the reset profile dialog when the reset button is clicked. | 88 // - opens the reset profile dialog when the reset button is clicked. |
| 89 // - reset happens when clicking on the dialog's reset button. |
| 89 // - the reset profile dialog is closed after reset is done. | 90 // - the reset profile dialog is closed after reset is done. |
| 90 test(TestNames.ResetBannerReset, function() { | 91 test(TestNames.ResetBannerReset, function() { |
| 91 var dialog = resetBanner.$$('settings-reset-profile-dialog'); | 92 var dialog = resetBanner.$$('settings-reset-profile-dialog'); |
| 92 assertFalse(!!dialog); | 93 assertFalse(!!dialog); |
| 93 MockInteractions.tap(resetBanner.$['reset']); | 94 MockInteractions.tap(resetBanner.$.reset); |
| 94 Polymer.dom.flush(); | 95 Polymer.dom.flush(); |
| 96 assertTrue(resetBanner.showResetProfileDialog_) |
| 95 dialog = resetBanner.$$('settings-reset-profile-dialog'); | 97 dialog = resetBanner.$$('settings-reset-profile-dialog'); |
| 96 assertTrue(!!dialog); | 98 assertTrue(!!dialog); |
| 97 | 99 |
| 98 dialog.fire('reset-done'); | 100 MockInteractions.tap(dialog.$.reset); |
| 99 Polymer.dom.flush(); | 101 |
| 100 assertEquals('none', dialog.style.display); | 102 return browserProxy.whenCalled('performResetProfileSettings') |
| 101 return Promise.resolve(); | 103 .then(flush) |
| 104 .then(function() { |
| 105 assertFalse(resetBanner.showResetProfileDialog_); |
| 106 dialog = resetBanner.$$('settings-reset-profile-dialog'); |
| 107 assertFalse(!!dialog); |
| 108 }); |
| 102 }); | 109 }); |
| 103 | 110 |
| 104 // Tests that the reset profile banner removes itself from the DOM when | 111 // Tests that the reset profile banner removes itself from the DOM when |
| 105 // the close button is clicked and that |onHideResetProfileBanner| is | 112 // the close button is clicked and that |onHideResetProfileBanner| is |
| 106 // called. | 113 // called. |
| 107 test(TestNames.ResetBannerClose, function() { | 114 test(TestNames.ResetBannerClose, function() { |
| 108 MockInteractions.tap(resetBanner.$['close']); | 115 MockInteractions.tap(resetBanner.$.close); |
| 109 assertFalse(!!resetBanner.parentNode); | 116 assertFalse(!!resetBanner.parentNode); |
| 110 return browserProxy.whenCalled('onHideResetProfileBanner'); | 117 return browserProxy.whenCalled('onHideResetProfileBanner'); |
| 111 }); | 118 }); |
| 112 }); | 119 }); |
| 113 } | 120 } |
| 114 | 121 |
| 115 function registerDialogTests() { | 122 function registerDialogTests() { |
| 116 suite('DialogTests', function() { | 123 suite('DialogTests', function() { |
| 117 var resetPage = null; | 124 var resetPage = null; |
| 118 | 125 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 ]); | 177 ]); |
| 171 }); | 178 }); |
| 172 } | 179 } |
| 173 | 180 |
| 174 // Tests that the reset profile dialog opens and closes correctly and that | 181 // Tests that the reset profile dialog opens and closes correctly and that |
| 175 // resetPageBrowserProxy calls are occurring as expected. | 182 // resetPageBrowserProxy calls are occurring as expected. |
| 176 test(TestNames.ResetProfileDialogOpenClose, function() { | 183 test(TestNames.ResetProfileDialogOpenClose, function() { |
| 177 return testOpenCloseResetProfileDialog(function(dialog) { | 184 return testOpenCloseResetProfileDialog(function(dialog) { |
| 178 // Test case where the 'cancel' button is clicked. | 185 // Test case where the 'cancel' button is clicked. |
| 179 MockInteractions.tap(dialog.$.cancel); | 186 MockInteractions.tap(dialog.$.cancel); |
| 180 }).then(function() { | 187 }).then(flush).then(function() { |
| 181 return testOpenCloseResetProfileDialog(function(dialog) { | 188 return testOpenCloseResetProfileDialog(function(dialog) { |
| 182 // Test case where the 'close' button is clicked. | 189 // Test case where the 'close' button is clicked. |
| 183 MockInteractions.tap(dialog.$.dialog.getCloseButton()); | 190 MockInteractions.tap(dialog.$.dialog.getCloseButton()); |
| 184 }); | 191 }); |
| 185 }); | 192 }); |
| 186 }); | 193 }); |
| 187 | 194 |
| 188 // Tests that when user request to reset the profile the appropriate | 195 // Tests that when user request to reset the profile the appropriate |
| 189 // message is sent to the browser. | 196 // message is sent to the browser. |
| 190 test(TestNames.ResetProfileDialogAction, function() { | 197 test(TestNames.ResetProfileDialogAction, function() { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 }); | 276 }); |
| 270 } | 277 } |
| 271 | 278 |
| 272 return { | 279 return { |
| 273 registerTests: function() { | 280 registerTests: function() { |
| 274 registerBannerTests(); | 281 registerBannerTests(); |
| 275 registerDialogTests(); | 282 registerDialogTests(); |
| 276 }, | 283 }, |
| 277 }; | 284 }; |
| 278 }); | 285 }); |
| OLD | NEW |