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

Unified Diff: components/ukm/ukm_service_unittest.cc

Issue 2727013002: Add UKM API GetNewSourceID() (Closed)
Patch Set: fix comment 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 d5226068a42ecee5f997b4fd02a806b5bb39bd62..3ec67ce19318151a0e4d3377ccc20f3e21c85a62 100644
--- a/components/ukm/ukm_service_unittest.cc
+++ b/components/ukm/ukm_service_unittest.cc
@@ -100,7 +100,7 @@ TEST_F(UkmServiceTest, PersistAndPurge) {
service.EnableRecording();
service.EnableReporting();
- int32_t id = 1;
+ int32_t id = UkmService::GetNewSourceID();
service.UpdateSourceURL(id, GURL("https://google.com/foobar"));
// Should init, generate a log, and start an upload for source.
task_runner_->RunPendingTasks();
@@ -125,7 +125,7 @@ TEST_F(UkmServiceTest, SourceSerialization) {
service.EnableRecording();
service.EnableReporting();
- int32_t id = 1;
+ int32_t id = UkmService::GetNewSourceID();
service.UpdateSourceURL(id, GURL("https://google.com/foobar"));
service.Flush();
@@ -147,7 +147,7 @@ TEST_F(UkmServiceTest, EntryBuilderAndSerialization) {
service.EnableRecording();
service.EnableReporting();
- int32_t id = 1;
+ int32_t id = UkmService::GetNewSourceID();
service.UpdateSourceURL(id, GURL("https://google.com/foobar"));
{
std::unique_ptr<UkmEntryBuilder> foo_builder =
@@ -210,7 +210,7 @@ TEST_F(UkmServiceTest, AddEntryOnlyWithNonEmptyMetrics) {
service.EnableRecording();
service.EnableReporting();
- int32_t id = 1;
+ int32_t id = UkmService::GetNewSourceID();
service.UpdateSourceURL(id, GURL("https://google.com/foobar"));
{
@@ -249,7 +249,7 @@ TEST_F(UkmServiceTest, MetricsProviderTest) {
service.EnableRecording();
service.EnableReporting();
- int32_t id = 1;
+ int32_t id = UkmService::GetNewSourceID();
service.UpdateSourceURL(id, GURL("https://google.com/foobar"));
{
std::unique_ptr<UkmEntryBuilder> builder =
@@ -281,7 +281,7 @@ TEST_F(UkmServiceTest, LogsUploadedOnlyWhenHavingSourcesOrEntries) {
service.Flush();
EXPECT_EQ(GetPersistedLogCount(), 0);
- int32_t id = 1;
+ int32_t id = UkmService::GetNewSourceID();
service.UpdateSourceURL(id, GURL("https://google.com/foobar"));
// Includes a Source, so will persist.
service.Flush();
@@ -311,4 +311,13 @@ TEST_F(UkmServiceTest, LogsUploadedOnlyWhenHavingSourcesOrEntries) {
EXPECT_EQ(GetPersistedLogCount(), 3);
}
+TEST_F(UkmServiceTest, GetNewSourceID) {
+ int32_t id1 = UkmService::GetNewSourceID();
+ int32_t id2 = UkmService::GetNewSourceID();
+ int32_t id3 = UkmService::GetNewSourceID();
+ EXPECT_NE(id1, id2);
+ EXPECT_NE(id1, id3);
+ EXPECT_NE(id2, id3);
+}
+
} // 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