Index: chrome/browser/resources/google_now/background_unittest.gtestjs |
diff --git a/chrome/browser/resources/google_now/background_unittest.gtestjs b/chrome/browser/resources/google_now/background_unittest.gtestjs |
index 5ad7050d7d59f8fcca27da9d25038a6920509b5b..964f451fa16fa605ec5e9eeafce0c885326658d7 100644 |
--- a/chrome/browser/resources/google_now/background_unittest.gtestjs |
+++ b/chrome/browser/resources/google_now/background_unittest.gtestjs |
@@ -55,12 +55,14 @@ TEST_F('GoogleNowBackgroundUnitTest', 'AreTasksConflicting', function() { |
function mockInitializeDependencies(fixture) { |
fixture.makeAndRegisterMockGlobals([ |
'recordEvent', |
+ 'setBackgroundEnable', |
'showWelcomeToast', |
'startPollingCards' |
]); |
fixture.makeAndRegisterMockApis([ |
'authenticationManager.isSignedIn', |
'chrome.location.clearWatch', |
+ 'chrome.metricsPrivate.getFieldTrial', |
'chrome.notifications.getAll', |
'chrome.preferencesPrivate.googleGeolocationAccessEnabled.get', |
'storage.get', |
@@ -77,19 +79,20 @@ function mockInitializeDependencies(fixture) { |
* Note that this CAN NOT be used if any of the methods below are called |
* outside of this context with the same argument matchers. |
* expects() calls cannot be chained with the same argument matchers. |
- * @param {object} mockApisObj Mock APIs Object. |
+ * @param {object} fixture Test fixture. |
* @param {string} testIdentityToken getAuthToken callback token. |
* @param {boolean} testGeolocationPref Geolocation Preference callback value. |
* @param {boolean} testUserRespondedToToast User Response to toast |
& callback value. |
*/ |
function expectStateMachineCalls( |
- mockApisObj, |
+ fixture, |
testIdentityToken, |
testGeolocationPref, |
- testUserRespondedToToast) { |
+ testUserRespondedToToast, |
+ testExperimentResponse) { |
var authenticationManagerIsSignedInSavedArgs = new SaveMockArguments(); |
- mockApisObj.expects(once()). |
+ fixture.mockApis.expects(once()). |
authenticationManager_isSignedIn( |
authenticationManagerIsSignedInSavedArgs.match(ANYTHING)). |
will(invokeCallback( |
@@ -97,8 +100,16 @@ function expectStateMachineCalls( |
0, |
testIdentityToken)); |
+ var getFieldTrialSavedArgs = new SaveMockArguments(); |
+ fixture.mockApis.expects(once()). |
+ chrome_metricsPrivate_getFieldTrial( |
+ getFieldTrialSavedArgs.match(ANYTHING), |
+ getFieldTrialSavedArgs.match(ANYTHING)). |
+ will(invokeCallback( |
+ getFieldTrialSavedArgs, 1, testExperimentResponse)); |
+ |
var googleGeolocationPrefGetSavedArgs = new SaveMockArguments(); |
- mockApisObj.expects(once()). |
+ fixture.mockApis.expects(once()). |
chrome_preferencesPrivate_googleGeolocationAccessEnabled_get( |
googleGeolocationPrefGetSavedArgs.match(eqJSON({})), |
googleGeolocationPrefGetSavedArgs.match(ANYTHING)). |
@@ -106,11 +117,19 @@ function expectStateMachineCalls( |
googleGeolocationPrefGetSavedArgs, 1, {value: testGeolocationPref})); |
var storageGetSavedArgs = new SaveMockArguments(); |
- mockApisObj.expects(once()). |
+ fixture.mockApis.expects(once()). |
storage_get( |
storageGetSavedArgs.match(eq('userRespondedToToast')), |
storageGetSavedArgs.match(ANYTHING)). |
will(invokeCallback(storageGetSavedArgs, 1, testUserRespondedToToast)); |
+ |
+ var setBackgroundEnableSavedArgs = new SaveMockArguments(); |
+ fixture.mockGlobals.expects(once()). |
+ setBackgroundEnable( |
+ setBackgroundEnableSavedArgs.match(ANYTHING), |
+ setBackgroundEnableSavedArgs.match(ANYTHING)). |
+ will(invokeCallback( |
+ setBackgroundEnableSavedArgs, 1, {})); |
} |
/** |
@@ -155,6 +174,7 @@ TEST_F( |
var testIdentityToken = undefined; |
var testGeolocationPref = false; |
var testUserRespondedToToast = {}; |
+ var testExperimentResponse = ''; |
mockInitializeDependencies(this); |
@@ -167,10 +187,11 @@ TEST_F( |
expectInitialization(this.mockApis); |
expectStateMachineCalls( |
- this.mockApis, |
+ this, |
testIdentityToken, |
testGeolocationPref, |
- testUserRespondedToToast); |
+ testUserRespondedToToast, |
+ testExperimentResponse); |
var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); |
this.mockApis.expects(exactly(2)). |
@@ -199,6 +220,7 @@ TEST_F( |
var testIdentityToken = undefined; |
var testGeolocationPref = false; |
var testUserRespondedToToast = {}; |
+ var testExperimentResponse = ''; |
mockInitializeDependencies(this); |
@@ -211,10 +233,11 @@ TEST_F( |
expectInitialization(this.mockApis); |
expectStateMachineCalls( |
- this.mockApis, |
+ this, |
testIdentityToken, |
testGeolocationPref, |
- testUserRespondedToToast); |
+ testUserRespondedToToast, |
+ testExperimentResponse); |
var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); |
this.mockApis.expects(exactly(2)). |
@@ -241,6 +264,7 @@ TEST_F( |
var testIdentityToken = 'some identity token'; |
var testGeolocationPref = false; |
var testUserRespondedToToast = {}; |
+ var testExperimentResponse = ''; |
mockInitializeDependencies(this); |
@@ -250,10 +274,11 @@ TEST_F( |
expectInitialization(this.mockApis); |
expectStateMachineCalls( |
- this.mockApis, |
+ this, |
testIdentityToken, |
testGeolocationPref, |
- testUserRespondedToToast); |
+ testUserRespondedToToast, |
+ testExperimentResponse); |
var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); |
this.mockApis.expects(exactly(2)). |
@@ -278,6 +303,7 @@ TEST_F('GoogleNowBackgroundUnitTest', 'Initialize_RunGoogleNow', function() { |
var testIdentityToken = 'some identity token'; |
var testGeolocationPref = true; |
var testUserRespondedToToast = {userRespondedToToast: true}; |
+ var testExperimentResponse = ''; |
mockInitializeDependencies(this); |
@@ -287,10 +313,11 @@ TEST_F('GoogleNowBackgroundUnitTest', 'Initialize_RunGoogleNow', function() { |
expectInitialization(this.mockApis); |
expectStateMachineCalls( |
- this.mockApis, |
+ this, |
testIdentityToken, |
testGeolocationPref, |
- testUserRespondedToToast); |
+ testUserRespondedToToast, |
+ testExperimentResponse); |
var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); |
this.mockApis.expects(exactly(2)). |
@@ -315,6 +342,7 @@ TEST_F('GoogleNowBackgroundUnitTest', 'Initialize_NoGeolocation', function() { |
var testIdentityToken = 'some identity token'; |
var testGeolocationPref = false; |
var testUserRespondedToToast = {userRespondedToToast: true}; |
+ var testExperimentResponse = ''; |
mockInitializeDependencies(this); |
@@ -327,10 +355,11 @@ TEST_F('GoogleNowBackgroundUnitTest', 'Initialize_NoGeolocation', function() { |
expectInitialization(this.mockApis); |
expectStateMachineCalls( |
- this.mockApis, |
+ this, |
testIdentityToken, |
testGeolocationPref, |
- testUserRespondedToToast); |
+ testUserRespondedToToast, |
+ testExperimentResponse); |
var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); |
this.mockApis.expects(exactly(2)). |