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

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

Issue 374183003: Two fixes regarding to bookmark backup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update test 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sync/internal_api/sync_backup_manager.cc » ('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 "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/sync/profile_sync_service.h" 9 #include "chrome/browser/sync/profile_sync_service.h"
10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
11 #include "chrome/browser/sync/test/integration/preferences_helper.h" 11 #include "chrome/browser/sync/test/integration/preferences_helper.h"
12 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" 12 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
13 #include "chrome/browser/sync/test/integration/sync_test.h" 13 #include "chrome/browser/sync/test/integration/sync_test.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "components/bookmarks/browser/bookmark_model.h" 16 #include "components/bookmarks/browser/bookmark_model.h"
17 #include "sync/test/fake_server/fake_server_verifier.h" 17 #include "sync/test/fake_server/fake_server_verifier.h"
18 18
19 using bookmarks_helper::AddFolder; 19 using bookmarks_helper::AddFolder;
20 using bookmarks_helper::AddURL; 20 using bookmarks_helper::AddURL;
21 using bookmarks_helper::GetOtherNode; 21 using bookmarks_helper::GetOtherNode;
22 using bookmarks_helper::ModelMatchesVerifier; 22 using bookmarks_helper::ModelMatchesVerifier;
23 using bookmarks_helper::Move; 23 using bookmarks_helper::Move;
24 using bookmarks_helper::Remove; 24 using bookmarks_helper::Remove;
25 using sync_integration_test_util::AwaitCommitActivityCompletion; 25 using sync_integration_test_util::AwaitCommitActivityCompletion;
26 26
27 namespace {
28 const char kUrl1[] = "http://www.google.com";
29 const char kUrl2[] = "http://map.google.com";
30 const char kUrl3[] = "http://plus.google.com";
31 } // anonymous namespace
32
27 class SingleClientBackupRollbackTest : public SyncTest { 33 class SingleClientBackupRollbackTest : public SyncTest {
28 public: 34 public:
29 SingleClientBackupRollbackTest() : SyncTest(SINGLE_CLIENT) {} 35 SingleClientBackupRollbackTest() : SyncTest(SINGLE_CLIENT) {}
30 virtual ~SingleClientBackupRollbackTest() {} 36 virtual ~SingleClientBackupRollbackTest() {}
31 37
32 void DisableBackup() { 38 void DisableBackup() {
33 CommandLine::ForCurrentProcess()->AppendSwitch( 39 CommandLine::ForCurrentProcess()->AppendSwitch(
34 switches::kSyncDisableBackup); 40 switches::kSyncDisableBackup);
35 } 41 }
36 42
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 #define MAYBE_TestPrefBackupRollback TestPrefBackupRollback 221 #define MAYBE_TestPrefBackupRollback TestPrefBackupRollback
216 #else 222 #else
217 #define MAYBE_TestPrefBackupRollback DISABLED_TestPrefBackupRollback 223 #define MAYBE_TestPrefBackupRollback DISABLED_TestPrefBackupRollback
218 #endif 224 #endif
219 // Verify local preferences are not affected by preferences in backup DB under 225 // Verify local preferences are not affected by preferences in backup DB under
220 // backup mode. 226 // backup mode.
221 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, 227 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest,
222 MAYBE_TestPrefBackupRollback) { 228 MAYBE_TestPrefBackupRollback) {
223 EnableRollback(); 229 EnableRollback();
224 230
225 const char kUrl1[] = "http://www.google.com";
226 const char kUrl2[] = "http://map.google.com";
227 const char kUrl3[] = "http://plus.google.com";
228
229 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 231 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
230 232
231 preferences_helper::ChangeStringPref(0, prefs::kHomePage, kUrl1); 233 preferences_helper::ChangeStringPref(0, prefs::kHomePage, kUrl1);
232 234
233 BackupModeChecker checker(GetSyncService(0), 235 BackupModeChecker checker(GetSyncService(0),
234 base::TimeDelta::FromSeconds(15)); 236 base::TimeDelta::FromSeconds(15));
235 ASSERT_TRUE(checker.Wait()); 237 ASSERT_TRUE(checker.Wait());
236 238
237 // Shut down backup, then change preference. 239 // Shut down backup, then change preference.
238 GetSyncService(0)->StartStopBackupForTesting(); 240 GetSyncService(0)->StartStopBackupForTesting();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // Wait for sync to switch to backup mode after finishing rollback. 301 // Wait for sync to switch to backup mode after finishing rollback.
300 BackupModeChecker checker(GetSyncService(0), 302 BackupModeChecker checker(GetSyncService(0),
301 base::TimeDelta::FromSeconds(15)); 303 base::TimeDelta::FromSeconds(15));
302 ASSERT_TRUE(checker.Wait()); 304 ASSERT_TRUE(checker.Wait());
303 305
304 // Without backup DB, bookmarks added during sync shouldn't be removed. 306 // Without backup DB, bookmarks added during sync shouldn't be removed.
305 ASSERT_EQ(1, GetOtherNode(0)->child_count()); 307 ASSERT_EQ(1, GetOtherNode(0)->child_count());
306 ASSERT_EQ(GURL("http://www.nhl.com"), 308 ASSERT_EQ(GURL("http://www.nhl.com"),
307 GetOtherNode(0)->GetChild(0)->url()); 309 GetOtherNode(0)->GetChild(0)->url());
308 } 310 }
311
312 #if defined(ENABLE_PRE_SYNC_BACKUP)
313 #define MAYBE_DontChangeBookmarkOrdering DontChangeBookmarkOrdering
314 #else
315 #define MAYBE_DontChangeBookmarkOrdering DISABLED_DontChangeBookmarkOrdering
316 #endif
317 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest,
318 MAYBE_DontChangeBookmarkOrdering) {
319 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
320
321 const BookmarkNode* sub_folder = AddFolder(0, GetOtherNode(0), 0, "test");
322 ASSERT_TRUE(AddURL(0, sub_folder, 0, "", GURL(kUrl1)));
323 ASSERT_TRUE(AddURL(0, sub_folder, 1, "", GURL(kUrl2)));
324 ASSERT_TRUE(AddURL(0, sub_folder, 2, "", GURL(kUrl3)));
325
326 BackupModeChecker checker(GetSyncService(0),
327 base::TimeDelta::FromSeconds(15));
328 ASSERT_TRUE(checker.Wait());
329
330 // Restart backup.
331 GetSyncService(0)->StartStopBackupForTesting();
332 GetSyncService(0)->StartStopBackupForTesting();
333 ASSERT_TRUE(checker.Wait());
334
335 // Verify bookmarks are unchanged.
336 ASSERT_EQ(3, sub_folder->child_count());
337 ASSERT_EQ(GURL(kUrl1), sub_folder->GetChild(0)->url());
338 ASSERT_EQ(GURL(kUrl2), sub_folder->GetChild(1)->url());
339 ASSERT_EQ(GURL(kUrl3), sub_folder->GetChild(2)->url());
340 }
OLDNEW
« no previous file with comments | « no previous file | sync/internal_api/sync_backup_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698