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

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: Add a test 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
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..44b6573a8dec3a14b0455aaa9606fa7df77b9ba9 100644
--- a/chrome/test/data/webui/md_bookmarks/test_store.js
+++ b/chrome/test/data/webui/md_bookmarks/test_store.js
@@ -12,6 +12,7 @@ suiteSetup(function() {
this.lastAction_ = null;
this.acceptInit_ = false;
this.enableReducers_ = false;
+ this.resolverMap_ = new Map();
calamity 2017/05/29 06:52:28 Type annotation?
tsergeant 2017/05/30 00:18:21 Done.
};
TestStore.prototype = {
@@ -54,6 +55,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 +74,27 @@ 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. Specifically, it will resolve the first time the action is
+ * seen after `expectAction` is called with that name. To reset the
+ * promise after that, call `expectAction` again.
calamity 2017/05/29 06:52:28 Seems a bit risky to have subsequent calls to wait
tsergeant 2017/05/30 00:18:21 Doing it this way is necessary to support the foll
calamity 2017/06/01 04:07:44 Can you work around the synchronicity issue? (e.g
tsergeant 2017/06/01 05:27:16 Interesting idea to queue up resetting the promise
+ * @param {string} name
+ * @return {!Promise<!Action>}
+ */
+ waitForAction: function(name) {
+ return this.resolverMap_.get(name).promise;
+ },
};
return {

Powered by Google App Engine
This is Rietveld 408576698