OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ukm/ukm_service.h" | 5 #include "components/ukm/ukm_service.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 534 |
535 const Entry& proto_entry_a = proto_report.entries(0); | 535 const Entry& proto_entry_a = proto_report.entries(0); |
536 EXPECT_EQ(id, proto_entry_a.source_id()); | 536 EXPECT_EQ(id, proto_entry_a.source_id()); |
537 EXPECT_EQ(base::HashMetricName("EntryA"), proto_entry_a.event_hash()); | 537 EXPECT_EQ(base::HashMetricName("EntryA"), proto_entry_a.event_hash()); |
538 | 538 |
539 const Entry& proto_entry_b = proto_report.entries(1); | 539 const Entry& proto_entry_b = proto_report.entries(1); |
540 EXPECT_EQ(id, proto_entry_b.source_id()); | 540 EXPECT_EQ(id, proto_entry_b.source_id()); |
541 EXPECT_EQ(base::HashMetricName("EntryB"), proto_entry_b.event_hash()); | 541 EXPECT_EQ(base::HashMetricName("EntryB"), proto_entry_b.event_hash()); |
542 } | 542 } |
543 | 543 |
| 544 TEST_F(UkmServiceTest, SourceURLLength) { |
| 545 UkmService service(&prefs_, &client_); |
| 546 EXPECT_EQ(0, GetPersistedLogCount()); |
| 547 service.Initialize(); |
| 548 task_runner_->RunUntilIdle(); |
| 549 service.EnableRecording(); |
| 550 service.EnableReporting(); |
| 551 |
| 552 auto id = UkmService::GetNewSourceID(); |
| 553 |
| 554 // This URL is too long to be recorded fully. |
| 555 const std::string long_string = "https://" + std::string(10000, 'a'); |
| 556 service.UpdateSourceURL(id, GURL(long_string)); |
| 557 |
| 558 service.Flush(); |
| 559 EXPECT_EQ(1, GetPersistedLogCount()); |
| 560 |
| 561 auto proto_report = GetPersistedReport(); |
| 562 ASSERT_EQ(1, proto_report.sources_size()); |
| 563 const Source& proto_source = proto_report.sources(0); |
| 564 EXPECT_EQ("URLTooLong", proto_source.url()); |
| 565 } |
| 566 |
544 } // namespace ukm | 567 } // namespace ukm |
OLD | NEW |