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

Side by Side Diff: chrome/browser/sync/test/integration/single_client_backup_rollback_test.cc

Issue 435463002: Enable rollback by default on trunk (m38). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/profile_sync_service_unittest.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/profile_sync_service.h" 10 #include "chrome/browser/sync/profile_sync_service.h"
(...skipping 25 matching lines...) Expand all
36 class SingleClientBackupRollbackTest : public SyncTest { 36 class SingleClientBackupRollbackTest : public SyncTest {
37 public: 37 public:
38 SingleClientBackupRollbackTest() : SyncTest(SINGLE_CLIENT) {} 38 SingleClientBackupRollbackTest() : SyncTest(SINGLE_CLIENT) {}
39 virtual ~SingleClientBackupRollbackTest() {} 39 virtual ~SingleClientBackupRollbackTest() {}
40 40
41 void DisableBackup() { 41 void DisableBackup() {
42 CommandLine::ForCurrentProcess()->AppendSwitch( 42 CommandLine::ForCurrentProcess()->AppendSwitch(
43 switches::kSyncDisableBackup); 43 switches::kSyncDisableBackup);
44 } 44 }
45 45
46 void EnableRollback() { 46 void DisableRollback() {
47 CommandLine::ForCurrentProcess()->AppendSwitch( 47 CommandLine::ForCurrentProcess()->AppendSwitch(
48 switches::kSyncEnableRollback); 48 switches::kSyncDisableRollback);
49 } 49 }
50 50
51 base::Time GetBackupDbLastModified() { 51 base::Time GetBackupDbLastModified() {
52 base::RunLoop run_loop; 52 base::RunLoop run_loop;
53 53
54 base::Time backup_time; 54 base::Time backup_time;
55 syncer::CheckSyncDbLastModifiedTime( 55 syncer::CheckSyncDbLastModifiedTime(
56 GetProfile(0)->GetPath().Append(FILE_PATH_LITERAL("Sync Data Backup")), 56 GetProfile(0)->GetPath().Append(FILE_PATH_LITERAL("Sync Data Backup")),
57 base::MessageLoopProxy::current(), 57 base::MessageLoopProxy::current(),
58 base::Bind(&SingleClientBackupRollbackTest::CheckDbCallback, 58 base::Bind(&SingleClientBackupRollbackTest::CheckDbCallback,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 ASSERT_EQ(ProfileSyncService::IDLE, GetSyncService(0)->backend_mode()); 128 ASSERT_EQ(ProfileSyncService::IDLE, GetSyncService(0)->backend_mode());
129 } 129 }
130 130
131 #if defined(ENABLE_PRE_SYNC_BACKUP) 131 #if defined(ENABLE_PRE_SYNC_BACKUP)
132 #define MAYBE_TestBackupOnly TestBackupOnly 132 #define MAYBE_TestBackupOnly TestBackupOnly
133 #else 133 #else
134 #define MAYBE_TestBackupOnly DISABLED_TestBackupOnly 134 #define MAYBE_TestBackupOnly DISABLED_TestBackupOnly
135 #endif 135 #endif
136 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, 136 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest,
137 MAYBE_TestBackupOnly) { 137 MAYBE_TestBackupOnly) {
138 DisableRollback();
139
138 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 140 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
139 141
140 // Starting state: 142 // Starting state:
141 // other_node 143 // other_node
142 // -> http://mail.google.com "url0" 144 // -> http://mail.google.com "url0"
143 // -> http://www.nhl.com "url1" 145 // -> http://www.nhl.com "url1"
144 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, "url0", 146 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, "url0",
145 GURL("http://mail.google.com"))); 147 GURL("http://mail.google.com")));
146 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url1", 148 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 1, "url1",
147 GURL("http://www.nhl.com"))); 149 GURL("http://www.nhl.com")));
(...skipping 30 matching lines...) Expand all
178 GetOtherNode(0)->GetChild(0)->url()); 180 GetOtherNode(0)->GetChild(0)->url());
179 } 181 }
180 182
181 #if defined(ENABLE_PRE_SYNC_BACKUP) 183 #if defined(ENABLE_PRE_SYNC_BACKUP)
182 #define MAYBE_TestBackupRollback TestBackupRollback 184 #define MAYBE_TestBackupRollback TestBackupRollback
183 #else 185 #else
184 #define MAYBE_TestBackupRollback DISABLED_TestBackupRollback 186 #define MAYBE_TestBackupRollback DISABLED_TestBackupRollback
185 #endif 187 #endif
186 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, 188 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest,
187 MAYBE_TestBackupRollback) { 189 MAYBE_TestBackupRollback) {
188 EnableRollback();
189
190 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 190 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
191 191
192 // Starting state: 192 // Starting state:
193 // other_node 193 // other_node
194 // -> top 194 // -> top
195 // -> tier1_a 195 // -> tier1_a
196 // -> http://mail.google.com "tier1_a_url0" 196 // -> http://mail.google.com "tier1_a_url0"
197 // -> tier1_b 197 // -> tier1_b
198 // -> http://www.nhl.com "tier1_b_url0" 198 // -> http://www.nhl.com "tier1_b_url0"
199 const BookmarkNode* top = AddFolder(0, GetOtherNode(0), 0, "top"); 199 const BookmarkNode* top = AddFolder(0, GetOtherNode(0), 0, "top");
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 #if defined(ENABLE_PRE_SYNC_BACKUP) 247 #if defined(ENABLE_PRE_SYNC_BACKUP)
248 #define MAYBE_TestPrefBackupRollback TestPrefBackupRollback 248 #define MAYBE_TestPrefBackupRollback TestPrefBackupRollback
249 #else 249 #else
250 #define MAYBE_TestPrefBackupRollback DISABLED_TestPrefBackupRollback 250 #define MAYBE_TestPrefBackupRollback DISABLED_TestPrefBackupRollback
251 #endif 251 #endif
252 // Verify local preferences are not affected by preferences in backup DB under 252 // Verify local preferences are not affected by preferences in backup DB under
253 // backup mode. 253 // backup mode.
254 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, 254 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest,
255 MAYBE_TestPrefBackupRollback) { 255 MAYBE_TestPrefBackupRollback) {
256 EnableRollback();
257
258 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 256 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
259 257
260 preferences_helper::ChangeStringPref(0, prefs::kHomePage, kUrl1); 258 preferences_helper::ChangeStringPref(0, prefs::kHomePage, kUrl1);
261 259
262 BackupModeChecker checker(GetSyncService(0), 260 BackupModeChecker checker(GetSyncService(0),
263 base::TimeDelta::FromSeconds(15)); 261 base::TimeDelta::FromSeconds(15));
264 ASSERT_TRUE(checker.Wait()); 262 ASSERT_TRUE(checker.Wait());
265 263
266 // Shut down backup, then change preference. 264 // Shut down backup, then change preference.
267 GetSyncService(0)->StartStopBackupForTesting(); 265 GetSyncService(0)->StartStopBackupForTesting();
(...skipping 25 matching lines...) Expand all
293 preferences_helper::GetPrefs(0)->GetString(prefs::kHomePage)); 291 preferences_helper::GetPrefs(0)->GetString(prefs::kHomePage));
294 } 292 }
295 293
296 #if defined(ENABLE_PRE_SYNC_BACKUP) 294 #if defined(ENABLE_PRE_SYNC_BACKUP)
297 #define MAYBE_RollbackNoBackup RollbackNoBackup 295 #define MAYBE_RollbackNoBackup RollbackNoBackup
298 #else 296 #else
299 #define MAYBE_RollbackNoBackup DISABLED_RollbackNoBackup 297 #define MAYBE_RollbackNoBackup DISABLED_RollbackNoBackup
300 #endif 298 #endif
301 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, 299 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest,
302 MAYBE_RollbackNoBackup) { 300 MAYBE_RollbackNoBackup) {
303 EnableRollback();
304
305 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 301 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
306 302
307 // Setup sync, wait for its completion, and make sure changes were synced. 303 // Setup sync, wait for its completion, and make sure changes were synced.
308 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 304 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
309 305
310 // Starting state: 306 // Starting state:
311 // other_node 307 // other_node
312 // -> http://mail.google.com "url0" 308 // -> http://mail.google.com "url0"
313 // -> http://www.nhl.com "url1" 309 // -> http://www.nhl.com "url1"
314 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, "url0", 310 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, "url0",
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 GetSyncService(0)->StartStopBackupForTesting(); 354 GetSyncService(0)->StartStopBackupForTesting();
359 GetSyncService(0)->StartStopBackupForTesting(); 355 GetSyncService(0)->StartStopBackupForTesting();
360 ASSERT_TRUE(checker.Wait()); 356 ASSERT_TRUE(checker.Wait());
361 357
362 // Verify bookmarks are unchanged. 358 // Verify bookmarks are unchanged.
363 ASSERT_EQ(3, sub_folder->child_count()); 359 ASSERT_EQ(3, sub_folder->child_count());
364 ASSERT_EQ(GURL(kUrl1), sub_folder->GetChild(0)->url()); 360 ASSERT_EQ(GURL(kUrl1), sub_folder->GetChild(0)->url());
365 ASSERT_EQ(GURL(kUrl2), sub_folder->GetChild(1)->url()); 361 ASSERT_EQ(GURL(kUrl2), sub_folder->GetChild(1)->url());
366 ASSERT_EQ(GURL(kUrl3), sub_folder->GetChild(2)->url()); 362 ASSERT_EQ(GURL(kUrl3), sub_folder->GetChild(2)->url());
367 } 363 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_unittest.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698