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

Unified Diff: chrome/browser/autofill/autofill_save_card_infobar_delegate_mobile_unittest.cc

Issue 2434543003: [Autofill] Separate Autofill.CreditCardInfoBar into .Local and .Server (Closed)
Patch Set: Add base=true value to histogram Created 4 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 | « no previous file | components/autofill/core/browser/autofill_metrics.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_save_card_infobar_delegate_mobile_unittest.cc
diff --git a/chrome/browser/autofill/autofill_save_card_infobar_delegate_mobile_unittest.cc b/chrome/browser/autofill/autofill_save_card_infobar_delegate_mobile_unittest.cc
index b97789e2cf823cf96dcf2a5345a069ea869e3745..7a560a276f20b9b38b623aa921db16e2f7bb9dc0 100644
--- a/chrome/browser/autofill/autofill_save_card_infobar_delegate_mobile_unittest.cc
+++ b/chrome/browser/autofill/autofill_save_card_infobar_delegate_mobile_unittest.cc
@@ -54,7 +54,7 @@ class AutofillSaveCardInfoBarDelegateMobileTest
void TearDown() override;
protected:
- std::unique_ptr<ConfirmInfoBarDelegate> CreateDelegate();
+ std::unique_ptr<ConfirmInfoBarDelegate> CreateDelegate(bool is_uploading);
std::unique_ptr<TestPersonalDataManager> personal_data_;
@@ -88,63 +88,119 @@ void AutofillSaveCardInfoBarDelegateMobileTest::TearDown() {
}
std::unique_ptr<ConfirmInfoBarDelegate>
-AutofillSaveCardInfoBarDelegateMobileTest::CreateDelegate() {
+AutofillSaveCardInfoBarDelegateMobileTest::CreateDelegate(bool is_uploading) {
base::HistogramTester histogram_tester;
CreditCard credit_card;
std::unique_ptr<base::DictionaryValue> legal_message;
std::unique_ptr<ConfirmInfoBarDelegate> delegate(
new AutofillSaveCardInfoBarDelegateMobile(
- false, credit_card, std::move(legal_message),
+ is_uploading, credit_card, std::move(legal_message),
base::Bind(base::IgnoreResult(
&TestPersonalDataManager::SaveImportedCreditCard),
base::Unretained(personal_data_.get()), credit_card)));
- histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar",
+ std::string destination = is_uploading ? ".Server" : ".Local";
+ histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar"
+ + destination,
AutofillMetrics::INFOBAR_SHOWN, 1);
return delegate;
}
-// Test that credit card infobar metrics are logged correctly.
-TEST_F(AutofillSaveCardInfoBarDelegateMobileTest, Metrics) {
+// Test that local credit card save infobar metrics are logged correctly.
+TEST_F(AutofillSaveCardInfoBarDelegateMobileTest, Metrics_Local) {
::testing::InSequence dummy;
// Accept the infobar.
{
- std::unique_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
+ std::unique_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateDelegate(/* is_uploading= */ false));
EXPECT_CALL(*personal_data_, SaveImportedCreditCard(_));
base::HistogramTester histogram_tester;
EXPECT_TRUE(infobar->Accept());
- histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar",
+ histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar.Local",
AutofillMetrics::INFOBAR_ACCEPTED, 1);
}
// Cancel the infobar.
{
- std::unique_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
+ std::unique_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateDelegate(/* is_uploading= */ false));
base::HistogramTester histogram_tester;
EXPECT_TRUE(infobar->Cancel());
- histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar",
+ histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar.Local",
AutofillMetrics::INFOBAR_DENIED, 1);
}
// Dismiss the infobar.
{
- std::unique_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
+ std::unique_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateDelegate(/* is_uploading= */ false));
base::HistogramTester histogram_tester;
infobar->InfoBarDismissed();
- histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar",
+ histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar.Local",
AutofillMetrics::INFOBAR_DENIED, 1);
}
// Ignore the infobar.
{
- std::unique_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
+ std::unique_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateDelegate(/* is_uploading= */ false));
base::HistogramTester histogram_tester;
infobar.reset();
- histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar",
+ histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar.Local",
+ AutofillMetrics::INFOBAR_IGNORED, 1);
+ }
+}
+
+// Test that server credit card save infobar metrics are logged correctly.
+TEST_F(AutofillSaveCardInfoBarDelegateMobileTest, Metrics_Server) {
+ ::testing::InSequence dummy;
+
+ // Accept the infobar.
+ {
+ std::unique_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateDelegate(/* is_uploading= */ true));
+ EXPECT_CALL(*personal_data_, SaveImportedCreditCard(_));
+
+ base::HistogramTester histogram_tester;
+ EXPECT_TRUE(infobar->Accept());
+ histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar.Server",
+ AutofillMetrics::INFOBAR_ACCEPTED, 1);
+ }
+
+ // Cancel the infobar.
+ {
+ std::unique_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateDelegate(/* is_uploading= */ true));
+
+ base::HistogramTester histogram_tester;
+ EXPECT_TRUE(infobar->Cancel());
+ histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar.Server",
+ AutofillMetrics::INFOBAR_DENIED, 1);
+ }
+
+ // Dismiss the infobar.
+ {
+ std::unique_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateDelegate(/* is_uploading= */ true));
+
+ base::HistogramTester histogram_tester;
+ infobar->InfoBarDismissed();
+ histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar.Server",
+ AutofillMetrics::INFOBAR_DENIED, 1);
+ }
+
+ // Ignore the infobar.
+ {
+ std::unique_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateDelegate(/* is_uploading= */ true));
+
+ base::HistogramTester histogram_tester;
+ infobar.reset();
+ histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar.Server",
AutofillMetrics::INFOBAR_IGNORED, 1);
}
}
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698