Chromium Code Reviews| 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']); |
|
tommycli
2016/10/03 20:47:46
nit: the dialog.$['foo'] pattern seems odd. Any re
alito
2016/10/03 23:27:17
No particular reason. I was just following the sam
| |
| 99 Polymer.dom.flush(); | 101 flush().then(function() { |
|
tommycli
2016/10/03 20:47:46
I wonder if this the then() may be skipped in some
alito
2016/10/03 23:27:17
I think your suggestion seems safer so I've change
| |
| 100 assertEquals('none', dialog.style.display); | 102 assertFalse(resetBanner.showResetProfileDialog_); |
| 101 return Promise.resolve(); | 103 dialog = resetBanner.$$('settings-reset-profile-dialog'); |
| 104 assertFalse(!!dialog); | |
| 105 }); | |
| 106 | |
| 107 return browserProxy.whenCalled('performResetProfileSettings'); | |
| 102 }); | 108 }); |
| 103 | 109 |
| 104 // Tests that the reset profile banner removes itself from the DOM when | 110 // Tests that the reset profile banner removes itself from the DOM when |
| 105 // the close button is clicked and that |onHideResetProfileBanner| is | 111 // the close button is clicked and that |onHideResetProfileBanner| is |
| 106 // called. | 112 // called. |
| 107 test(TestNames.ResetBannerClose, function() { | 113 test(TestNames.ResetBannerClose, function() { |
| 108 MockInteractions.tap(resetBanner.$['close']); | 114 MockInteractions.tap(resetBanner.$['close']); |
| 109 assertFalse(!!resetBanner.parentNode); | 115 assertFalse(!!resetBanner.parentNode); |
| 110 return browserProxy.whenCalled('onHideResetProfileBanner'); | 116 return browserProxy.whenCalled('onHideResetProfileBanner'); |
| 111 }); | 117 }); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 }); | 177 }); |
| 172 } | 178 } |
| 173 | 179 |
| 174 // Tests that the reset profile dialog opens and closes correctly and that | 180 // Tests that the reset profile dialog opens and closes correctly and that |
| 175 // resetPageBrowserProxy calls are occurring as expected. | 181 // resetPageBrowserProxy calls are occurring as expected. |
| 176 test(TestNames.ResetProfileDialogOpenClose, function() { | 182 test(TestNames.ResetProfileDialogOpenClose, function() { |
| 177 return testOpenCloseResetProfileDialog(function(dialog) { | 183 return testOpenCloseResetProfileDialog(function(dialog) { |
| 178 // Test case where the 'cancel' button is clicked. | 184 // Test case where the 'cancel' button is clicked. |
| 179 MockInteractions.tap(dialog.$.cancel); | 185 MockInteractions.tap(dialog.$.cancel); |
| 180 }).then(function() { | 186 }).then(function() { |
| 181 return testOpenCloseResetProfileDialog(function(dialog) { | 187 return flush().then(function() { |
|
tommycli
2016/10/03 20:47:46
nit: i think we can linearize the promise chain li
alito
2016/10/03 23:27:17
Done.
| |
| 182 // Test case where the 'close' button is clicked. | 188 return testOpenCloseResetProfileDialog(function(dialog) { |
| 183 MockInteractions.tap(dialog.$.dialog.getCloseButton()); | 189 // Test case where the 'close' button is clicked. |
| 190 MockInteractions.tap(dialog.$.dialog.getCloseButton()); | |
| 191 }); | |
| 184 }); | 192 }); |
| 185 }); | 193 }); |
| 186 }); | 194 }); |
| 187 | 195 |
| 188 // Tests that when user request to reset the profile the appropriate | 196 // Tests that when user request to reset the profile the appropriate |
| 189 // message is sent to the browser. | 197 // message is sent to the browser. |
| 190 test(TestNames.ResetProfileDialogAction, function() { | 198 test(TestNames.ResetProfileDialogAction, function() { |
| 191 // Open reset profile dialog. | 199 // Open reset profile dialog. |
| 192 MockInteractions.tap(resetPage.$.resetProfile); | 200 MockInteractions.tap(resetPage.$.resetProfile); |
| 193 Polymer.dom.flush(); | 201 Polymer.dom.flush(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 }); | 277 }); |
| 270 } | 278 } |
| 271 | 279 |
| 272 return { | 280 return { |
| 273 registerTests: function() { | 281 registerTests: function() { |
| 274 registerBannerTests(); | 282 registerBannerTests(); |
| 275 registerDialogTests(); | 283 registerDialogTests(); |
| 276 }, | 284 }, |
| 277 }; | 285 }; |
| 278 }); | 286 }); |
| OLD | NEW |