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

Side by Side Diff: components/autofill/core/browser/autofill_manager_unittest.cc

Issue 2737953002: UKM: Remove UkmService::RecordSource (Closed)
Patch Set: fix error from rebase Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 const ukm::Entry_Metric* FindMetric( 785 const ukm::Entry_Metric* FindMetric(
786 const char* name, 786 const char* name,
787 const google::protobuf::RepeatedPtrField<ukm::Entry_Metric>& metrics) { 787 const google::protobuf::RepeatedPtrField<ukm::Entry_Metric>& metrics) {
788 for (const auto& metric : metrics) { 788 for (const auto& metric : metrics) {
789 if (metric.metric_hash() == base::HashMetricName(name)) 789 if (metric.metric_hash() == base::HashMetricName(name))
790 return &metric; 790 return &metric;
791 } 791 }
792 return nullptr; 792 return nullptr;
793 } 793 }
794 794
795 // Get Ukm sources from the Ukm service.
796 std::vector<const ukm::UkmSource*> GetUkmSources(ukm::TestUkmService* service) {
797 std::vector<const ukm::UkmSource*> sources;
798 for (const auto& kv : service->GetSources())
799 sources.push_back(kv.second.get());
800
801 return sources;
802 }
803
795 } // namespace 804 } // namespace
796 805
797 class AutofillManagerTest : public testing::Test { 806 class AutofillManagerTest : public testing::Test {
798 public: 807 public:
799 AutofillManagerTest() : field_trial_list_(nullptr) {} 808 AutofillManagerTest() : field_trial_list_(nullptr) {}
800 809
801 void SetUp() override { 810 void SetUp() override {
802 autofill_client_.SetPrefs(test::PrefServiceForTesting()); 811 autofill_client_.SetPrefs(test::PrefServiceForTesting());
803 personal_data_.set_database(autofill_client_.GetDatabase()); 812 personal_data_.set_database(autofill_client_.GetDatabase());
804 personal_data_.SetPrefService(autofill_client_.GetPrefs()); 813 personal_data_.SetPrefService(autofill_client_.GetPrefs());
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 void EnableUkmLogging() { 1028 void EnableUkmLogging() {
1020 scoped_feature_list_.InitAndEnableFeature(kAutofillUkmLogging); 1029 scoped_feature_list_.InitAndEnableFeature(kAutofillUkmLogging);
1021 } 1030 }
1022 1031
1023 void ExpectUniqueCardUploadDecisionUkm( 1032 void ExpectUniqueCardUploadDecisionUkm(
1024 AutofillMetrics::CardUploadDecisionMetric upload_decision) { 1033 AutofillMetrics::CardUploadDecisionMetric upload_decision) {
1025 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); 1034 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
1026 1035
1027 // Check that one source is logged. 1036 // Check that one source is logged.
1028 ASSERT_EQ(1U, ukm_service->sources_count()); 1037 ASSERT_EQ(1U, ukm_service->sources_count());
1029 const ukm::UkmSource* source = ukm_service->GetSource(0); 1038 const ukm::UkmSource* source = GetUkmSources(ukm_service)[0];
1030 1039
1031 // Check that one entry is logged. 1040 // Check that one entry is logged.
1032 EXPECT_EQ(1U, ukm_service->entries_count()); 1041 EXPECT_EQ(1U, ukm_service->entries_count());
1033 const ukm::UkmEntry* entry = ukm_service->GetEntry(0); 1042 const ukm::UkmEntry* entry = ukm_service->GetEntry(0);
1034 EXPECT_EQ(source->id(), entry->source_id()); 1043 EXPECT_EQ(source->id(), entry->source_id());
1035 1044
1036 ukm::Entry entry_proto; 1045 ukm::Entry entry_proto;
1037 entry->PopulateProto(&entry_proto); 1046 entry->PopulateProto(&entry_proto);
1038 EXPECT_EQ(source->id(), entry_proto.source_id()); 1047 EXPECT_EQ(source->id(), entry_proto.source_id());
1039 1048
(...skipping 4790 matching lines...) Expand 10 before | Expand all | Expand 10 after
5830 FormsSeen({form}); 5839 FormsSeen({form});
5831 5840
5832 // Suggestions should be displayed. 5841 // Suggestions should be displayed.
5833 for (const FormFieldData& field : form.fields) { 5842 for (const FormFieldData& field : form.fields) {
5834 GetAutofillSuggestions(form, field); 5843 GetAutofillSuggestions(form, field);
5835 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); 5844 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen());
5836 } 5845 }
5837 } 5846 }
5838 5847
5839 } // namespace autofill 5848 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698