Chromium Code Reviews| 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 efea6e76cab0aafd11a2a5053fff1cb525bda757..dc9e95cb2464a5160ed660b8728eb499bba655f0 100644 |
| --- a/components/autofill/core/browser/autofill_metrics_unittest.cc |
| +++ b/components/autofill/core/browser/autofill_metrics_unittest.cc |
| @@ -766,7 +766,7 @@ TEST_F(AutofillMetricsTest, QualityMetrics_BasedOnAutocomplete) { |
| std::unique_ptr<TestFormStructure> form_structure = |
| base::MakeUnique<TestFormStructure>(form); |
| TestFormStructure* form_structure_ptr = form_structure.get(); |
| - form_structure->DetermineHeuristicTypes(); |
| + form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL()); |
| autofill_manager_->form_structures()->push_back(std::move(form_structure)); |
| AutofillQueryResponseContents response; |
| @@ -4366,7 +4366,7 @@ TEST_F(AutofillMetricsTest, |
| } |
| } |
| -// Tests that logging a UKM works as expected. |
| +// Tests that logging CardUploadDecision UKM works as expected. |
| TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric) { |
| EnableUkmLogging(); |
| ukm::UkmServiceTestingHarness ukm_service_test_harness; |
| @@ -4393,7 +4393,7 @@ TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric) { |
| const ukm::UkmEntry* entry = ukm_service->GetEntry(0); |
| EXPECT_EQ(source->id(), entry->source_id()); |
| - // Make sure that an card upload decision entry was logged. |
| + // Make sure that a card upload decision entry was logged. |
| ukm::Entry entry_proto; |
| entry->PopulateProto(&entry_proto); |
| EXPECT_EQ(source->id(), entry_proto.source_id()); |
| @@ -4408,6 +4408,48 @@ TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric) { |
| EXPECT_EQ(upload_decision, metric->value()); |
| } |
| +// Tests that logging DeveloperEngagement UKM works as expected. |
| +TEST_F(AutofillMetricsTest, RecordDeveloperEnagementMetric) { |
|
Mathieu
2017/03/27 18:58:55
*engagement
Mathieu
2017/03/27 18:58:55
This is not a sufficient test. You should also add
csashi
2017/03/27 23:37:43
Done.
|
| + EnableUkmLogging(); |
| + ukm::UkmServiceTestingHarness ukm_service_test_harness; |
| + GURL url("https://www.google.com"); |
| + int form_structure_metric = 1; |
| + std::map<std::string, int> metrics; |
| + metrics.insert(std::make_pair(internal::kUKMDeveloperEngagementMetricName, |
| + form_structure_metric)); |
| + |
| + EXPECT_TRUE(AutofillMetrics::LogUkm( |
| + ukm_service_test_harness.test_ukm_service(), url, |
| + internal::kUKMDeveloperEngagementEntryName, metrics)); |
| + |
| + // Make sure that the UKM was logged correctly. |
| + ukm::TestUkmService* ukm_service = |
| + ukm_service_test_harness.test_ukm_service(); |
| + |
| + ASSERT_EQ(1U, ukm_service->sources_count()); |
| + const ukm::UkmSource* source = |
| + ukm_service->GetSourceForUrl(url.spec().c_str()); |
| + EXPECT_EQ(url.spec(), source->url().spec()); |
| + |
| + EXPECT_EQ(1U, ukm_service->entries_count()); |
| + const ukm::UkmEntry* entry = ukm_service->GetEntry(0); |
| + EXPECT_EQ(source->id(), entry->source_id()); |
| + |
| + // Make sure that a developer engagement entry was logged. |
| + ukm::Entry entry_proto; |
| + entry->PopulateProto(&entry_proto); |
| + EXPECT_EQ(source->id(), entry_proto.source_id()); |
| + EXPECT_EQ(base::HashMetricName(internal::kUKMDeveloperEngagementEntryName), |
| + entry_proto.event_hash()); |
| + EXPECT_EQ(1, entry_proto.metrics_size()); |
| + |
| + // Make sure that the correct developer engagement metric was logged. |
| + const ukm::Entry_Metric* metric = FindMetric( |
| + internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics()); |
| + ASSERT_NE(nullptr, metric); |
| + EXPECT_EQ(form_structure_metric, metric->value()); |
| +} |
| + |
| // Tests that no UKM is logged when the URL is not valid. |
| TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_InvalidUrl) { |
| EnableUkmLogging(); |