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

Unified Diff: components/ukm/ukm_service_unittest.cc

Issue 2727343004: Add Feature params for UKM Service to control thresholds on sources and entries. (Closed)
Patch Set: wording Created 3 years, 10 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/ukm/ukm_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ukm/ukm_service_unittest.cc
diff --git a/components/ukm/ukm_service_unittest.cc b/components/ukm/ukm_service_unittest.cc
index 21f31eefc7b1c881e17233b168cb77097e5e8eb5..8a2782af38c4d9ba014a65d4c9b200a95d49cd89 100644
--- a/components/ukm/ukm_service_unittest.cc
+++ b/components/ukm/ukm_service_unittest.cc
@@ -423,21 +423,51 @@ TEST_F(UkmServiceTest, RecordSessionId) {
ClearPrefs();
UkmService service(&prefs_, &client_);
- EXPECT_EQ(GetPersistedLogCount(), 0);
+ EXPECT_EQ(0, GetPersistedLogCount());
service.Initialize();
task_runner_->RunUntilIdle();
service.EnableRecording();
service.EnableReporting();
- int32_t id = UkmService::GetNewSourceID();
+ auto id = UkmService::GetNewSourceID();
service.UpdateSourceURL(id, GURL("https://google.com/foobar"));
service.Flush();
- EXPECT_EQ(GetPersistedLogCount(), 1);
+ EXPECT_EQ(1, GetPersistedLogCount());
- Report proto_report = GetPersistedReport();
+ auto proto_report = GetPersistedReport();
EXPECT_EQ(should_record_session_id, proto_report.has_session_id());
}
}
+TEST_F(UkmServiceTest, SourceSize) {
+ base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
+ // Set a threshold of number of Sources via Feature Params.
+ ScopedUkmFeatureParams params(base::FeatureList::OVERRIDE_ENABLE_FEATURE,
+ {{"MaxSources", "2"}});
+
+ ClearPrefs();
+ UkmService service(&prefs_, &client_);
+ EXPECT_EQ(0, GetPersistedLogCount());
+ service.Initialize();
+ task_runner_->RunUntilIdle();
+ service.EnableRecording();
+ service.EnableReporting();
+
+ auto id = UkmService::GetNewSourceID();
+ service.UpdateSourceURL(id, GURL("https://google.com/foobar1"));
+ id = UkmService::GetNewSourceID();
+ service.UpdateSourceURL(id, GURL("https://google.com/foobar2"));
+ id = UkmService::GetNewSourceID();
+ service.UpdateSourceURL(id, GURL("https://google.com/foobar3"));
+
+ service.Flush();
+ EXPECT_EQ(1, GetPersistedLogCount());
+
+ auto proto_report = GetPersistedReport();
+ // Note, 2 instead of 3 sources, since we overrode the max number of sources
+ // via Feature params.
+ EXPECT_EQ(2, proto_report.sources_size());
+}
+
} // namespace ukm
« no previous file with comments | « components/ukm/ukm_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698