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

Unified Diff: chrome/browser/ui/autofill/save_card_bubble_controller_impl_unittest.cc

Issue 2839683002: Logs different SaveCardPrompt histogram names depending on if user (Closed)
Patch Set: Uses no-suffix, 'PreviouslyAccepted' and 'PreviouslyDenied' for the save card prompt histograms. Created 3 years, 8 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/ui/autofill/save_card_bubble_controller_impl_unittest.cc
diff --git a/chrome/browser/ui/autofill/save_card_bubble_controller_impl_unittest.cc b/chrome/browser/ui/autofill/save_card_bubble_controller_impl_unittest.cc
index a1121ec0e70d10582419f630e2881d96d927e139..fc31bc0b37a3c297514c5d71667ffe1aab354a65 100644
--- a/chrome/browser/ui/autofill/save_card_bubble_controller_impl_unittest.cc
+++ b/chrome/browser/ui/autofill/save_card_bubble_controller_impl_unittest.cc
@@ -18,6 +18,8 @@
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/credit_card.h"
+#include "components/autofill/core/common/autofill_pref_names.h"
+#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/navigation_handle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -61,8 +63,13 @@ class SaveCardBubbleControllerImplTest : public BrowserWithTestWindowTest {
void SetUp() override {
BrowserWithTestWindowTest::SetUp();
AddTab(browser(), GURL("about:blank"));
- TestSaveCardBubbleControllerImpl::CreateForTesting(
- browser()->tab_strip_model()->GetActiveWebContents());
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ TestSaveCardBubbleControllerImpl::CreateForTesting(web_contents);
+ user_prefs::UserPrefs::Get(web_contents->GetBrowserContext())
+ ->SetInteger(
+ prefs::kAutofillAcceptSaveCreditCardPromptState,
+ prefs::PREVIOUS_SAVE_CREDIT_CARD_PROMPT_USER_DECISION_NONE);
}
BrowserWindow* CreateBrowserWindow() override {
@@ -267,6 +274,63 @@ TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_Reshows_CancelButton) {
}
TEST_F(SaveCardBubbleControllerImplTest,
+ Metrics_Local_FirstShow_CancelButton_FirstShow) {
+ base::HistogramTester histogram_tester;
+ ShowLocalBubble();
+ controller()->OnCancelButton();
+ controller()->OnBubbleClosed();
+
+ ShowLocalBubble();
+ controller()->OnCancelButton();
+ controller()->OnBubbleClosed();
+
+ EXPECT_THAT(
+ histogram_tester.GetAllSamples(
+ "Autofill.SaveCreditCardPrompt.Local.FirstShow"),
+ ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
+ Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1),
+ Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_DENIED, 1)));
+ EXPECT_THAT(
+ histogram_tester.GetAllSamples(
+ "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyDenied"),
+ ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
+ Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1),
+ Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_DENIED, 1)));
+}
+
+TEST_F(SaveCardBubbleControllerImplTest,
+ Metrics_Local_FirstShow_CancelButton_FirstShow_SaveButton_FirstShow) {
+ base::HistogramTester histogram_tester;
+ ShowLocalBubble();
+ controller()->OnCancelButton();
+ controller()->OnBubbleClosed();
+
+ ShowLocalBubble();
+ controller()->OnSaveButton();
+ controller()->OnBubbleClosed();
+
+ ShowLocalBubble();
+
+ EXPECT_THAT(
+ histogram_tester.GetAllSamples(
+ "Autofill.SaveCreditCardPrompt.Local.FirstShow"),
+ ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
+ Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1),
+ Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_DENIED, 1)));
+ EXPECT_THAT(
+ histogram_tester.GetAllSamples(
+ "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyAccepted"),
+ ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
+ Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1)));
+ EXPECT_THAT(
+ histogram_tester.GetAllSamples(
+ "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyDenied"),
+ ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
+ Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1),
+ Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_ACCEPTED, 1)));
+}
+
+TEST_F(SaveCardBubbleControllerImplTest,
Metrics_Local_FirstShow_NavigateWhileShowing) {
ShowLocalBubble();

Powered by Google App Engine
This is Rietveld 408576698