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

Unified Diff: chrome/test/data/webui/settings/privacy_page_test.js

Issue 1902873003: MD Settings: Display spinner and disable buttons while clearing browsing data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed typo Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/settings/privacy_page_test.js
diff --git a/chrome/test/data/webui/settings/privacy_page_test.js b/chrome/test/data/webui/settings/privacy_page_test.js
index 120096ceea5cd62747cc85158de6dbd073ddbedf..e7474b77b9831fb0a100e17b4044d2779e961b9a 100644
--- a/chrome/test/data/webui/settings/privacy_page_test.js
+++ b/chrome/test/data/webui/settings/privacy_page_test.js
@@ -28,15 +28,29 @@ cr.define('settings_privacy_page', function() {
*/
function TestClearBrowsingDataBrowserProxy() {
settings.TestBrowserProxy.call(this, ['clearBrowsingData']);
+
+ /**
+ * The promise to return from |clearBrowsingData|.
+ * Allows testing code to test what happens after the call is made, and
+ * before the browser responds.
+ * @private {?Promise}
+ */
+ this.clearBrowsingDataPromise_ = null;
}
TestClearBrowsingDataBrowserProxy.prototype = {
__proto__: settings.TestBrowserProxy.prototype,
+ /** @param {!Promise} promise */
+ setClearBrowsingDataPromise: function(promise) {
+ this.clearBrowsingDataPromise_ = promise;
+ },
+
/** @override */
clearBrowsingData: function() {
this.methodCalled('clearBrowsingData');
- return Promise.resolve();
+ return this.clearBrowsingDataPromise_ !== null ?
+ this.clearBrowsingDataPromise_ : Promise.resolve();
},
};
@@ -86,13 +100,40 @@ cr.define('settings_privacy_page', function() {
test('ClearBrowsingDataTap', function() {
element.open();
assertTrue(element.$.dialog.opened);
- var clearBrowsingDataButton = element.$.clearBrowsingData;
- assertTrue(!!clearBrowsingDataButton);
- MockInteractions.tap(clearBrowsingDataButton);
+ var cancelButton = element.$$('.cancel-button');
+ assertTrue(!!cancelButton);
+ var actionButton = element.$$('.action-button');
+ assertTrue(!!actionButton);
+ var spinner = element.$$('paper-spinner');
+ assertTrue(!!spinner);
+
+ assertFalse(cancelButton.disabled);
+ assertFalse(actionButton.disabled);
+ assertFalse(spinner.active);
+
+ var promiseResolver = new PromiseResolver();
+ testBrowserProxy.setClearBrowsingDataPromise(promiseResolver.promise);
+ MockInteractions.tap(actionButton);
+
return testBrowserProxy.whenCalled('clearBrowsingData').then(
function() {
+ assertTrue(element.$.dialog.opened);
+ assertTrue(cancelButton.disabled);
+ assertTrue(actionButton.disabled);
+ assertTrue(spinner.active);
+
+ // Simulate signal from browser indicating that clearing has
+ // completed.
+ promiseResolver.resolve();
+ // Yields to the message loop to allow the callback chain of the
+ // Promise that was just resolved to execute before the
+ // assertions.
+ }).then(function() {
assertFalse(element.$.dialog.opened);
+ assertFalse(cancelButton.disabled);
+ assertFalse(actionButton.disabled);
+ assertFalse(spinner.active);
});
});
});
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698