| 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |