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

Unified Diff: components/ukm/ukm_service_unittest.cc

Issue 2736683003: Handle the case where Purge is called while upload is in progress. (Closed)
Patch Set: Update test 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 | « 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 8a2782af38c4d9ba014a65d4c9b200a95d49cd89..4cfc97d80f1b6571f1da3e18ce88ca1f8b0fabd7 100644
--- a/components/ukm/ukm_service_unittest.cc
+++ b/components/ukm/ukm_service_unittest.cc
@@ -470,4 +470,24 @@ TEST_F(UkmServiceTest, SourceSize) {
EXPECT_EQ(2, proto_report.sources_size());
}
+TEST_F(UkmServiceTest, PurgeMidUpload) {
+ UkmService service(&prefs_, &client_);
+ EXPECT_EQ(GetPersistedLogCount(), 0);
+ service.Initialize();
+ task_runner_->RunUntilIdle();
+ service.EnableRecording();
+ service.EnableReporting();
+ auto id = UkmService::GetNewSourceID();
+ service.UpdateSourceURL(id, GURL("https://google.com/foobar1"));
+ // Should init, generate a log, and start an upload.
+ task_runner_->RunPendingTasks();
+ EXPECT_TRUE(client_.uploader()->is_uploading());
+ // Purge should delete all logs, including the one being sent.
+ service.Purge();
+ // Upload succeeds after logs was deleted.
+ client_.uploader()->CompleteUpload(200);
+ EXPECT_EQ(GetPersistedLogCount(), 0);
+ EXPECT_FALSE(client_.uploader()->is_uploading());
+}
+
} // 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