summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 19:50:11 +0000
committerrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 19:50:11 +0000
commitbb415723ffe8794f16c6639738066061d4f97288 (patch)
treece031742b1d0267c8512e99e4fef406764c9cd32 /chrome/test
parent1e72e6a35f909e87837d208f3534908788337d06 (diff)
downloadchromium_src-bb415723ffe8794f16c6639738066061d4f97288.zip
chromium_src-bb415723ffe8794f16c6639738066061d4f97288.tar.gz
chromium_src-bb415723ffe8794f16c6639738066061d4f97288.tar.bz2
Add methods to ProfileSyncServiceTestHarness to enable / disable sync for datatypes.
Some sync integration tests require functionality to enable or disable sync for a given datatype. BUG=55772,55650 TEST=sync_integration_tests Review URL: http://codereview.chromium.org/3390007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59700 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/live_sync/profile_sync_service_test_harness.cc59
-rw-r--r--chrome/test/live_sync/profile_sync_service_test_harness.h9
-rw-r--r--chrome/test/live_sync/two_client_live_preferences_sync_test.cc42
3 files changed, 84 insertions, 26 deletions
diff --git a/chrome/test/live_sync/profile_sync_service_test_harness.cc b/chrome/test/live_sync/profile_sync_service_test_harness.cc
index 541403b..dbf3ef1 100644
--- a/chrome/test/live_sync/profile_sync_service_test_harness.cc
+++ b/chrome/test/live_sync/profile_sync_service_test_harness.cc
@@ -305,12 +305,12 @@ bool ProfileSyncServiceTestHarness::WaitForServiceInit() {
}
// Choose datatypes to be synced.
- syncable::ModelTypeSet set;
+ syncable::ModelTypeSet synced_datatypes;
for (int i = syncable::FIRST_REAL_MODEL_TYPE;
i < syncable::MODEL_TYPE_COUNT; ++i) {
- set.insert(syncable::ModelTypeFromInt(i));
+ synced_datatypes.insert(syncable::ModelTypeFromInt(i));
}
- service()->OnUserChoseDatatypes(true, set);
+ service()->OnUserChoseDatatypes(true, synced_datatypes);
// Wait for initial sync cycle to complete.
EXPECT_EQ(wait_state_, WAITING_FOR_INITIAL_SYNC);
@@ -351,6 +351,59 @@ const SyncSessionSnapshot*
return NULL;
}
+void ProfileSyncServiceTestHarness::EnableSyncForDatatype(
+ syncable::ModelType datatype) {
+ syncable::ModelTypeSet synced_datatypes;
+ EXPECT_FALSE(service() == NULL)
+ << "EnableSyncForDatatype(): service() is null.";
+ service()->GetPreferredDataTypes(&synced_datatypes);
+ syncable::ModelTypeSet::iterator it = synced_datatypes.find(
+ syncable::ModelTypeFromInt(datatype));
+ if (it == synced_datatypes.end()) {
+ synced_datatypes.insert(syncable::ModelTypeFromInt(datatype));
+ service()->OnUserChoseDatatypes(false, synced_datatypes);
+ AwaitSyncCycleCompletion("Waiting for datatype configuration.");
+ LOG(INFO) << "EnableSyncForDatatype(): Enabled sync for datatype "
+ << syncable::ModelTypeToString(datatype) << ".";
+ } else {
+ LOG(INFO) << "EnableSyncForDatatype(): Sync already enabled for datatype "
+ << syncable::ModelTypeToString(datatype) << ".";
+ }
+}
+
+void ProfileSyncServiceTestHarness::DisableSyncForDatatype(
+ syncable::ModelType datatype) {
+ syncable::ModelTypeSet synced_datatypes;
+ EXPECT_FALSE(service() == NULL)
+ << "DisableSyncForDatatype(): service() is null.";
+ service()->GetPreferredDataTypes(&synced_datatypes);
+ syncable::ModelTypeSet::iterator it = synced_datatypes.find(
+ syncable::ModelTypeFromInt(datatype));
+ if (it != synced_datatypes.end()) {
+ synced_datatypes.erase(it);
+ service()->OnUserChoseDatatypes(false, synced_datatypes);
+ AwaitSyncCycleCompletion("Waiting for datatype configuration.");
+ LOG(INFO) << "DisableSyncForDatatype(): Disabled sync for datatype "
+ << syncable::ModelTypeToString(datatype) << ".";
+ } else {
+ LOG(INFO) << "DisableSyncForDatatype(): Sync already disabled for datatype "
+ << syncable::ModelTypeToString(datatype) << ".";
+ }
+}
+
+void ProfileSyncServiceTestHarness::EnableSyncForAllDatatypes() {
+ syncable::ModelTypeSet synced_datatypes;
+ for (int i = syncable::FIRST_REAL_MODEL_TYPE;
+ i < syncable::MODEL_TYPE_COUNT; ++i) {
+ synced_datatypes.insert(syncable::ModelTypeFromInt(i));
+ }
+ EXPECT_FALSE(service() == NULL)
+ << "EnableSyncForAllDatatypes(): service() is null.";
+ service()->OnUserChoseDatatypes(true, synced_datatypes);
+ AwaitSyncCycleCompletion("Waiting for datatype configuration.");
+ LOG(INFO) << "EnableSyncForAllDatatypes(): Enabled sync for all datatypes.";
+}
+
int64 ProfileSyncServiceTestHarness::GetUpdatedTimestamp() {
const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
EXPECT_FALSE(snap == NULL) << "GetUpdatedTimestamp(): Sync snapshot is NULL.";
diff --git a/chrome/test/live_sync/profile_sync_service_test_harness.h b/chrome/test/live_sync/profile_sync_service_test_harness.h
index e9c50ea..a523c68 100644
--- a/chrome/test/live_sync/profile_sync_service_test_harness.h
+++ b/chrome/test/live_sync/profile_sync_service_test_harness.h
@@ -75,6 +75,15 @@ class ProfileSyncServiceTestHarness : public ProfileSyncServiceObserver {
// See ProfileSyncService::ShouldPushChanges().
bool ServiceIsPushingChanges() { return service_->ShouldPushChanges(); }
+ // Enables sync for a particular sync datatype.
+ void EnableSyncForDatatype(syncable::ModelType datatype);
+
+ // Disables sync for a particular sync datatype.
+ void DisableSyncForDatatype(syncable::ModelType datatype);
+
+ // Enables sync for all sync datatypes.
+ void EnableSyncForAllDatatypes();
+
private:
friend class StateChangeTimeoutEvent;
diff --git a/chrome/test/live_sync/two_client_live_preferences_sync_test.cc b/chrome/test/live_sync/two_client_live_preferences_sync_test.cc
index 37370ac..2d9f936 100644
--- a/chrome/test/live_sync/two_client_live_preferences_sync_test.cc
+++ b/chrome/test/live_sync/two_client_live_preferences_sync_test.cc
@@ -64,36 +64,30 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest,
EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncThemes),
GetPrefs(1)->GetBoolean(prefs::kSyncThemes));
- GetPrefs(0)->SetBoolean(prefs::kKeepEverythingSynced, 0);
- GetPrefs(0)->SetBoolean(prefs::kSyncThemes, 0);
- GetPrefs(1)->SetBoolean(prefs::kKeepEverythingSynced, 1);
- EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ GetClient(0)->DisableSyncForDatatype(syncable::THEMES);
EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kKeepEverythingSynced),
GetPrefs(1)->GetBoolean(prefs::kKeepEverythingSynced));
}
-// TODO(rsimha): Remove FAILS_ prefix after http://crbug.com/55650 is fixed.
-IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest,
- FAILS_kSyncPreferences) {
+IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kSyncPreferences) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncPreferences),
GetPrefs(1)->GetBoolean(prefs::kSyncPreferences));
EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kPasswordManagerEnabled),
GetPrefs(1)->GetBoolean(prefs::kPasswordManagerEnabled));
- GetPrefs(0)->SetBoolean(prefs::kKeepEverythingSynced, 0);
- GetPrefs(0)->SetBoolean(prefs::kSyncPreferences, 0);
+ GetClient(0)->DisableSyncForDatatype(syncable::PREFERENCES);
+
GetPrefs(0)->SetBoolean(prefs::kPasswordManagerEnabled, 1);
GetPrefs(1)->SetBoolean(prefs::kPasswordManagerEnabled, 0);
- EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients()));
EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kPasswordManagerEnabled),
GetPrefs(1)->GetBoolean(prefs::kPasswordManagerEnabled));
}
-IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest,
- SignInDialog) {
+IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, SignInDialog) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kSyncPreferences),
GetPrefs(1)->GetBoolean(prefs::kSyncPreferences));
@@ -108,19 +102,21 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest,
EXPECT_EQ(GetPrefs(0)->GetBoolean(prefs::kKeepEverythingSynced),
GetPrefs(1)->GetBoolean(prefs::kKeepEverythingSynced));
- GetPrefs(0)->SetBoolean(prefs::kKeepEverythingSynced, 0);
- GetPrefs(1)->SetBoolean(prefs::kKeepEverythingSynced, 1);
- GetPrefs(0)->SetBoolean(prefs::kSyncAutofill, 0);
- GetPrefs(1)->SetBoolean(prefs::kSyncAutofill, 1);
- GetPrefs(0)->SetBoolean(prefs::kSyncBookmarks, 0);
- GetPrefs(1)->SetBoolean(prefs::kSyncBookmarks, 1);
- GetPrefs(0)->SetBoolean(prefs::kSyncExtensions, 0);
- GetPrefs(1)->SetBoolean(prefs::kSyncExtensions, 1);
- GetPrefs(0)->SetBoolean(prefs::kSyncThemes, 0);
- GetPrefs(1)->SetBoolean(prefs::kSyncThemes, 1);
+ GetClient(0)->DisableSyncForDatatype(syncable::PREFERENCES);
+ GetClient(1)->EnableSyncForDatatype(syncable::PREFERENCES);
+ GetClient(0)->DisableSyncForDatatype(syncable::AUTOFILL);
+ GetClient(1)->EnableSyncForDatatype(syncable::AUTOFILL);
+ GetClient(0)->DisableSyncForDatatype(syncable::BOOKMARKS);
+ GetClient(1)->EnableSyncForDatatype(syncable::BOOKMARKS);
+ GetClient(0)->DisableSyncForDatatype(syncable::EXTENSIONS);
+ GetClient(1)->EnableSyncForDatatype(syncable::EXTENSIONS);
+ GetClient(0)->DisableSyncForDatatype(syncable::THEMES);
+ GetClient(1)->EnableSyncForDatatype(syncable::THEMES);
- EXPECT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients()));
+ EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncPreferences),
+ GetPrefs(1)->GetBoolean(prefs::kSyncPreferences));
EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncAutofill),
GetPrefs(1)->GetBoolean(prefs::kSyncAutofill));
EXPECT_NE(GetPrefs(0)->GetBoolean(prefs::kSyncBookmarks),