Index: chrome/browser/resources/google_now/background_test_util.js |
diff --git a/chrome/browser/resources/google_now/background_test_util.js b/chrome/browser/resources/google_now/background_test_util.js |
index b4d2bccb9b0268e2cfa24261dfd71cf900340a0a..6b82ea8806589f57f0b37741ac20327b9b9e42fd 100644 |
--- a/chrome/browser/resources/google_now/background_test_util.js |
+++ b/chrome/browser/resources/google_now/background_test_util.js |
@@ -6,24 +6,51 @@ |
function emptyMock() {} |
function buildTaskManager() { |
- return {instrumentApiFunction: emptyMock}; |
+ return { |
+ add: function(taskname, task) { |
+ task(function() {}); |
+ }, |
+ debugSetStepName: emptyMock, |
+ instrumentApiFunction: emptyMock, |
+ }; |
} |
var instrumentApiFunction = emptyMock; |
-var buildAttemptManager = emptyMock; |
+var buildAttemptManager = function() { |
+ var isRunningState = false; |
+ return { |
+ isRunning: function(callback) { |
+ callback(isRunningState); |
+ }, |
+ start: function() { |
+ isRunningState = true; |
+ }, |
+ stop: function() { |
+ isRunningState = false; |
+ } |
+ }; |
+}; |
var emptyListener = {addListener: emptyMock}; |
-chrome['location'] = {onLocationUpdate: emptyListener}; |
+chrome['location'] = { |
+ onLocationUpdate: emptyListener, |
+ clearWatch: emptyMock |
vadimt
2013/07/25 20:48:01
We mock in background_test_util.js only methods th
robliao
2013/07/25 22:35:48
Done.
|
+}; |
chrome['notifications'] = { |
onButtonClicked: emptyListener, |
onClicked: emptyListener, |
onClosed: emptyListener |
}; |
chrome['omnibox'] = {onInputEntered: emptyListener}; |
+chrome['preferencesPrivate'] = { |
+ googleGeolocationAccessEnabled: { |
+ onChange: emptyListener |
+ } |
+}; |
chrome['runtime'] = { |
onInstalled: emptyListener, |
onStartup: emptyListener |
}; |
-var storage = {}; |
+var storage = {set: emptyMock}; |
/** |
* Syntactic sugar for use with will() on a Mock4JS.Mock. |
@@ -40,6 +67,11 @@ function invokeCallback(savedArgs, callbackParameter, var_args) { |
var callbackArguments = Array.prototype.slice.call(arguments, 2); |
return callFunction(function() { |
savedArgs.arguments[callbackParameter].apply(null, callbackArguments); |
+ |
+ // Mock4JS does not clear the saved args after invocation. |
+ // To allow reuse of the same SaveMockArguments for multiple |
+ // invocations with similar arguments, clear them here. |
+ savedArgs.arguments.splice(0, savedArgs.arguments.length); |
}); |
} |