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

Side by Side Diff: chrome/browser/resources/google_now/background_test_util.js

Issue 19822007: Updated Google Now to Check the Geolocation Access Preference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@r213016
Patch Set: Spacing Fix Created 7 years, 5 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
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 // Mocks for globals needed for loading background.js. 5 // Mocks for globals needed for loading background.js.
6 6
7 function emptyMock() {} 7 function emptyMock() {}
8 function buildTaskManager() { 8 function buildTaskManager() {
9 return {instrumentApiFunction: emptyMock}; 9 return {
10 debugSetStepName: emptyMock,
11 instrumentApiFunction: emptyMock,
12 };
10 } 13 }
11 var instrumentApiFunction = emptyMock; 14 var instrumentApiFunction = emptyMock;
12 var buildAttemptManager = emptyMock; 15 var buildAttemptManager = emptyMock;
13 var emptyListener = {addListener: emptyMock}; 16 var emptyListener = {addListener: emptyMock};
14 chrome['location'] = {onLocationUpdate: emptyListener}; 17 chrome['location'] = {
18 onLocationUpdate: emptyListener,
xiyuan 2013/07/26 17:24:51 nit: The change seems to be unnecessary.
robliao 2013/07/26 19:04:32 Done.
19 };
15 chrome['notifications'] = { 20 chrome['notifications'] = {
16 onButtonClicked: emptyListener, 21 onButtonClicked: emptyListener,
17 onClicked: emptyListener, 22 onClicked: emptyListener,
18 onClosed: emptyListener 23 onClosed: emptyListener
19 }; 24 };
20 chrome['omnibox'] = {onInputEntered: emptyListener}; 25 chrome['omnibox'] = {onInputEntered: emptyListener};
26 chrome['preferencesPrivate'] = {
27 googleGeolocationAccessEnabled: {
28 onChange: emptyListener
29 }
30 };
21 chrome['runtime'] = { 31 chrome['runtime'] = {
22 onInstalled: emptyListener, 32 onInstalled: emptyListener,
23 onStartup: emptyListener 33 onStartup: emptyListener
24 }; 34 };
25 35
26 var storage = {}; 36 var storage = {};
27 37
28 /** 38 /**
29 * Syntactic sugar for use with will() on a Mock4JS.Mock. 39 * Syntactic sugar for use with will() on a Mock4JS.Mock.
30 * Creates an action for will() that invokes a callback that the tested code 40 * Creates an action for will() that invokes a callback that the tested code
31 * passes to a mocked function. 41 * passes to a mocked function.
32 * @param {SaveMockArguments} savedArgs Arguments that will contain the 42 * @param {SaveMockArguments} savedArgs Arguments that will contain the
33 * callback once the mocked function is called. 43 * callback once the mocked function is called.
34 * @param {number} callbackParameter Index of the callback parameter in 44 * @param {number} callbackParameter Index of the callback parameter in
35 * |savedArgs|. 45 * |savedArgs|.
36 * @param {...Object} var_args Arguments to pass to the callback. 46 * @param {...Object} var_args Arguments to pass to the callback.
37 * @return {CallFunctionAction} Action for use in will(). 47 * @return {CallFunctionAction} Action for use in will().
38 */ 48 */
39 function invokeCallback(savedArgs, callbackParameter, var_args) { 49 function invokeCallback(savedArgs, callbackParameter, var_args) {
40 var callbackArguments = Array.prototype.slice.call(arguments, 2); 50 var callbackArguments = Array.prototype.slice.call(arguments, 2);
41 return callFunction(function() { 51 return callFunction(function() {
42 savedArgs.arguments[callbackParameter].apply(null, callbackArguments); 52 savedArgs.arguments[callbackParameter].apply(null, callbackArguments);
53
54 // Mock4JS does not clear the saved args after invocation.
55 // To allow reuse of the same SaveMockArguments for multiple
56 // invocations with similar arguments, clear them here.
57 savedArgs.arguments.splice(0, savedArgs.arguments.length);
43 }); 58 });
44 } 59 }
45 60
46 /** 61 /**
47 * Mock4JS matcher object that matches the actual agrument and the expected 62 * Mock4JS matcher object that matches the actual agrument and the expected
48 * value iff their JSON represenations are same. 63 * value iff their JSON represenations are same.
49 * @param {Object} expectedValue Expected value. 64 * @param {Object} expectedValue Expected value.
50 * @constructor 65 * @constructor
51 */ 66 */
52 function MatchJSON(expectedValue) { 67 function MatchJSON(expectedValue) {
(...skipping 22 matching lines...) Expand all
75 }; 90 };
76 91
77 /** 92 /**
78 * Builds a MatchJSON agrument matcher for a given expected value. 93 * Builds a MatchJSON agrument matcher for a given expected value.
79 * @param {Object} expectedValue Expected value. 94 * @param {Object} expectedValue Expected value.
80 * @return {MatchJSON} Resulting Mock4JS matcher. 95 * @return {MatchJSON} Resulting Mock4JS matcher.
81 */ 96 */
82 function eqJSON(expectedValue) { 97 function eqJSON(expectedValue) {
83 return new MatchJSON(expectedValue); 98 return new MatchJSON(expectedValue);
84 } 99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698