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

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: CR Feedback 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
« no previous file with comments | « chrome/browser/resources/google_now/background.js ('k') | tools/metrics/histograms/histograms.xml » ('j') | 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 14d8e58429e11417fd0ff857ca6979d62f869761..8b902afd1b624afd4976242ceb2e2681ba7b45d0 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 Event Recording 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.
*/
« no previous file with comments | « chrome/browser/resources/google_now/background.js ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698