Fix OmahaRequestActionTest when the device time is very old.
Changed OmahaRequestAction to use the ClockInterface instead so that
it can be faked in the unittests.
Test: ./update_engine_unittests
Bug: 29577823
Change-Id: If243aa3beae973606ace226a7845ca5a6b02225f
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index a9143a8..3d2dac1 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -1224,7 +1224,7 @@
return kWallClockWaitDoneAndUpdateCheckWaitNotRequired;
}
} else {
- update_first_seen_at = Time::Now();
+ update_first_seen_at = system_state_->clock()->GetWallclockTime();
update_first_seen_at_int = update_first_seen_at.ToInternalValue();
if (system_state_->prefs()->SetInt64(kPrefsUpdateFirstSeenAt,
update_first_seen_at_int)) {
@@ -1241,9 +1241,10 @@
}
}
- TimeDelta elapsed_time = Time::Now() - update_first_seen_at;
- TimeDelta max_scatter_period = TimeDelta::FromDays(
- output_object->max_days_to_scatter);
+ TimeDelta elapsed_time =
+ system_state_->clock()->GetWallclockTime() - update_first_seen_at;
+ TimeDelta max_scatter_period =
+ TimeDelta::FromDays(output_object->max_days_to_scatter);
LOG(INFO) << "Waiting Period = "
<< utils::FormatSecs(params_->waiting_period().InSeconds())