Commit 760d9d15 authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Fix HistoryCounterTest flakiness around DST changes

The test fails when changing between winter/summer time due to days
being longer/shorter than 24h. RevertTimeInDays assumes that every day
has 24h. To fix the issue the test always runs on a fixed timestamp.

Bug: 1144634
Change-Id: I55f94df979c61a3e965885eb577bc05d41612725
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523032Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825290}
parent 9290b6b5
......@@ -51,6 +51,8 @@ class HistoryCounterTest : public InProcessBrowserTest {
return time_;
}
void SetTime(base::Time time) { time_ = time; }
void RevertTimeInDays(int days) {
time_ -= base::TimeDelta::FromDays(days);
}
......@@ -126,6 +128,11 @@ class HistoryCounterTest : public InProcessBrowserTest {
// Tests that the counter considers duplicate visits from the same day
// to be a single item.
IN_PROC_BROWSER_TEST_F(HistoryCounterTest, DuplicateVisits) {
// Start at a fixed day to avoid flakiness due to timezone changes.
base::Time time;
ASSERT_TRUE(base::Time::FromUTCString("1 Jul 2020 10:00 GMT", &time));
SetTime(time);
AddVisit("https://www.google.com"); // 1 item
AddVisit("https://www.google.com");
AddVisit("https://www.chrome.com"); // 2 items
......
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