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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 addListener: function(callback) { | 53 addListener: function(callback) { |
54 mockEventContainer[eventName].push(callback); | 54 mockEventContainer[eventName].push(callback); |
55 } | 55 } |
56 }; | 56 }; |
57 } | 57 } |
58 | 58 |
59 /** | 59 /** |
60 * Gets the array of event handlers added by a mocked 'addListener' function. | 60 * Gets the array of event handlers added by a mocked 'addListener' function. |
61 * @param {string} eventIdentifier Event identifier, such as | 61 * @param {string} eventIdentifier Event identifier, such as |
62 * 'runtime.onSuspend'. | 62 * 'runtime.onSuspend'. |
63 * @return {Array.<Function>} Array of handlers. | 63 * @return {Array<Function>} Array of handlers. |
64 */ | 64 */ |
65 function getMockHandlerContainer(eventIdentifier) { | 65 function getMockHandlerContainer(eventIdentifier) { |
66 var eventIdentifierParts = eventIdentifier.split('.'); | 66 var eventIdentifierParts = eventIdentifier.split('.'); |
67 var mockEventContainer = mockEventHandlers; | 67 var mockEventContainer = mockEventHandlers; |
68 eventIdentifierParts.forEach(function(fragment) { | 68 eventIdentifierParts.forEach(function(fragment) { |
69 mockEventContainer = mockEventContainer[fragment]; | 69 mockEventContainer = mockEventContainer[fragment]; |
70 }); | 70 }); |
71 | 71 |
72 return mockEventContainer; | 72 return mockEventContainer; |
73 } | 73 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 if (opt_AllowRejection === undefined) { | 196 if (opt_AllowRejection === undefined) { |
197 fixture.mockApis.expects(once()). | 197 fixture.mockApis.expects(once()). |
198 fillFromChromeLocalStorage(eqJSON(defaultObject)). | 198 fillFromChromeLocalStorage(eqJSON(defaultObject)). |
199 will(returnValue(Promise.resolve(result))); | 199 will(returnValue(Promise.resolve(result))); |
200 } else { | 200 } else { |
201 fixture.mockApis.expects(once()). | 201 fixture.mockApis.expects(once()). |
202 fillFromChromeLocalStorage(eqJSON(defaultObject), opt_AllowRejection). | 202 fillFromChromeLocalStorage(eqJSON(defaultObject), opt_AllowRejection). |
203 will(returnValue(Promise.resolve(result))); | 203 will(returnValue(Promise.resolve(result))); |
204 } | 204 } |
205 } | 205 } |
OLD | NEW |