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

Unified Diff: chrome/browser/resources/google_now/common_test_util.js

Issue 166033010: Convert Google Now's use of chrome.local.storage.get to use Promises (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR Feedback Created 6 years, 10 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/browser/resources/google_now/common_test_util.js
diff --git a/chrome/browser/resources/google_now/common_test_util.js b/chrome/browser/resources/google_now/common_test_util.js
index 44d21e6d1f640ea07406a7919738959bcbb09706..66d65f49d9efa9d3f0f77aa6db76165f119cf9c1 100644
--- a/chrome/browser/resources/google_now/common_test_util.js
+++ b/chrome/browser/resources/google_now/common_test_util.js
@@ -129,6 +129,36 @@ var Promise = function() {
});
return promise;
}
+
+ function resolve(value) {
+ var promise = new PromisePrototypeObject(function(resolve) {
+ resolve(value);
+ });
+ return promise;
+ }
+
PromisePrototypeObject.all = all;
+ PromisePrototypeObject.resolve = resolve;
return PromisePrototypeObject;
}();
+
+
+/**
+ * Sets up the test to expect a Chrome Local Storage call.
+ * @param {Object} fixture Mock JS Test Object.
+ * @param {Object} defaultObject Storage request default object.
+ * @param {Object} result Storage result.
+ * @param {boolean=} opt_AllowRejection Allow Promise Rejection
+ */
+function expectChromeLocalStorageGet(
+ fixture, defaultObject, result, opt_AllowRejection) {
+ if (opt_AllowRejection === undefined) {
+ fixture.mockApis.expects(once()).
+ fillFromChromeLocalStorage(eqJSON(defaultObject)).
+ will(returnValue(Promise.resolve(result)));
+ } else {
+ fixture.mockApis.expects(once()).
+ fillFromChromeLocalStorage(eqJSON(defaultObject), opt_AllowRejection).
+ will(returnValue(Promise.resolve(result)));
+ }
+}
« no previous file with comments | « chrome/browser/resources/google_now/cards_unittest.gtestjs ('k') | chrome/browser/resources/google_now/utility.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698