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

Unified Diff: chrome/browser/resources/google_now/background_unittest.gtestjs

Issue 21985002: Add Finch Checks to the State Machine (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SMLog
Patch Set: Make Strings Const Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
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 a99ff5f21a1a4ca5280ffa9958a9915f80f2c9d5..64c799ed64681bb4582ebefd79725ddb6c435263 100644
--- a/chrome/browser/resources/google_now/background_unittest.gtestjs
+++ b/chrome/browser/resources/google_now/background_unittest.gtestjs
@@ -55,6 +55,7 @@ TEST_F('GoogleNowBackgroundUnitTest', 'AreTasksConflicting', function() {
function mockInitializeDependencies(fixture) {
fixture.makeAndRegisterMockGlobals([
'recordEvent',
+ 'setBackgroundEnable',
'showWelcomeToast',
'startPollingCards'
]);
@@ -62,6 +63,7 @@ function mockInitializeDependencies(fixture) {
'authenticationManager.isSignedIn',
'chrome.location.clearWatch',
'chrome.storage.local.set',
+ 'instrumented.metricsPrivate.getFieldTrial',
'instrumented.notifications.getAll',
'instrumented.preferencesPrivate.googleGeolocationAccessEnabled.get',
'instrumented.storage.local.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()).
+ instrumented_metricsPrivate_getFieldTrial(
+ getFieldTrialSavedArgs.match(ANYTHING),
+ getFieldTrialSavedArgs.match(ANYTHING)).
+ will(invokeCallback(
+ getFieldTrialSavedArgs, 1, testExperimentResponse));
+
var googleGeolocationPrefGetSavedArgs = new SaveMockArguments();
- mockApisObj.expects(once()).
+ fixture.mockApis.expects(once()).
instrumented_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()).
instrumented_storage_local_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)).
« no previous file with comments | « chrome/browser/resources/google_now/background.js ('k') | chrome/browser/resources/google_now/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698