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

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

Issue 367063005: Use new sync backup DB if settings are reset to avoid undoing reset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months 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_unittest.cc
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index 44361a292e81790ecb4ac889dc48e86c7e3e5ac0..387345c534441359c421fb7387e2ff3e4c5f77ae 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -7,6 +7,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/invalidation/fake_invalidation_service.h"
@@ -492,10 +493,6 @@ TEST_F(ProfileSyncServiceTest, GetSyncTokenStatus) {
}
#if defined(ENABLE_PRE_SYNC_BACKUP)
-void QuitLoop() {
- base::MessageLoop::current()->Quit();
-}
-
TEST_F(ProfileSyncServiceTest, StartBackup) {
CreateServiceWithoutSignIn();
ExpectDataTypeManagerCreation(1);
@@ -503,10 +500,11 @@ TEST_F(ProfileSyncServiceTest, StartBackup) {
ExpectSyncBackendHostCreationCollectDeleteDir(1, &delete_dir_param);
Initialize();
EXPECT_EQ(ProfileSyncService::IDLE, service()->backend_mode());
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE, base::Bind(&QuitLoop),
+ FROM_HERE, run_loop.QuitClosure(),
base::TimeDelta::FromMilliseconds(100));
- base::MessageLoop::current()->Run();
+ run_loop.Run();
EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode());
EXPECT_EQ(1u, delete_dir_param.size());
@@ -521,7 +519,6 @@ TEST_F(ProfileSyncServiceTest, BackupAfterSyncDisabled) {
ExpectSyncBackendHostCreationCollectDeleteDir(2, &delete_dir_param);
IssueTestTokens();
Initialize();
- base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&QuitLoop));
EXPECT_TRUE(service()->sync_initialized());
EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode());
@@ -556,7 +553,6 @@ TEST_F(ProfileSyncServiceTest, RollbackThenBackup) {
ExpectSyncBackendHostCreationCollectDeleteDir(3, &delete_dir_param);
IssueTestTokens();
Initialize();
- base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&QuitLoop));
EXPECT_TRUE(service()->sync_initialized());
EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode());
@@ -587,6 +583,32 @@ TEST_F(ProfileSyncServiceTest, RollbackThenBackup) {
EXPECT_FALSE(delete_dir_param[1]);
EXPECT_TRUE(delete_dir_param[2]);
}
+
+TEST_F(ProfileSyncServiceTest, StartNewBackupDbOnSettingsReset) {
+ CreateServiceWithoutSignIn();
+ ExpectDataTypeManagerCreation(1);
+ std::vector<bool> delete_dir_param;
+ ExpectSyncBackendHostCreationCollectDeleteDir(1, &delete_dir_param);
+ Initialize();
+ EXPECT_EQ(ProfileSyncService::IDLE, service()->backend_mode());
+
+ // Set reset time to pretend settings reset happened.
+ profile()->GetPrefs()->SetString(
+ prefs::kPreferenceResetTime,
+ base::Int64ToString(base::Time::Now().ToInternalValue()));
+
+ base::RunLoop run_loop;
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, run_loop.QuitClosure(),
+ base::TimeDelta::FromMilliseconds(100));
+ run_loop.Run();
+
+ EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode());
+
+ EXPECT_EQ(1u, delete_dir_param.size());
+ EXPECT_TRUE(delete_dir_param[0]);
+}
+
#endif
TEST_F(ProfileSyncServiceTest, GetSyncServiceURL) {
« 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