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

Unified Diff: chrome/test/data/webui/md_bookmarks/test_store.js

Issue 2902103002: MD Bookmarks: Disable 'Open in Incognito Window' when Incognito is disabled (Closed)
Patch Set: Review comment Created 3 years, 7 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/md_bookmarks/policy_test.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/md_bookmarks/test_store.js
diff --git a/chrome/test/data/webui/md_bookmarks/test_store.js b/chrome/test/data/webui/md_bookmarks/test_store.js
index 10fab150dd8ad5be18aa6e94106125c4a714deb4..cdf2571c9ac8bb4ab4b1fe062cc0251b01c27c22 100644
--- a/chrome/test/data/webui/md_bookmarks/test_store.js
+++ b/chrome/test/data/webui/md_bookmarks/test_store.js
@@ -12,6 +12,8 @@ suiteSetup(function() {
this.lastAction_ = null;
this.acceptInit_ = false;
this.enableReducers_ = false;
+ /** @type {!Map<string, !PromiseResolver>} */
+ this.resolverMap_ = new Map();
};
TestStore.prototype = {
@@ -54,6 +56,8 @@ suiteSetup(function() {
this.lastAction_ = action;
if (this.enableReducers_)
bookmarks.Store.prototype.reduce_.call(this, action);
+ if (this.resolverMap_.has(action.name))
+ this.resolverMap_.get(action.name).resolve(action);
},
/**
@@ -71,6 +75,32 @@ suiteSetup(function() {
this.acceptInit_ = true;
this.initialized_ = false;
},
+
+ /**
+ * Track actions called |name|, allowing that type of action to be waited
+ * for with `waitForAction`.
+ * @param {string} name
+ */
+ expectAction: function(name) {
+ this.resolverMap_.set(name, new PromiseResolver());
+ },
+
+ /**
+ * Returns a Promise that will resolve when an action called |name| is
+ * dispatched. The promise must be prepared by calling
+ * `expectAction(name)` before the action is dispatched.
+ * @param {string} name
+ * @return {!Promise<!Action>}
+ */
+ waitForAction: function(name) {
+ assertTrue(
+ this.resolverMap_.has(name),
+ 'Must call expectAction before each call to waitForAction');
+ return this.resolverMap_.get(name).promise.then((action) => {
+ this.resolverMap_.delete(name);
+ return action;
+ });
+ },
};
return {
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/policy_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698