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

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

Issue 1758973002: MD Settings: Creating a <settings-dialog> element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra blank line Created 4 years, 9 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
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 }); 86 });
87 87
88 setup(function() { 88 setup(function() {
89 PolymerTest.clearBody(); 89 PolymerTest.clearBody();
90 resetPage = document.createElement('settings-reset-page'); 90 resetPage = document.createElement('settings-reset-page');
91 document.body.appendChild(resetPage); 91 document.body.appendChild(resetPage);
92 }); 92 });
93 93
94 94
95 /** 95 /**
96 * @param {string} closeButtonId The ID of the button that closes the 96 * @param {function(SettingsResetProfileDialogElemeent):!Element}
97 * dialog. 97 * closeButtonFn A function that returns the button to be used for
98 * closing the dialog.
98 * @return {!Promise} 99 * @return {!Promise}
99 */ 100 */
100 function testOpenCloseResetProfileDialog(closeButtonId) { 101 function testOpenCloseResetProfileDialog(closeButtonFn) {
101 var onShowResetProfileDialogCalled = whenChromeSendCalled( 102 var onShowResetProfileDialogCalled = whenChromeSendCalled(
102 'onShowResetProfileDialog'); 103 'onShowResetProfileDialog');
103 var onHideResetProfileDialogCalled = whenChromeSendCalled( 104 var onHideResetProfileDialogCalled = whenChromeSendCalled(
104 'onHideResetProfileDialog'); 105 'onHideResetProfileDialog');
105 106
106 // Open reset profile dialog. 107 // Open reset profile dialog.
107 MockInteractions.tap(resetPage.$.resetProfile); 108 MockInteractions.tap(resetPage.$.resetProfile);
108 var dialog = resetPage.$$('settings-reset-profile-dialog'); 109 var dialog = resetPage.$$('settings-reset-profile-dialog');
109 var onDialogClosed = new Promise( 110 var onDialogClosed = new Promise(
110 function(resolve, reject) { 111 function(resolve, reject) {
111 dialog.addEventListener('iron-overlay-closed', resolve); 112 dialog.addEventListener('iron-overlay-closed', resolve);
112 }); 113 });
113 114
114 MockInteractions.tap(dialog.$[closeButtonId]); 115 MockInteractions.tap(closeButtonFn(dialog));
115 116
116 return Promise.all([ 117 return Promise.all([
117 onShowResetProfileDialogCalled, 118 onShowResetProfileDialogCalled,
118 onHideResetProfileDialogCalled, 119 onHideResetProfileDialogCalled,
119 onDialogClosed 120 onDialogClosed
120 ]); 121 ]);
121 } 122 }
122 123
123 // Tests that the reset profile dialog opens and closes correctly and that 124 // Tests that the reset profile dialog opens and closes correctly and that
124 // chrome.send calls are propagated as expected. 125 // chrome.send calls are propagated as expected.
125 test(TestNames.ResetProfileDialogOpenClose, function() { 126 test(TestNames.ResetProfileDialogOpenClose, function() {
126 return Promise.all([ 127 return Promise.all([
127 // Test case where the 'cancel' button is clicked. 128 // Test case where the 'cancel' button is clicked.
128 testOpenCloseResetProfileDialog('cancel'), 129 testOpenCloseResetProfileDialog(
130 function(dialog) { return dialog.$.cancel;}),
129 // Test case where the 'close' button is clicked. 131 // Test case where the 'close' button is clicked.
130 testOpenCloseResetProfileDialog('close') 132 testOpenCloseResetProfileDialog(
133 function(dialog) { return dialog.$.dialog.getCloseButton(); }),
131 ]); 134 ]);
132 }); 135 });
133 136
134 // Tests that when resetting the profile is requested chrome.send calls 137 // Tests that when resetting the profile is requested chrome.send calls
135 // are propagated as expected. 138 // are propagated as expected.
136 test(TestNames.ResetProfileDialogAction, function() { 139 test(TestNames.ResetProfileDialogAction, function() {
137 // Open reset profile dialog. 140 // Open reset profile dialog.
138 MockInteractions.tap(resetPage.$.resetProfile); 141 MockInteractions.tap(resetPage.$.resetProfile);
139 var dialog = resetPage.$$('settings-reset-profile-dialog'); 142 var dialog = resetPage.$$('settings-reset-profile-dialog');
140 var promise = whenChromeSendCalled('performResetProfileSettings'); 143 var promise = whenChromeSendCalled('performResetProfileSettings');
141 MockInteractions.tap(dialog.$.reset); 144 MockInteractions.tap(dialog.$.reset);
142 return promise; 145 return promise;
143 }); 146 });
144 147
145 if (cr.isChromeOS) { 148 if (cr.isChromeOS) {
146 /** 149 /**
147 * @param {string} closeButtonId The ID of the button that closes the 150 * @param {function(SettingsPowerwashDialogElemeent):!Element}
148 * dialog. 151 * closeButtonFn A function that returns the button to be used for
152 * closing the dialog.
149 * @return {!Promise} 153 * @return {!Promise}
150 */ 154 */
151 function testOpenClosePowerwashDialog(closeButtonId) { 155 function testOpenClosePowerwashDialog(closeButtonFn) {
152 var onPowerwashDialogShowCalled = whenChromeSendCalled( 156 var onPowerwashDialogShowCalled = whenChromeSendCalled(
153 'onPowerwashDialogShow'); 157 'onPowerwashDialogShow');
154 158
155 // Open powerwash dialog. 159 // Open powerwash dialog.
156 MockInteractions.tap(resetPage.$.powerwash); 160 MockInteractions.tap(resetPage.$.powerwash);
157 var dialog = resetPage.$$('settings-powerwash-dialog'); 161 var dialog = resetPage.$$('settings-powerwash-dialog');
158 var onDialogClosed = new Promise( 162 var onDialogClosed = new Promise(
159 function(resolve, reject) { 163 function(resolve, reject) {
160 dialog.addEventListener('iron-overlay-closed', resolve); 164 dialog.addEventListener('iron-overlay-closed', resolve);
161 }); 165 });
162 166
163 MockInteractions.tap(dialog.$[closeButtonId]); 167 MockInteractions.tap(closeButtonFn(dialog));
164 return Promise.all([onPowerwashDialogShowCalled, onDialogClosed]); 168 return Promise.all([onPowerwashDialogShowCalled, onDialogClosed]);
165 } 169 }
166 170
167 // Tests that the powerwash dialog opens and closes correctly, and 171 // Tests that the powerwash dialog opens and closes correctly, and
168 // that chrome.send calls are propagated as expected. 172 // that chrome.send calls are propagated as expected.
169 test(TestNames.PowerwashDialogOpenClose, function() { 173 test(TestNames.PowerwashDialogOpenClose, function() {
170 return Promise.all([ 174 return Promise.all([
171 // Test case where the 'cancel' button is clicked. 175 // Test case where the 'cancel' button is clicked.
172 testOpenClosePowerwashDialog('cancel'), 176 testOpenClosePowerwashDialog(
177 function(dialog) { return dialog.$.cancel; }),
173 // Test case where the 'close' button is clicked. 178 // Test case where the 'close' button is clicked.
174 testOpenClosePowerwashDialog('close') 179 testOpenClosePowerwashDialog(
180 function(dialog) { return dialog.$.dialog.getCloseButton(); }),
175 ]); 181 ]);
176 }); 182 });
177 183
178 // Tests that when powerwash is requested chrome.send calls are 184 // Tests that when powerwash is requested chrome.send calls are
179 // propagated as expected. 185 // propagated as expected.
180 test(TestNames.PowerwashDialogAction, function() { 186 test(TestNames.PowerwashDialogAction, function() {
181 // Open powerwash dialog. 187 // Open powerwash dialog.
182 MockInteractions.tap(resetPage.$.powerwash); 188 MockInteractions.tap(resetPage.$.powerwash);
183 var dialog = resetPage.$$('settings-powerwash-dialog'); 189 var dialog = resetPage.$$('settings-powerwash-dialog');
184 var promise = whenChromeSendCalled('requestFactoryResetRestart'); 190 var promise = whenChromeSendCalled('requestFactoryResetRestart');
185 MockInteractions.tap(dialog.$.powerwash); 191 MockInteractions.tap(dialog.$.powerwash);
186 return promise; 192 return promise;
187 }); 193 });
188 } 194 }
189 }); 195 });
190 } 196 }
191 197
192 return { 198 return {
193 registerBannerTests: registerBannerTests, 199 registerBannerTests: registerBannerTests,
194 registerDialogTests: registerDialogTests 200 registerDialogTests: registerDialogTests
195 }; 201 };
196 }); 202 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/settings_resources.grd ('k') | chrome/test/data/webui/settings/search_engines_page_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698