Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1659)

Unified Diff: chrome/browser/sync/profile_sync_service_startup_unittest.cc

Issue 11365041: [Sync] Re-reland fix for bug 154940 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/profile_sync_service_startup_unittest.cc
diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
index 010952535438f6f6aad402090c0d47ad358d0b8c..f38cc5e322919bc9cbb3287fc9250f153e7c8cdc 100644
--- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/sync/glue/data_type_manager_mock.h"
#include "chrome/browser/sync/profile_sync_components_factory_mock.h"
#include "chrome/browser/sync/profile_sync_test_util.h"
+#include "chrome/browser/sync/sync_prefs.h"
#include "chrome/browser/sync/test_profile_sync_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
@@ -268,6 +269,62 @@ TEST_F(ProfileSyncServiceStartupTest, StartNormal) {
service_->Initialize();
}
+// Test that we can recover from a case where a bug in the code resulted in
+// OnUserChoseDatatypes not being properly called and datatype preferences
+// therefore being left unset.
+TEST_F(ProfileSyncServiceStartupTest, StartRecoverDatatypePrefs) {
+ DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
+ EXPECT_CALL(*data_type_manager, Configure(_, _));
+ EXPECT_CALL(*data_type_manager, state()).
+ WillRepeatedly(Return(DataTypeManager::CONFIGURED));
+ EXPECT_CALL(*data_type_manager, Stop()).Times(1);
+
+ EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
+
+ // Clear the datatype preference fields (simulating bug 154940).
+ profile_->GetPrefs()->ClearPref(prefs::kSyncKeepEverythingSynced);
+ syncer::ModelTypeSet user_types = syncer::UserTypes();
+ for (syncer::ModelTypeSet::Iterator iter = user_types.First();
+ iter.Good(); iter.Inc()) {
+ profile_->GetPrefs()->ClearPref(
+ browser_sync::SyncPrefs::GetPrefNameForDataType(iter.Get()));
+ }
+
+ // Pre load the tokens
+ TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
+ GaiaConstants::kSyncService, "sync_token");
+ profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "test_user");
+ service_->Initialize();
+
+ EXPECT_TRUE(profile_->GetPrefs()->GetBoolean(
+ prefs::kSyncKeepEverythingSynced));
+}
+
+// Verify that the recovery of datatype preferences doesn't overwrite a valid
+// case where only bookmarks are enabled.
+TEST_F(ProfileSyncServiceStartupTest, StartDontRecoverDatatypePrefs) {
+ DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
+ EXPECT_CALL(*data_type_manager, Configure(_, _));
+ EXPECT_CALL(*data_type_manager, state()).
+ WillRepeatedly(Return(DataTypeManager::CONFIGURED));
+ EXPECT_CALL(*data_type_manager, Stop()).Times(1);
+
+ EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
+
+ // Explicitly set Keep Everything Synced to false and have only bookmarks
+ // enabled.
+ profile_->GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
+
+ // Pre load the tokens
+ TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
+ GaiaConstants::kSyncService, "sync_token");
+ profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "test_user");
+ service_->Initialize();
+
+ EXPECT_FALSE(profile_->GetPrefs()->GetBoolean(
+ prefs::kSyncKeepEverythingSynced));
+}
+
TEST_F(ProfileSyncServiceStartupTest, ManagedStartup) {
// Disable sync through policy.
profile_->GetPrefs()->SetBoolean(prefs::kSyncManaged, true);
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698