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

Unified Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 2144653002: [Autofill] Log whether queried credit card form context is secure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 5 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 | « components/autofill/core/browser/autofill_metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/autofill_metrics_unittest.cc
diff --git a/components/autofill/core/browser/autofill_metrics_unittest.cc b/components/autofill/core/browser/autofill_metrics_unittest.cc
index 1d5c5168f5475ad417889ec883020c51760dda2e..c19f5c2247130ff8a93c82d6c8e0877a9f047594 100644
--- a/components/autofill/core/browser/autofill_metrics_unittest.cc
+++ b/components/autofill/core/browser/autofill_metrics_unittest.cc
@@ -155,7 +155,8 @@ class TestPersonalDataManager : public PersonalDataManager {
local_credit_cards_.clear();
server_credit_cards_.clear();
if (include_local_credit_card) {
- CreditCard* credit_card = new CreditCard;
+ CreditCard* credit_card =
+ new CreditCard(base::ASCIIToUTF16("4111111111111111"), 12, 24);
credit_card->set_guid("10000000-0000-0000-0000-000000000001");
local_credit_cards_.push_back(credit_card);
}
@@ -1812,6 +1813,56 @@ TEST_F(AutofillMetricsTest, PolledCreditCardSuggestions_DebounceLogs) {
"Autofill_PolledCreditCardSuggestions"));
}
+// Tests that the Autofill.QueriedCreditCardFormIsSecure histogram is logged
+// properly.
+TEST_F(AutofillMetricsTest, QueriedCreditCardFormIsSecure) {
+ personal_data_->RecreateCreditCards(
+ true /* include_local_credit_card */,
+ false /* include_masked_server_credit_card */,
+ false /* include_full_server_credit_card */);
+
+ // Set up the form data.
+ FormData form;
+ form.name = ASCIIToUTF16("TestForm");
+ form.origin = GURL("http://example.com/form.html");
+ form.action = GURL("http://example.com/submit.html");
+
+ FormFieldData field;
+ std::vector<ServerFieldType> field_types;
+ test::CreateTestFormField("Month", "card_month", "", "text", &field);
+ form.fields.push_back(field);
+ field_types.push_back(CREDIT_CARD_EXP_MONTH);
+ test::CreateTestFormField("Year", "card_year", "", "text", &field);
+ form.fields.push_back(field);
+ field_types.push_back(CREDIT_CARD_EXP_2_DIGIT_YEAR);
+ test::CreateTestFormField("Credit card", "card", "", "text", &field);
+ form.fields.push_back(field);
+ field_types.push_back(CREDIT_CARD_NUMBER);
+
+ // Simulate having seen this form on page load.
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulate an Autofill query on a credit card field.
+ autofill_client_.set_is_context_secure(true);
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnQueryFormFieldAutofill(0, form, form.fields[1],
+ gfx::RectF());
+ histogram_tester.ExpectUniqueSample(
+ "Autofill.QueriedCreditCardFormIsSecure", true, 1);
+ }
+
+ {
+ // Simulate an Autofill query on a credit card field.
+ autofill_client_.set_is_context_secure(false);
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnQueryFormFieldAutofill(0, form, form.fields[1],
+ gfx::RectF());
+ histogram_tester.ExpectUniqueSample(
+ "Autofill.QueriedCreditCardFormIsSecure", false, 1);
+ }
+}
+
// Tests that the Autofill_PolledProfileSuggestions user action is only logged
// once if the field is queried repeatedly.
TEST_F(AutofillMetricsTest, PolledProfileSuggestions_DebounceLogs) {
« no previous file with comments | « components/autofill/core/browser/autofill_metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698