diff options
-rw-r--r-- | chrome/browser/sync/engine/sync_scheduler.cc | 81 | ||||
-rw-r--r-- | chrome/browser/sync/engine/sync_scheduler.h | 6 | ||||
-rw-r--r-- | chrome/browser/sync/engine/sync_scheduler_unittest.cc | 36 | ||||
-rw-r--r-- | chrome/browser/sync/internal_api/sync_manager.cc | 115 | ||||
-rw-r--r-- | chrome/browser/sync/internal_api/sync_manager.h | 11 | ||||
-rw-r--r-- | chrome/browser/sync/internal_api/syncapi_unittest.cc | 15 | ||||
-rw-r--r-- | chrome/browser/sync/test/integration/two_client_autofill_sync_test.cc | 44 |
7 files changed, 246 insertions, 62 deletions
diff --git a/chrome/browser/sync/engine/sync_scheduler.cc b/chrome/browser/sync/engine/sync_scheduler.cc index 7bb2d65..241692e 100644 --- a/chrome/browser/sync/engine/sync_scheduler.cc +++ b/chrome/browser/sync/engine/sync_scheduler.cc @@ -453,9 +453,11 @@ void SyncScheduler::ScheduleClearUserData() { // functions, too. void SyncScheduler::ScheduleCleanupDisabledTypes() { DCHECK_EQ(MessageLoop::current(), sync_loop_); - ScheduleSyncSessionJob( - TimeDelta::FromSeconds(0), SyncSessionJob::CLEANUP_DISABLED_TYPES, - CreateSyncSession(SyncSourceInfo()), FROM_HERE); + SyncSessionJob job(SyncSessionJob::CLEANUP_DISABLED_TYPES, TimeTicks::Now(), + make_linked_ptr(CreateSyncSession(SyncSourceInfo())), + false, + FROM_HERE); + ScheduleSyncSessionJob(job); } void SyncScheduler::ScheduleNudge( @@ -503,9 +505,12 @@ void SyncScheduler::ScheduleNudgeWithPayloads( void SyncScheduler::ScheduleClearUserDataImpl() { DCHECK_EQ(MessageLoop::current(), sync_loop_); - ScheduleSyncSessionJob( - TimeDelta::FromSeconds(0), SyncSessionJob::CLEAR_USER_DATA, - CreateSyncSession(SyncSourceInfo()), FROM_HERE); + SyncSessionJob job(SyncSessionJob::CLEAR_USER_DATA, TimeTicks::Now(), + make_linked_ptr(CreateSyncSession(SyncSourceInfo())), + false, + FROM_HERE); + + ScheduleSyncSessionJob(job); } void SyncScheduler::ScheduleNudgeImpl( @@ -543,22 +548,18 @@ void SyncScheduler::ScheduleNudgeImpl( SDVLOG(2) << "Coalescing pending nudge"; pending_nudge_->session->Coalesce(*(job.session.get())); - if (!IsBackingOff()) { - SDVLOG(2) << "Dropping a nudge because" - << " we are not in backoff and the job was coalesced"; - return; - } else { - SDVLOG(2) << "Rescheduling pending nudge"; - SyncSession* s = pending_nudge_->session.get(); - job.session.reset(new SyncSession(s->context(), s->delegate(), - s->source(), s->routing_info(), s->workers())); - pending_nudge_.reset(); - } + SDVLOG(2) << "Rescheduling pending nudge"; + SyncSession* s = pending_nudge_->session.get(); + job.session.reset(new SyncSession(s->context(), s->delegate(), + s->source(), s->routing_info(), s->workers())); + + // Choose the start time as the earliest of the 2. + job.scheduled_start = std::min(job.scheduled_start, + pending_nudge_->scheduled_start); + pending_nudge_.reset(); } - // TODO(lipalani) - pass the job itself to ScheduleSyncSessionJob. - ScheduleSyncSessionJob(delay, SyncSessionJob::NUDGE, job.session.release(), - nudge_location); + ScheduleSyncSessionJob(job); } // Helper to extract the routing info and workers corresponding to types in @@ -637,8 +638,11 @@ void SyncScheduler::ScheduleConfigImpl( syncable::ModelTypePayloadMapFromRoutingInfo( routing_info, std::string())), routing_info, workers); - ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), - SyncSessionJob::CONFIGURATION, session, FROM_HERE); + SyncSessionJob job(SyncSessionJob::CONFIGURATION, TimeTicks::Now(), + make_linked_ptr(session), + false, + FROM_HERE); + ScheduleSyncSessionJob(job); } const char* SyncScheduler::GetModeString(SyncScheduler::Mode mode) { @@ -684,25 +688,23 @@ void SyncScheduler::PostDelayedTask( sync_loop_->PostDelayedTask(from_here, task, delay_ms); } -void SyncScheduler::ScheduleSyncSessionJob( - const base::TimeDelta& delay, - SyncSessionJob::SyncSessionJobPurpose purpose, - sessions::SyncSession* session, - const tracked_objects::Location& from_here) { +void SyncScheduler::ScheduleSyncSessionJob(const SyncSessionJob& job) { DCHECK_EQ(MessageLoop::current(), sync_loop_); - SDVLOG_LOC(from_here, 2) + TimeDelta delay = job.scheduled_start - TimeTicks::Now(); + if (delay < TimeDelta::FromMilliseconds(0)) + delay = TimeDelta::FromMilliseconds(0); + SDVLOG_LOC(job.from_here, 2) << "In ScheduleSyncSessionJob with " - << SyncSessionJob::GetPurposeString(purpose) + << SyncSessionJob::GetPurposeString(job.purpose) << " job and " << delay.InMilliseconds() << " ms delay"; - SyncSessionJob job(purpose, TimeTicks::Now() + delay, - make_linked_ptr(session), false, from_here); - if (purpose == SyncSessionJob::NUDGE) { - SDVLOG_LOC(from_here, 2) << "Resetting pending_nudge"; - DCHECK(!pending_nudge_.get() || pending_nudge_->session.get() == session); + if (job.purpose == SyncSessionJob::NUDGE) { + SDVLOG_LOC(job.from_here, 2) << "Resetting pending_nudge"; + DCHECK(!pending_nudge_.get() || pending_nudge_->session.get() == + job.session); pending_nudge_.reset(new SyncSessionJob(job)); } - PostDelayedTask(from_here, "DoSyncSessionJob", + PostDelayedTask(job.from_here, "DoSyncSessionJob", base::Bind(&SyncScheduler::DoSyncSessionJob, weak_ptr_factory_.GetWeakPtr(), job), @@ -1082,8 +1084,13 @@ void SyncScheduler::PollTimerCallback() { syncable::ModelTypePayloadMapFromRoutingInfo(r, std::string()); SyncSourceInfo info(GetUpdatesCallerInfo::PERIODIC, types_with_payloads); SyncSession* s = CreateSyncSession(info); - ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), SyncSessionJob::POLL, s, - FROM_HERE); + + SyncSessionJob job(SyncSessionJob::POLL, TimeTicks::Now(), + make_linked_ptr(s), + false, + FROM_HERE); + + ScheduleSyncSessionJob(job); } void SyncScheduler::Unthrottle() { diff --git a/chrome/browser/sync/engine/sync_scheduler.h b/chrome/browser/sync/engine/sync_scheduler.h index f5617fc..24b9968 100644 --- a/chrome/browser/sync/engine/sync_scheduler.h +++ b/chrome/browser/sync/engine/sync_scheduler.h @@ -255,11 +255,7 @@ class SyncScheduler : public sessions::SyncSession::Delegate, int64 delay_ms); // Helper to assemble a job and post a delayed task to sync. - void ScheduleSyncSessionJob( - const base::TimeDelta& delay, - SyncSessionJob::SyncSessionJobPurpose purpose, - sessions::SyncSession* session, - const tracked_objects::Location& from_here); + void ScheduleSyncSessionJob(const SyncSessionJob& job); // Invoke the Syncer to perform a sync. void DoSyncSessionJob(const SyncSessionJob& job); diff --git a/chrome/browser/sync/engine/sync_scheduler_unittest.cc b/chrome/browser/sync/engine/sync_scheduler_unittest.cc index b44a88c..0bc81f4 100644 --- a/chrome/browser/sync/engine/sync_scheduler_unittest.cc +++ b/chrome/browser/sync/engine/sync_scheduler_unittest.cc @@ -476,6 +476,42 @@ TEST_F(SyncSchedulerTest, NudgeCoalescing) { r2.snapshots[0]->source.updates_source); } +// Test that nudges are coalesced. +TEST_F(SyncSchedulerTest, NudgeCoalescingWithDifferentTimings) { + StartSyncScheduler(SyncScheduler::NORMAL_MODE); + RunLoop(); + + SyncShareRecords r; + EXPECT_CALL(*syncer(), SyncShare(_,_,_)) + .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), + WithArg<0>(RecordSyncShare(&r)))); + syncable::ModelTypeSet types1(syncable::BOOKMARKS), + types2(syncable::AUTOFILL), types3; + + // Create a huge time delay. + TimeDelta delay = TimeDelta::FromDays(1); + + scheduler()->ScheduleNudge( + delay, NUDGE_SOURCE_UNKNOWN, types1, FROM_HERE); + + scheduler()->ScheduleNudge( + zero(), NUDGE_SOURCE_UNKNOWN, types2, FROM_HERE); + + TimeTicks min_time = TimeTicks::Now(); + TimeTicks max_time = TimeTicks::Now() + delay; + + RunLoop(); + + // Make sure the sync has happened. + ASSERT_EQ(1U, r.snapshots.size()); + EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap( + Union(types1, types2), r.snapshots[0]->source.types)); + + // Make sure the sync happened at the right time. + EXPECT_GE(r.times[0], min_time); + EXPECT_LE(r.times[0], max_time); +} + // Test nudge scheduling. TEST_F(SyncSchedulerTest, NudgeWithPayloads) { StartSyncScheduler(SyncScheduler::NORMAL_MODE); diff --git a/chrome/browser/sync/internal_api/sync_manager.cc b/chrome/browser/sync/internal_api/sync_manager.cc index babb6f3..8f5bb82 100644 --- a/chrome/browser/sync/internal_api/sync_manager.cc +++ b/chrome/browser/sync/internal_api/sync_manager.cc @@ -19,6 +19,7 @@ #include "chrome/browser/sync/engine/all_status.h" #include "chrome/browser/sync/engine/net/server_connection_manager.h" #include "chrome/browser/sync/engine/nigori_util.h" +#include "chrome/browser/sync/engine/polling_constants.h" #include "chrome/browser/sync/engine/syncapi_internal.h" #include "chrome/browser/sync/engine/syncer_types.h" #include "chrome/browser/sync/engine/sync_scheduler.h" @@ -120,6 +121,9 @@ GetUpdatesCallerInfo::GetUpdatesSource GetSourceFromReason( namespace sync_api { +const int SyncManager::kDefaultNudgeDelayMilliseconds = 200; +const int SyncManager::kPreferencesNudgeDelayMilliseconds = 2000; + ////////////////////////////////////////////////////////////////////////// // SyncManager's implementation: SyncManager::SyncInternal class SyncManager::SyncInternal @@ -130,8 +134,6 @@ class SyncManager::SyncInternal public SyncEngineEventListener, public ServerConnectionEventListener, public syncable::DirectoryChangeDelegate { - static const int kDefaultNudgeDelayMilliseconds; - static const int kPreferencesNudgeDelayMilliseconds; public: explicit SyncInternal(const std::string& name) : name_(name), @@ -291,7 +293,7 @@ class SyncManager::SyncInternal SyncAPIServerConnectionManager* connection_manager() { return connection_manager_.get(); } - SyncScheduler* scheduler() { return scheduler_.get(); } + SyncScheduler* scheduler() const { return scheduler_.get(); } UserShare* GetUserShare() { DCHECK(initialized_); return &share_; @@ -311,6 +313,8 @@ class SyncManager::SyncInternal const tracked_objects::Location& nudge_location, const ModelType& type); + TimeDelta GetNudgeDelayTimeDelta(const ModelType& model_type); + // See SyncManager::Shutdown* for information. void StopSyncingForShutdown(const base::Closure& callback); void ShutdownOnSyncThread(); @@ -563,8 +567,81 @@ class SyncManager::SyncInternal MessageLoop* const created_on_loop_; }; -const int SyncManager::SyncInternal::kDefaultNudgeDelayMilliseconds = 200; -const int SyncManager::SyncInternal::kPreferencesNudgeDelayMilliseconds = 2000; + +// A class to calculate nudge delays for types. +class NudgeStrategy { + public: + static TimeDelta GetNudgeDelayTimeDelta(const ModelType& model_type, + SyncManager::SyncInternal* core) { + NudgeDelayStrategy delay_type = GetNudgeDelayStrategy(model_type); + return GetNudgeDelayTimeDeltaFromType(delay_type, + model_type, + core); + } + + private: + // Possible types of nudge delay for datatypes. + // Note: These are just hints. If a sync happens then all dirty entries + // would be committed as part of the sync. + enum NudgeDelayStrategy { + // Sync right away. + IMMEDIATE, + + // Sync this change while syncing another change. + ACCOMPANY_ONLY, + + // The datatype does not use one of the predefined wait times but defines + // its own wait time logic for nudge. + CUSTOM, + }; + + static NudgeDelayStrategy GetNudgeDelayStrategy(const ModelType& type) { + switch (type) { + case syncable::AUTOFILL: + case syncable::AUTOFILL_PROFILE: + return ACCOMPANY_ONLY; + case syncable::PREFERENCES: + case syncable::SESSIONS: + return CUSTOM; + default: + return IMMEDIATE; + } + } + + static TimeDelta GetNudgeDelayTimeDeltaFromType( + const NudgeDelayStrategy& delay_type, const ModelType& model_type, + const SyncManager::SyncInternal* core) { + CHECK(core); + TimeDelta delay = TimeDelta::FromMilliseconds( + SyncManager::kDefaultNudgeDelayMilliseconds); + switch (delay_type) { + case IMMEDIATE: + delay = TimeDelta::FromMilliseconds( + SyncManager::kDefaultNudgeDelayMilliseconds); + break; + case ACCOMPANY_ONLY: + delay = TimeDelta::FromSeconds( + browser_sync::kDefaultShortPollIntervalSeconds); + break; + case CUSTOM: + switch (model_type) { + case syncable::PREFERENCES: + delay = TimeDelta::FromMilliseconds( + SyncManager::kPreferencesNudgeDelayMilliseconds); + break; + case syncable::SESSIONS: + delay = core->scheduler()->sessions_commit_delay(); + break; + default: + NOTREACHED(); + } + break; + default: + NOTREACHED(); + } + return delay; + } +}; SyncManager::ChangeDelegate::~ChangeDelegate() {} @@ -1620,6 +1697,11 @@ void SyncManager::SyncInternal::RequestNudge( ModelTypeSet(), location); } +TimeDelta SyncManager::SyncInternal::GetNudgeDelayTimeDelta( + const ModelType& model_type) { + return NudgeStrategy::GetNudgeDelayTimeDelta(model_type, this); +} + void SyncManager::SyncInternal::RequestNudgeForDataType( const tracked_objects::Location& nudge_location, const ModelType& type) { @@ -1627,20 +1709,10 @@ void SyncManager::SyncInternal::RequestNudgeForDataType( NOTREACHED(); return; } - base::TimeDelta nudge_delay; - switch (type) { - case syncable::PREFERENCES: - nudge_delay = - TimeDelta::FromMilliseconds(kPreferencesNudgeDelayMilliseconds); - break; - case syncable::SESSIONS: - nudge_delay = scheduler()->sessions_commit_delay(); - break; - default: - nudge_delay = - TimeDelta::FromMilliseconds(kDefaultNudgeDelayMilliseconds); - break; - } + + base::TimeDelta nudge_delay = NudgeStrategy::GetNudgeDelayTimeDelta(type, + this); + syncable::ModelTypeSet types(type); scheduler()->ScheduleNudge(nudge_delay, browser_sync::NUDGE_SOURCE_LOCAL, ModelTypeSet(type), @@ -2071,6 +2143,11 @@ void SyncManager::DoneRefreshNigori(const base::Closure& done_callback, done_callback.Run(); } +TimeDelta SyncManager::GetNudgeDelayTimeDelta( + const ModelType& model_type) { + return data_->GetNudgeDelayTimeDelta(model_type); +} + syncable::ModelTypeSet SyncManager::GetEncryptedDataTypesForTest() const { ReadTransaction trans(FROM_HERE, GetUserShare()); return GetEncryptedTypes(&trans); diff --git a/chrome/browser/sync/internal_api/sync_manager.h b/chrome/browser/sync/internal_api/sync_manager.h index 321a6c6..cc0e462 100644 --- a/chrome/browser/sync/internal_api/sync_manager.h +++ b/chrome/browser/sync/internal_api/sync_manager.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/callback_forward.h" +#include "base/time.h" #include "base/threading/thread_checker.h" #include "chrome/browser/sync/internal_api/change_record.h" #include "chrome/browser/sync/internal_api/configure_reason.h" @@ -56,6 +57,7 @@ enum PassphraseRequiredReason { // was unsuccessful. }; + // Contains everything needed to talk to and identify a user account. struct SyncCredentials { std::string email; @@ -580,7 +582,16 @@ class SyncManager { void TriggerOnIncomingNotificationForTest( syncable::ModelTypeSet model_types); + static const int kDefaultNudgeDelayMilliseconds; + static const int kPreferencesNudgeDelayMilliseconds; + static const int kPiggybackNudgeDelay; + private: + FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); + + // For unit tests. + base::TimeDelta GetNudgeDelayTimeDelta(const syncable::ModelType& model_type); + base::ThreadChecker thread_checker_; // Internal callback of RefreshNigori. diff --git a/chrome/browser/sync/internal_api/syncapi_unittest.cc b/chrome/browser/sync/internal_api/syncapi_unittest.cc index b761a96..53a6521 100644 --- a/chrome/browser/sync/internal_api/syncapi_unittest.cc +++ b/chrome/browser/sync/internal_api/syncapi_unittest.cc @@ -25,6 +25,7 @@ #include "chrome/browser/password_manager/encryptor.h" #include "chrome/browser/sync/engine/model_safe_worker.h" #include "chrome/browser/sync/engine/nigori_util.h" +#include "chrome/browser/sync/engine/polling_constants.h" #include "chrome/browser/sync/engine/syncapi_internal.h" #include "chrome/browser/sync/internal_api/change_record.h" #include "chrome/browser/sync/internal_api/http_post_provider_factory.h" @@ -1534,6 +1535,20 @@ TEST_F(SyncManagerTest, SetPassphraseWithEmptyPasswordNode) { } } +TEST_F(SyncManagerTest, NudgeDelayTest) { + EXPECT_EQ(sync_manager_.GetNudgeDelayTimeDelta(syncable::BOOKMARKS), + base::TimeDelta::FromMilliseconds( + SyncManager::kDefaultNudgeDelayMilliseconds)); + + EXPECT_EQ(sync_manager_.GetNudgeDelayTimeDelta(syncable::AUTOFILL), + base::TimeDelta::FromSeconds( + browser_sync::kDefaultShortPollIntervalSeconds)); + + EXPECT_EQ(sync_manager_.GetNudgeDelayTimeDelta(syncable::PREFERENCES), + base::TimeDelta::FromMilliseconds( + SyncManager::kPreferencesNudgeDelayMilliseconds)); +} + // Friended by WriteNode, so can't be in an anonymouse namespace. TEST_F(SyncManagerTest, EncryptBookmarksWithLegacyData) { EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); diff --git a/chrome/browser/sync/test/integration/two_client_autofill_sync_test.cc b/chrome/browser/sync/test/integration/two_client_autofill_sync_test.cc index ebe6e535..f542c4a 100644 --- a/chrome/browser/sync/test/integration/two_client_autofill_sync_test.cc +++ b/chrome/browser/sync/test/integration/two_client_autofill_sync_test.cc @@ -6,6 +6,7 @@ #include "chrome/browser/autofill/autofill_profile.h" #include "chrome/browser/sync/profile_sync_service_harness.h" #include "chrome/browser/sync/test/integration/autofill_helper.h" +#include "chrome/browser/sync/test/integration/bookmarks_helper.h" #include "chrome/browser/sync/test/integration/sync_test.h" #include "chrome/browser/webdata/autofill_entry.h" #include "chrome/browser/webdata/autofill_table.h" @@ -24,13 +25,25 @@ using autofill_helper::PROFILE_NULL; using autofill_helper::RemoveKey; using autofill_helper::RemoveProfile; using autofill_helper::UpdateProfile; +using bookmarks_helper::AddFolder; +using bookmarks_helper::AddURL; +using bookmarks_helper::IndexedURL; +using bookmarks_helper::IndexedURLTitle; class TwoClientAutofillSyncTest : public SyncTest { public: - TwoClientAutofillSyncTest() : SyncTest(TWO_CLIENT) {} + TwoClientAutofillSyncTest() : SyncTest(TWO_CLIENT) { count = 0; } virtual ~TwoClientAutofillSyncTest() {} + // We do this so as to make a change that will trigger the autofill to sync. + // By default autofill does not sync unless there is some other change. + void MakeABookmarkChange(int profile) { + ASSERT_TRUE( + AddURL(profile, IndexedURLTitle(count), GURL(IndexedURL(count)))); + ++count; + } private: + int count; DISALLOW_COPY_AND_ASSIGN(TwoClientAutofillSyncTest); }; @@ -42,6 +55,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, FLAKY_WebDataServiceSanity) { std::set<AutofillKey> keys; keys.insert(AutofillKey("name0", "value0")); AddKeys(0, keys); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(KeysMatch(0, 1)); ASSERT_EQ(1U, GetAllKeys(0).size()); @@ -50,6 +64,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, FLAKY_WebDataServiceSanity) { keys.clear(); keys.insert(AutofillKey("name1", "value1-0")); AddKeys(1, keys); + MakeABookmarkChange(1); ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); ASSERT_TRUE(KeysMatch(0, 1)); ASSERT_EQ(2U, GetAllKeys(0).size()); @@ -58,12 +73,14 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, FLAKY_WebDataServiceSanity) { keys.clear(); keys.insert(AutofillKey("name1", "value1-1")); AddKeys(0, keys); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(KeysMatch(0, 1)); ASSERT_EQ(3U, GetAllKeys(0).size()); // Client1 removes a key. RemoveKey(1, AutofillKey("name1", "value1-0")); + MakeABookmarkChange(1); ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); ASSERT_TRUE(KeysMatch(0, 1)); ASSERT_EQ(2U, GetAllKeys(0).size()); @@ -71,6 +88,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, FLAKY_WebDataServiceSanity) { // Client0 removes the rest. RemoveKey(0, AutofillKey("name0", "value0")); RemoveKey(0, AutofillKey("name1", "value1-1")); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(KeysMatch(0, 1)); ASSERT_EQ(0U, GetAllKeys(0).size()); @@ -131,24 +149,28 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, // Client0 adds a profile. AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); // Client1 adds a profile. AddProfile(1, CreateAutofillProfile(PROFILE_MARION)); + MakeABookmarkChange(1); ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(2U, GetAllProfiles(0).size()); // Client0 adds the same profile. AddProfile(0, CreateAutofillProfile(PROFILE_MARION)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(2U, GetAllProfiles(0).size()); // Client1 removes a profile. RemoveProfile(1, GetAllProfiles(1)[0]->guid()); + MakeABookmarkChange(1); ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); @@ -158,12 +180,14 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, GetAllProfiles(0)[0]->guid(), AutofillType(NAME_FIRST), ASCIIToUTF16("Bart")); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); // Client1 removes remaining profile. RemoveProfile(1, GetAllProfiles(1)[0]->guid()); + MakeABookmarkChange(1); ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(0U, GetAllProfiles(0).size()); @@ -212,6 +236,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddProfile) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); @@ -224,6 +249,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddMultipleProfiles) { AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); AddProfile(0, CreateAutofillProfile(PROFILE_MARION)); AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(3U, GetAllProfiles(0).size()); @@ -234,11 +260,13 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DeleteProfile) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); RemoveProfile(1, GetAllProfiles(1)[0]->guid()); + MakeABookmarkChange(1); ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(0U, GetAllProfiles(0).size()); @@ -262,6 +290,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, UpdateFields) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); @@ -274,6 +303,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, UpdateFields) { GetAllProfiles(0)[0]->guid(), AutofillType(EMAIL_ADDRESS), ASCIIToUTF16("grrrl@TV.com")); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); @@ -284,6 +314,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ConflictingFields) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); @@ -291,10 +322,12 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ConflictingFields) { GetAllProfiles(0)[0]->guid(), AutofillType(NAME_FIRST), ASCIIToUTF16("Lisa")); + MakeABookmarkChange(0); UpdateProfile(1, GetAllProfiles(1)[0]->guid(), AutofillType(NAME_FIRST), ASCIIToUTF16("Bart")); + MakeABookmarkChange(1); ASSERT_TRUE(AwaitQuiescence()); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); @@ -305,18 +338,21 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DisableAutofill) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncable::AUTOFILL)); AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER)); + MakeABookmarkChange(0); ASSERT_TRUE(AwaitQuiescence()); ASSERT_FALSE(ProfilesMatch(0, 1)); ASSERT_EQ(2U, GetAllProfiles(0).size()); ASSERT_EQ(1U, GetAllProfiles(1).size()); ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncable::AUTOFILL)); + MakeABookmarkChange(0); ASSERT_TRUE(AwaitQuiescence()); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(2U, GetAllProfiles(0).size()); @@ -327,12 +363,14 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DisableSync) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Added a profile.")); ASSERT_FALSE(ProfilesMatch(0, 1)); ASSERT_EQ(2U, GetAllProfiles(0).size()); @@ -349,6 +387,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MaxLength) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); @@ -371,6 +410,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MaxLength) { AutofillType(ADDRESS_HOME_LINE1), max_length_string); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); } @@ -379,6 +419,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ExceedsMaxLength) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_TRUE(ProfilesMatch(0, 1)); ASSERT_EQ(1U, GetAllProfiles(0).size()); @@ -401,6 +442,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ExceedsMaxLength) { AutofillType(ADDRESS_HOME_LINE1), exceeds_max_length_string); + MakeABookmarkChange(0); ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); ASSERT_FALSE(ProfilesMatch(0, 1)); } |