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

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: Rebase to r252941 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..864492a08ca9becdf2c0c3e4ee54fb5eafeb307f 100644
--- a/chrome/browser/resources/google_now/common_test_util.js
+++ b/chrome/browser/resources/google_now/common_test_util.js
@@ -129,6 +129,28 @@ 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.
+ */
+function expectChromeLocalStorageGet(fixture, defaultObject, result) {
+ fixture.mockApis.expects(once()).
+ fillFromChromeLocalStorage(eqJSON(defaultObject)).
+ will(returnValue(Promise.resolve(result)));
+}

Powered by Google App Engine
This is Rietveld 408576698