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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Common test utilities. 5 // Common test utilities.
6 6
7 /** 7 /**
8 * Allows console.log output. 8 * Allows console.log output.
9 */ 9 */
10 var showConsoleLogOutput = false; 10 var showConsoleLogOutput = false;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 }); 122 });
123 } else { 123 } else {
124 results[i] = arrayOfPromises[i]; 124 results[i] = arrayOfPromises[i];
125 } 125 }
126 } 126 }
127 var promise = new PromisePrototypeObject(function(resolve) { 127 var promise = new PromisePrototypeObject(function(resolve) {
128 resolve(results); 128 resolve(results);
129 }); 129 });
130 return promise; 130 return promise;
131 } 131 }
132
133 function resolve(value) {
134 var promise = new PromisePrototypeObject(function(resolve) {
135 resolve(value);
136 });
137 return promise;
138 }
139
132 PromisePrototypeObject.all = all; 140 PromisePrototypeObject.all = all;
141 PromisePrototypeObject.resolve = resolve;
133 return PromisePrototypeObject; 142 return PromisePrototypeObject;
134 }(); 143 }();
144
145
146 /**
147 * Sets up the test to expect a Chrome Local Storage call.
148 * @param {Object} fixture Mock JS Test Object.
149 * @param {Object} defaultObject Storage request default object.
150 * @param {Object} result Storage result.
151 * @param {boolean=} opt_AllowRejection Allow Promise Rejection
152 */
153 function expectChromeLocalStorageGet(
154 fixture, defaultObject, result, opt_AllowRejection) {
155 if (opt_AllowRejection === undefined) {
156 fixture.mockApis.expects(once()).
157 fillFromChromeLocalStorage(eqJSON(defaultObject)).
158 will(returnValue(Promise.resolve(result)));
159 } else {
160 fixture.mockApis.expects(once()).
161 fillFromChromeLocalStorage(eqJSON(defaultObject), opt_AllowRejection).
162 will(returnValue(Promise.resolve(result)));
163 }
164 }
OLDNEW
« 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