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

Unified Diff: components/domain_reliability/scheduler_unittest.cc

Issue 272773004: Domain Reliability: Don't clear "upload pending" bit until upload starts (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 6 years, 7 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/domain_reliability/scheduler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/domain_reliability/scheduler_unittest.cc
diff --git a/components/domain_reliability/scheduler_unittest.cc b/components/domain_reliability/scheduler_unittest.cc
index 9eb96a39debf7eec51ef6d3efd93eaf5fa1803c3..f141cfb48c40c0f94a44f77db601f1a4c4554210 100644
--- a/components/domain_reliability/scheduler_unittest.cc
+++ b/components/domain_reliability/scheduler_unittest.cc
@@ -63,6 +63,7 @@ class DomainReliabilitySchedulerTest : public testing::Test {
if (callback_called_ && expected_min == callback_min_
&& expected_max == callback_max_) {
+ callback_called_ = false;
return ::testing::AssertionSuccess();
}
@@ -210,4 +211,40 @@ TEST_F(DomainReliabilitySchedulerTest, DetermineCollectorAtUpload) {
scheduler_->OnUploadComplete(true);
}
+TEST_F(DomainReliabilitySchedulerTest, BeaconWhilePending) {
+ CreateScheduler(1);
+
+ scheduler_->OnBeaconAdded();
+ ASSERT_TRUE(CheckPendingUpload(min_delay(), max_delay()));
+
+ // Second beacon should not call callback again.
+ scheduler_->OnBeaconAdded();
+ ASSERT_TRUE(CheckNoPendingUpload());
+ time_.Advance(min_delay());
+
+ // No pending upload after beacon.
+ ASSERT_TRUE(CheckStartingUpload(0));
+ scheduler_->OnUploadComplete(true);
+ ASSERT_TRUE(CheckNoPendingUpload());
+}
+
+TEST_F(DomainReliabilitySchedulerTest, BeaconWhileUploading) {
+ CreateScheduler(1);
+
+ scheduler_->OnBeaconAdded();
+ ASSERT_TRUE(CheckPendingUpload(min_delay(), max_delay()));
+ time_.Advance(min_delay());
+
+ // If a beacon arrives during the upload, a new upload should be pending.
+ ASSERT_TRUE(CheckStartingUpload(0));
+ scheduler_->OnBeaconAdded();
+ scheduler_->OnUploadComplete(true);
+ ASSERT_TRUE(CheckPendingUpload(min_delay(), max_delay()));
+
+ time_.Advance(min_delay());
+ ASSERT_TRUE(CheckStartingUpload(0));
+ scheduler_->OnUploadComplete(true);
+ ASSERT_TRUE(CheckNoPendingUpload());
+}
+
} // namespace domain_reliability
« no previous file with comments | « components/domain_reliability/scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698