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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « components/ukm/ukm_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 463
464 service.Flush(); 464 service.Flush();
465 EXPECT_EQ(1, GetPersistedLogCount()); 465 EXPECT_EQ(1, GetPersistedLogCount());
466 466
467 auto proto_report = GetPersistedReport(); 467 auto proto_report = GetPersistedReport();
468 // Note, 2 instead of 3 sources, since we overrode the max number of sources 468 // Note, 2 instead of 3 sources, since we overrode the max number of sources
469 // via Feature params. 469 // via Feature params.
470 EXPECT_EQ(2, proto_report.sources_size()); 470 EXPECT_EQ(2, proto_report.sources_size());
471 } 471 }
472 472
473 TEST_F(UkmServiceTest, PurgeMidUpload) {
474 UkmService service(&prefs_, &client_);
475 EXPECT_EQ(GetPersistedLogCount(), 0);
476 service.Initialize();
477 task_runner_->RunUntilIdle();
478 service.EnableRecording();
479 service.EnableReporting();
480 auto id = UkmService::GetNewSourceID();
481 service.UpdateSourceURL(id, GURL("https://google.com/foobar1"));
482 // Should init, generate a log, and start an upload.
483 task_runner_->RunPendingTasks();
484 EXPECT_TRUE(client_.uploader()->is_uploading());
485 // Purge should delete all logs, including the one being sent.
486 service.Purge();
487 // Upload succeeds after logs was deleted.
488 client_.uploader()->CompleteUpload(200);
489 EXPECT_EQ(GetPersistedLogCount(), 0);
490 EXPECT_FALSE(client_.uploader()->is_uploading());
491 }
492
473 } // namespace ukm 493 } // namespace ukm
OLDNEW
« 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