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

Unified Diff: components/ukm/test_ukm_service.cc

Issue 2800853004: UKM that threads together multiple form interaction events. (Closed)
Patch Set: Updates unit tests. Created 3 years, 8 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
Index: components/ukm/test_ukm_service.cc
diff --git a/components/ukm/test_ukm_service.cc b/components/ukm/test_ukm_service.cc
index e3fcef8671e1102941eae8d3b541227b3e71d5ad..824fa25a7fe2df7a21233a271bcd40eb21c14acb 100644
--- a/components/ukm/test_ukm_service.cc
+++ b/components/ukm/test_ukm_service.cc
@@ -4,6 +4,9 @@
#include "components/ukm/test_ukm_service.h"
+#include "base/logging.h"
+#include "base/metrics/metrics_hashes.h"
+#include "components/ukm/ukm_entry.h"
#include "components/ukm/ukm_source.h"
namespace ukm {
@@ -33,15 +36,38 @@ TestUkmService::GetSources() const {
}
const UkmSource* TestUkmService::GetSourceForUrl(const char* url) const {
+ const UkmSource* source = nullptr;
for (const auto& kv : sources_for_testing()) {
- if (kv.second->url() == url)
- return kv.second.get();
+ if (kv.second->url() == url) {
+ DCHECK_EQ(nullptr, source);
+ source = kv.second.get();
+ }
}
- return nullptr;
+ return source;
+}
+
+const UkmSource* TestUkmService::GetSourceForSourceId(int32_t source_id) const {
+ const UkmSource* source = nullptr;
+ for (const auto& kv : sources_for_testing()) {
+ if (kv.second->id() == source_id) {
+ DCHECK_EQ(nullptr, source);
+ source = kv.second.get();
+ }
+ }
+ return source;
}
const UkmEntry* TestUkmService::GetEntry(size_t entry_num) const {
return entries_for_testing()[entry_num].get();
}
+const UkmEntry* TestUkmService::GetEntryForEntryName(
+ const char* entry_name) const {
+ for (const auto& it : entries_for_testing()) {
+ if (it->event_hash() == base::HashMetricName(entry_name))
+ return it.get();
+ }
+ return nullptr;
+}
+
} // namespace ukm
« components/autofill/core/browser/form_structure.cc ('K') | « components/ukm/test_ukm_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698