OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |