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

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

Issue 2849753002: Logs all reasons card upload was not offered in UKM and UMA. (Closed)
Patch Set: Formatting fix. Created 3 years, 7 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_metrics.h" 5 #include "components/autofill/core/browser/autofill_metrics.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 internal::kUKMDeveloperEngagementEntryName); 336 internal::kUKMDeveloperEngagementEntryName);
337 ASSERT_NE(nullptr, entry); 337 ASSERT_NE(nullptr, entry);
338 ukm::Entry entry_proto; 338 ukm::Entry entry_proto;
339 entry->PopulateProto(&entry_proto); 339 entry->PopulateProto(&entry_proto);
340 340
341 const ukm::UkmSource* source = 341 const ukm::UkmSource* source =
342 ukm_service->GetSourceForSourceId(entry_proto.source_id()); 342 ukm_service->GetSourceForSourceId(entry_proto.source_id());
343 ASSERT_NE(nullptr, source); 343 ASSERT_NE(nullptr, source);
344 EXPECT_EQ(form.origin, source->url()); 344 EXPECT_EQ(form.origin, source->url());
345 345
346 std::vector<std::pair<const char*, int64_t>> expected_metrics; 346 int expected_metric_value = 0;
347 for (const auto it : expected_metric_values) 347 for (const auto it : expected_metric_values)
348 expected_metrics.push_back( 348 expected_metric_value |= 1 << it;
349 {internal::kUKMDeveloperEngagementMetricName, it}); 349
350 const std::vector<std::pair<const char*, int64_t>> expected_metrics{
351 {internal::kUKMDeveloperEngagementMetricName, expected_metric_value}};
350 352
351 EXPECT_THAT(entry_proto.metrics(), 353 EXPECT_THAT(entry_proto.metrics(),
352 UnorderedPointwise(CompareMetrics(), expected_metrics)); 354 UnorderedPointwise(CompareMetrics(), expected_metrics));
353 } 355 }
354 356
355 MATCHER(CompareMetricsIgnoringMillisecondsSinceFormLoaded, "") { 357 MATCHER(CompareMetricsIgnoringMillisecondsSinceFormLoaded, "") {
356 const ukm::Entry_Metric& lhs = ::testing::get<0>(arg); 358 const ukm::Entry_Metric& lhs = ::testing::get<0>(arg);
357 const std::pair<const char*, int64_t>& rhs = ::testing::get<1>(arg); 359 const std::pair<const char*, int64_t>& rhs = ::testing::get<1>(arg);
358 return lhs.metric_hash() == base::HashMetricName(rhs.first) && 360 return lhs.metric_hash() == base::HashMetricName(rhs.first) &&
359 (lhs.value() == rhs.second || 361 (lhs.value() == rhs.second ||
(...skipping 4812 matching lines...) Expand 10 before | Expand all | Expand 10 after
5172 ukm::UkmServiceTestingHarness ukm_service_test_harness; 5174 ukm::UkmServiceTestingHarness ukm_service_test_harness;
5173 GURL url("https://www.google.com"); 5175 GURL url("https://www.google.com");
5174 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}}; 5176 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}};
5175 5177
5176 EXPECT_FALSE(AutofillMetrics::LogUkm( 5178 EXPECT_FALSE(AutofillMetrics::LogUkm(
5177 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics)); 5179 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics));
5178 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); 5180 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count());
5179 } 5181 }
5180 5182
5181 } // namespace autofill 5183 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698