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

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

Issue 199793024: Report Metrics on No Card Polling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 14d8e58429e11417fd0ff857ca6979d62f869761..65c2ab5167ed572f1d800f45c800dc9caf039a91 100644
--- a/chrome/browser/resources/google_now/background_unittest.gtestjs
+++ b/chrome/browser/resources/google_now/background_unittest.gtestjs
@@ -279,6 +279,9 @@ TEST_F(
this.mockGlobals.expects(once()).recordEvent(
GoogleNowEvent.STOPPED);
+ this.mockGlobals.expects(once()).recordEvent(
+ GoogleNowEvent.SIGNED_OUT);
+
expectInitialization(this.mockApis);
expectStateMachineCalls(
@@ -323,6 +326,104 @@ TEST_F('GoogleNowBackgroundUnitTest', 'Initialize_RunGoogleNow', function() {
});
/**
+ * No Cards Reporting Tests
+ */
+TEST_F('GoogleNowBackgroundUnitTest', 'NoCardsSignedOut', function() {
+ var signedIn = false;
+ var notificationEnabled = false;
+ var googleNowEnabled = false;
+ this.makeAndRegisterMockGlobals([
+ 'recordEvent',
+ 'setBackgroundEnable',
+ 'setShouldPollCards']);
+
+ this.mockGlobals.stubs().setBackgroundEnable(ANYTHING);
+ this.mockGlobals.stubs().setShouldPollCards(ANYTHING);
+
+ this.mockGlobals.expects(once()).recordEvent(
+ GoogleNowEvent.STOPPED);
+ this.mockGlobals.expects(once()).recordEvent(
+ GoogleNowEvent.SIGNED_OUT);
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.NOTIFICATION_DISABLED);
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.GOOGLE_NOW_DISABLED);
+ updateRunningState(signedIn, true, notificationEnabled, googleNowEnabled);
+});
+
+TEST_F(
+ 'GoogleNowBackgroundUnitTest',
+ 'NoCardsNotificationsDisabled',
+ function() {
+ var signedIn = true;
+ var notificationEnabled = false;
+ var googleNowEnabled = false;
+ this.makeAndRegisterMockGlobals([
+ 'recordEvent',
+ 'setBackgroundEnable',
+ 'setShouldPollCards']);
+
+ this.mockGlobals.stubs().setBackgroundEnable(ANYTHING);
+ this.mockGlobals.stubs().setShouldPollCards(ANYTHING);
+
+ this.mockGlobals.expects(once()).recordEvent(
+ GoogleNowEvent.STOPPED);
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.SIGNED_OUT);
+ this.mockGlobals.expects(once()).recordEvent(
+ GoogleNowEvent.NOTIFICATION_DISABLED);
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.GOOGLE_NOW_DISABLED);
+ updateRunningState(signedIn, true, notificationEnabled, googleNowEnabled);
+ });
+
+TEST_F('GoogleNowBackgroundUnitTest', 'NoCardsGoogleNowDisabled', function() {
+ var signedIn = true;
+ var notificationEnabled = true;
+ var googleNowEnabled = false;
+ this.makeAndRegisterMockGlobals([
+ 'recordEvent',
+ 'setBackgroundEnable',
+ 'setShouldPollCards']);
+
+ this.mockGlobals.stubs().setBackgroundEnable(ANYTHING);
+ this.mockGlobals.stubs().setShouldPollCards(ANYTHING);
+
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.STOPPED);
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.SIGNED_OUT);
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.NOTIFICATION_DISABLED);
+ this.mockGlobals.expects(once()).recordEvent(
+ GoogleNowEvent.GOOGLE_NOW_DISABLED);
+ updateRunningState(signedIn, true, notificationEnabled, googleNowEnabled);
+});
+
+TEST_F('GoogleNowBackgroundUnitTest', 'NoCardsEverythingEnabled', function() {
+ var signedIn = true;
+ var notificationEnabled = true;
+ var googleNowEnabled = true;
+ this.makeAndRegisterMockGlobals([
+ 'recordEvent',
+ 'setBackgroundEnable',
+ 'setShouldPollCards']);
+
+ this.mockGlobals.stubs().setBackgroundEnable(ANYTHING);
+ this.mockGlobals.stubs().setShouldPollCards(ANYTHING);
+
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.STOPPED);
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.SIGNED_OUT);
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.NOTIFICATION_DISABLED);
+ this.mockGlobals.expects(never()).recordEvent(
+ GoogleNowEvent.GOOGLE_NOW_DISABLED);
+ updateRunningState(signedIn, true, notificationEnabled, googleNowEnabled);
+});
+
+/**
* Mocks global functions and APIs that onNotificationClicked() depends upon.
* @param {Test} fixture Test fixture.
*/

Powered by Google App Engine
This is Rietveld 408576698