Commit 0387a40e authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Sync polling tests: Set poll interval prefs before starting sync

Setting the prefs has no immediate effect - they're only read during
sync startup (and after that, there are many situations where the values
are overwritten).

https://crrev.com/c/1148392 exposed this as an actual problem; before
that, things just happened to work out.

Bug: 856179
Change-Id: I24a3c8a22c87a128238efb5d0b9dd2ef8a022c71
Reviewed-on: https://chromium-review.googlesource.com/1156600Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579776}
parent 0be6e939
......@@ -108,7 +108,15 @@ IN_PROC_BROWSER_TEST_F(SingleClientPollingSyncTest,
IN_PROC_BROWSER_TEST_F(SingleClientPollingSyncTest,
ShouldPollWhenIntervalExpiredAcrossRestarts) {
base::Time start = base::Time::Now();
ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
SyncPrefs remote_prefs(GetProfile(0)->GetPrefs());
remote_prefs.SetShortPollInterval(base::TimeDelta::FromMinutes(10));
remote_prefs.SetLongPollInterval(base::TimeDelta::FromMinutes(10));
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
// Trigger a sync-cycle.
ASSERT_TRUE(CheckInitialState(0));
ASSERT_TRUE(OpenTab(0, GURL(chrome::kChromeUIHistoryURL)));
......@@ -119,7 +127,6 @@ IN_PROC_BROWSER_TEST_F(SingleClientPollingSyncTest,
.Wait());
// Verify that the last poll time got initialized to a reasonable value.
SyncPrefs remote_prefs(GetProfile(0)->GetPrefs());
EXPECT_THAT(remote_prefs.GetLastPollTime(), Ge(start));
EXPECT_THAT(remote_prefs.GetLastPollTime(), Le(base::Time::Now()));
......@@ -129,8 +136,6 @@ IN_PROC_BROWSER_TEST_F(SingleClientPollingSyncTest,
GetClient(0)->StopSyncService(syncer::SyncService::KEEP_DATA);
// Simulate elapsed time so that the poll interval expired.
remote_prefs.SetShortPollInterval(base::TimeDelta::FromMinutes(10));
remote_prefs.SetLongPollInterval(base::TimeDelta::FromMinutes(10));
remote_prefs.SetLastPollTime(base::Time::Now() -
base::TimeDelta::FromMinutes(11));
ASSERT_TRUE(GetClient(0)->StartSyncService()) << "SetupSync() failed.";
......
......@@ -68,6 +68,13 @@ class SessionCountMatchChecker : public SingleClientStatusChangeChecker {
// data from client 0. That second phase will rely on polling on client 1 to
// receive the update.
IN_PROC_BROWSER_TEST_F(TwoClientPollingSyncTest, ShouldPollOnStartup) {
ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
// Choose larger intervals to verify the poll-on-start logic.
SyncPrefs remote_prefs(GetProfile(1)->GetPrefs());
remote_prefs.SetShortPollInterval(base::TimeDelta::FromMinutes(2));
remote_prefs.SetLongPollInterval(base::TimeDelta::FromMinutes(2));
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
// Phase 1.
......@@ -92,11 +99,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientPollingSyncTest, ShouldPollOnStartup) {
// Now start up the remote client (make sure it should start a poll after
// start-up) and verify it receives the latest changes and the poll cycle
// updated the last-poll-time.
// All data is already there, so we can get it in the first poll. Choose
// larger intervals to verify the poll-on-start logic.
SyncPrefs remote_prefs(GetProfile(1)->GetPrefs());
remote_prefs.SetShortPollInterval(base::TimeDelta::FromMinutes(2));
remote_prefs.SetLongPollInterval(base::TimeDelta::FromMinutes(2));
// All data is already there, so we can get it in the first poll.
base::Time remote_start = base::Time::Now();
base::Time new_last_poll_time = base::Time::Now() -
base::TimeDelta::FromMinutes(2) -
......
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