Commit cf62dcba authored by Joshua Pawlicki's avatar Joshua Pawlicki Committed by Commit Bot

Fix updaterstate time windows and hour computation.

Bug: 1053815
Change-Id: I221b4d7418610281eb52a38b4eed4791572bc50e
Fixed: 1053815
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071049
Auto-Submit: Joshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744692}
parent c2adfbd6
......@@ -84,13 +84,13 @@ UpdaterState::Attributes UpdaterState::BuildAttributes() const {
std::string UpdaterState::NormalizeTimeDelta(const base::TimeDelta& delta) {
const base::TimeDelta two_weeks = base::TimeDelta::FromDays(14);
const base::TimeDelta two_months = base::TimeDelta::FromDays(60);
const base::TimeDelta two_months = base::TimeDelta::FromDays(56);
std::string val; // Contains the value to return in hours.
if (delta <= two_weeks) {
val = "0";
} else if (two_weeks < delta && delta <= two_months) {
val = "408"; // 2 weeks in hours.
val = "336"; // 2 weeks in hours.
} else {
val = "1344"; // 2*28 days in hours.
}
......
......@@ -75,7 +75,12 @@ TEST_F(UpdaterStateTest, Serialize) {
updater_state.last_autoupdate_started_ =
base::Time::NowFromSystemTime() - base::TimeDelta::FromDays(15);
attributes = updater_state.BuildAttributes();
EXPECT_STREQ("408", attributes.at("laststarted").c_str());
EXPECT_STREQ("336", attributes.at("laststarted").c_str());
updater_state.last_autoupdate_started_ =
base::Time::NowFromSystemTime() - base::TimeDelta::FromDays(58);
attributes = updater_state.BuildAttributes();
EXPECT_STREQ("1344", attributes.at("laststarted").c_str());
updater_state.last_autoupdate_started_ =
base::Time::NowFromSystemTime() - base::TimeDelta::FromDays(90);
......@@ -90,7 +95,7 @@ TEST_F(UpdaterStateTest, Serialize) {
updater_state.last_checked_ =
base::Time::NowFromSystemTime() - base::TimeDelta::FromDays(15);
attributes = updater_state.BuildAttributes();
EXPECT_STREQ("408", attributes.at("lastchecked").c_str());
EXPECT_STREQ("336", attributes.at("lastchecked").c_str());
updater_state.last_checked_ =
base::Time::NowFromSystemTime() - base::TimeDelta::FromDays(90);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment