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

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

Issue 55123002: Requesting background permission only when user is opted in to GN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More robliao@ comments. Created 7 years, 2 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
« no previous file with comments | « chrome/browser/resources/google_now/background.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2541796164fc79c6bc2304244d707b2d8de3eeeb..bb9f943d878bd41b30110c44431fa1f045ba92de 100644
--- a/chrome/browser/resources/google_now/background_unittest.gtestjs
+++ b/chrome/browser/resources/google_now/background_unittest.gtestjs
@@ -486,13 +486,16 @@ function mockInitializeDependencies(fixture) {
* metricsPrivate.getVariationParams.
* @param {string} testExperimentVariationParams Response of
* notifications.getPermissionLevel.
+ * @param {boolean} testGoogleNowEnabled True if the user is opted in to Google
+ * Now.
*/
function expectStateMachineCalls(
fixture,
testIdentityToken,
testGeolocationPref,
testExperimentVariationParams,
- testNotificationPermissionLevel) {
+ testNotificationPermissionLevel,
+ testGoogleNowEnabled) {
var authenticationManagerIsSignedInSavedArgs = new SaveMockArguments();
fixture.mockApis.expects(once()).
authenticationManager_isSignedIn(
@@ -527,6 +530,14 @@ function expectStateMachineCalls(
0,
testNotificationPermissionLevel))
+ var storageGetSavedArgs = new SaveMockArguments();
+ fixture.mockApis.expects(once()).
+ instrumented_storage_local_get(
+ storageGetSavedArgs.match(eq('googleNowEnabled')),
+ storageGetSavedArgs.match(ANYTHING)).
+ will(invokeCallback(
+ storageGetSavedArgs, 1, {googleNowEnabled: testGoogleNowEnabled}));
+
fixture.mockGlobals.expects(once()).
setBackgroundEnable(ANYTHING);
}
@@ -567,6 +578,7 @@ TEST_F(
var testGeolocationPref = false;
var testExperimentVariationParams = {};
var testNotificationPermissionLevel = 'denied';
+ var testGoogleNowEnabled = undefined;
mockInitializeDependencies(this);
@@ -583,7 +595,8 @@ TEST_F(
testIdentityToken,
testGeolocationPref,
testExperimentVariationParams,
- testNotificationPermissionLevel);
+ testNotificationPermissionLevel,
+ testGoogleNowEnabled);
// Invoking the tested function.
initialize();
@@ -602,6 +615,7 @@ TEST_F(
var testGeolocationPref = false;
var testExperimentVariationParams = {};
var testNotificationPermissionLevel = 'denied';
+ var testGoogleNowEnabled = undefined;
mockInitializeDependencies(this);
@@ -615,7 +629,8 @@ TEST_F(
testIdentityToken,
testGeolocationPref,
testExperimentVariationParams,
- testNotificationPermissionLevel);
+ testNotificationPermissionLevel,
+ testGoogleNowEnabled);
var chromeNotificationGetAllSavedArgs = new SaveMockArguments();
this.mockApis.expects(exactly(1)).
@@ -638,6 +653,7 @@ TEST_F('GoogleNowBackgroundUnitTest', 'Initialize_RunGoogleNow', function() {
var testGeolocationPref = true;
var testExperimentVariationParams = {};
var testNotificationPermissionLevel = 'granted';
+ var testGoogleNowEnabled = true;
mockInitializeDependencies(this);
@@ -651,7 +667,8 @@ TEST_F('GoogleNowBackgroundUnitTest', 'Initialize_RunGoogleNow', function() {
testIdentityToken,
testGeolocationPref,
testExperimentVariationParams,
- testNotificationPermissionLevel);
+ testNotificationPermissionLevel,
+ testGoogleNowEnabled);
this.mockGlobals.expects(once()).startPollingCards();
@@ -671,6 +688,8 @@ TEST_F(
var testGeolocationPref = false;
var testExperimentVariationParams = {};
var testNotificationPermissionLevel = 'denied';
+ var testGoogleNowEnabled = undefined;
+
mockInitializeDependencies(this);
@@ -688,7 +707,8 @@ TEST_F(
testGeolocationPref,
testExperimentVariationParams,
testNotificationPermissionLevel,
- testNotificationPermissionLevel);
+ testNotificationPermissionLevel,
+ testGoogleNowEnabled);
var chromeNotificationGetAllSavedArgs = new SaveMockArguments();
this.mockApis.expects(exactly(2)).
« no previous file with comments | « chrome/browser/resources/google_now/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698