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

Unified Diff: components/ukm/ukm_service_unittest.cc

Issue 2756773002: Ensure UKM only sends URLs under a specific length (currently 2K). (Closed)
Patch Set: merge 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/ukm/ukm_source.cc » ('j') | 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 b7b1d61a5fc0b2e284516cf48e0c62cf44d46aab..b17286e5a9d7bdea6f236d9e2f8e560368573341 100644
--- a/components/ukm/ukm_service_unittest.cc
+++ b/components/ukm/ukm_service_unittest.cc
@@ -541,4 +541,27 @@ TEST_F(UkmServiceTest, WhitelistEntryTest) {
EXPECT_EQ(base::HashMetricName("EntryB"), proto_entry_b.event_hash());
}
+TEST_F(UkmServiceTest, SourceURLLength) {
+ UkmService service(&prefs_, &client_);
+ EXPECT_EQ(0, GetPersistedLogCount());
+ service.Initialize();
+ task_runner_->RunUntilIdle();
+ service.EnableRecording();
+ service.EnableReporting();
+
+ auto id = UkmService::GetNewSourceID();
+
+ // This URL is too long to be recorded fully.
+ const std::string long_string = "https://" + std::string(10000, 'a');
+ service.UpdateSourceURL(id, GURL(long_string));
+
+ service.Flush();
+ EXPECT_EQ(1, GetPersistedLogCount());
+
+ auto proto_report = GetPersistedReport();
+ ASSERT_EQ(1, proto_report.sources_size());
+ const Source& proto_source = proto_report.sources(0);
+ EXPECT_EQ("URLTooLong", proto_source.url());
+}
+
} // namespace ukm
« no previous file with comments | « no previous file | components/ukm/ukm_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698