Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: chrome/test/data/webui/settings/reset_page_test.js

Issue 2375223002: md-settings: Fix back navigation from /resetProfileSettings. (Closed)
Patch Set: Fix failing test. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/data/webui/polymer_browser_test_base.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(PolymerTest.flushTasks)
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 var dialog = resetPage.$$('settings-reset-profile-dialog'); 160 var dialog = resetPage.$$('settings-reset-profile-dialog');
154 assertTrue(!!dialog); 161 assertTrue(!!dialog);
155 var onDialogClosed = new Promise( 162 var onDialogClosed = new Promise(
156 function(resolve, reject) { 163 function(resolve, reject) {
157 dialog.addEventListener('close', function() { 164 dialog.addEventListener('close', function() {
158 assertFalse(dialog.$.dialog.open); 165 assertFalse(dialog.$.dialog.open);
159 resolve(); 166 resolve();
160 }); 167 });
161 }); 168 });
162 169
163 return resetPageBrowserProxy.whenCalled( 170 return PolymerTest.flushTasks().then(function() {
164 'onShowResetProfileDialog').then(function() { 171 resetPageBrowserProxy.whenCalled('onShowResetProfileDialog')
165 assertTrue(dialog.$.dialog.open); 172 .then(function() {
166 closeDialogFn(dialog); 173 assertTrue(dialog.$.dialog.open);
167 return Promise.all([ 174 closeDialogFn(dialog);
168 onDialogClosed, 175 return Promise.all([
169 resetPageBrowserProxy.whenCalled('onHideResetProfileDialog'), 176 onDialogClosed,
170 ]); 177 resetPageBrowserProxy.whenCalled('onHideResetProfileDialog'),
178 ]);
179 });
171 }); 180 });
172 } 181 }
173 182
174 // Tests that the reset profile dialog opens and closes correctly and that 183 // Tests that the reset profile dialog opens and closes correctly and that
175 // resetPageBrowserProxy calls are occurring as expected. 184 // resetPageBrowserProxy calls are occurring as expected.
176 test(TestNames.ResetProfileDialogOpenClose, function() { 185 test(TestNames.ResetProfileDialogOpenClose, function() {
177 return testOpenCloseResetProfileDialog(function(dialog) { 186 return testOpenCloseResetProfileDialog(function(dialog) {
178 // Test case where the 'cancel' button is clicked. 187 // Test case where the 'cancel' button is clicked.
179 MockInteractions.tap(dialog.$.cancel); 188 MockInteractions.tap(dialog.$.cancel);
180 }).then(function() { 189 }).then(PolymerTest.flushTasks).then(function() {
181 return testOpenCloseResetProfileDialog(function(dialog) { 190 return testOpenCloseResetProfileDialog(function(dialog) {
182 // Test case where the 'close' button is clicked. 191 // Test case where the 'close' button is clicked.
183 MockInteractions.tap(dialog.$.dialog.getCloseButton()); 192 MockInteractions.tap(dialog.$.dialog.getCloseButton());
184 }); 193 });
185 }); 194 });
186 }); 195 });
187 196
188 // Tests that when user request to reset the profile the appropriate 197 // Tests that when user request to reset the profile the appropriate
189 // message is sent to the browser. 198 // message is sent to the browser.
190 test(TestNames.ResetProfileDialogAction, function() { 199 test(TestNames.ResetProfileDialogAction, function() {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 }); 278 });
270 } 279 }
271 280
272 return { 281 return {
273 registerTests: function() { 282 registerTests: function() {
274 registerBannerTests(); 283 registerBannerTests();
275 registerDialogTests(); 284 registerDialogTests();
276 }, 285 },
277 }; 286 };
278 }); 287 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/polymer_browser_test_base.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698