OLD | NEW |
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/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
13 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 13 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/sync/chrome_sync_client.h" | 15 #include "chrome/browser/sync/chrome_sync_client.h" |
16 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 16 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
17 #include "chrome/browser/sync/test/integration/preferences_helper.h" | 17 #include "chrome/browser/sync/test/integration/preferences_helper.h" |
18 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 18 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
19 #include "chrome/browser/sync/test/integration/sync_test.h" | 19 #include "chrome/browser/sync/test/integration/sync_test.h" |
20 #include "components/bookmarks/browser/bookmark_model.h" | 20 #include "components/bookmarks/browser/bookmark_model.h" |
21 #include "components/browser_sync/browser/profile_sync_service.h" | 21 #include "components/browser_sync/browser/profile_sync_service.h" |
22 #include "components/sync_driver/sync_driver_features.h" | |
23 #include "components/sync_driver/sync_driver_switches.h" | 22 #include "components/sync_driver/sync_driver_switches.h" |
24 #include "sync/internal_api/public/util/sync_db_util.h" | 23 #include "sync/internal_api/public/util/sync_db_util.h" |
25 #include "sync/test/fake_server/fake_server_verifier.h" | 24 #include "sync/test/fake_server/fake_server_verifier.h" |
26 #include "sync/util/time.h" | 25 #include "sync/util/time.h" |
27 | 26 |
28 using bookmarks::BookmarkNode; | 27 using bookmarks::BookmarkNode; |
29 using bookmarks_helper::AddFolder; | 28 using bookmarks_helper::AddFolder; |
30 using bookmarks_helper::AddURL; | 29 using bookmarks_helper::AddURL; |
31 using bookmarks_helper::GetOtherNode; | 30 using bookmarks_helper::GetOtherNode; |
32 using bookmarks_helper::ModelMatchesVerifier; | 31 using bookmarks_helper::ModelMatchesVerifier; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 return rollback_started_ && clear_done_; | 151 return rollback_started_ && clear_done_; |
153 } | 152 } |
154 | 153 |
155 ProfileSyncService* const pss_; | 154 ProfileSyncService* const pss_; |
156 const base::TimeDelta timeout_; | 155 const base::TimeDelta timeout_; |
157 base::RunLoop run_loop_; | 156 base::RunLoop run_loop_; |
158 bool rollback_started_; | 157 bool rollback_started_; |
159 bool clear_done_; | 158 bool clear_done_; |
160 }; | 159 }; |
161 | 160 |
162 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) | 161 #if defined(ENABLE_PRE_SYNC_BACKUP) |
163 #define MAYBE_TestBackup TestBackup | 162 #define MAYBE_TestBackup TestBackup |
164 #else | 163 #else |
165 #define MAYBE_TestBackup DISABLED_TestBackup | 164 #define MAYBE_TestBackup DISABLED_TestBackup |
166 #endif | 165 #endif |
167 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, | 166 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
168 MAYBE_TestBackup) { | 167 MAYBE_TestBackup) { |
169 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 168 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
170 | 169 |
171 // Setup sync, wait for its completion, and make sure changes were synced. | 170 // Setup sync, wait for its completion, and make sure changes were synced. |
172 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 171 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
173 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); | 172 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); |
174 ASSERT_TRUE(ModelMatchesVerifier(0)); | 173 ASSERT_TRUE(ModelMatchesVerifier(0)); |
175 | 174 |
176 // Verify backup DB is created and backup time is set on device info. | 175 // Verify backup DB is created and backup time is set on device info. |
177 base::Time backup_time = GetBackupDbLastModified(); | 176 base::Time backup_time = GetBackupDbLastModified(); |
178 ASSERT_FALSE(backup_time.is_null()); | 177 ASSERT_FALSE(backup_time.is_null()); |
179 ASSERT_EQ(backup_time, GetSyncService(0)->GetDeviceBackupTimeForTesting()); | 178 ASSERT_EQ(backup_time, GetSyncService(0)->GetDeviceBackupTimeForTesting()); |
180 } | 179 } |
181 | 180 |
182 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) | 181 #if defined(ENABLE_PRE_SYNC_BACKUP) |
183 #define MAYBE_TestBackupDisabled TestBackupDisabled | 182 #define MAYBE_TestBackupDisabled TestBackupDisabled |
184 #else | 183 #else |
185 #define MAYBE_TestBackupDisabled DISABLED_TestBackupDisabled | 184 #define MAYBE_TestBackupDisabled DISABLED_TestBackupDisabled |
186 #endif | 185 #endif |
187 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, | 186 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
188 MAYBE_TestBackupDisabled) { | 187 MAYBE_TestBackupDisabled) { |
189 DisableBackup(); | 188 DisableBackup(); |
190 | 189 |
191 // Setup sync, wait for its completion, and make sure changes were synced. | 190 // Setup sync, wait for its completion, and make sure changes were synced. |
192 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 191 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
193 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); | 192 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); |
194 ASSERT_TRUE(ModelMatchesVerifier(0)); | 193 ASSERT_TRUE(ModelMatchesVerifier(0)); |
195 | 194 |
196 // Verify backup DB is not created and backup time is not set on device info. | 195 // Verify backup DB is not created and backup time is not set on device info. |
197 ASSERT_FALSE(base::PathExists( | 196 ASSERT_FALSE(base::PathExists( |
198 GetProfile(0)->GetPath().Append(FILE_PATH_LITERAL("Sync Data Backup")))); | 197 GetProfile(0)->GetPath().Append(FILE_PATH_LITERAL("Sync Data Backup")))); |
199 ASSERT_TRUE(GetSyncService(0)->GetDeviceBackupTimeForTesting().is_null()); | 198 ASSERT_TRUE(GetSyncService(0)->GetDeviceBackupTimeForTesting().is_null()); |
200 } | 199 } |
201 | 200 |
202 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) | 201 #if defined(ENABLE_PRE_SYNC_BACKUP) |
203 #define MAYBE_TestRollback TestRollback | 202 #define MAYBE_TestRollback TestRollback |
204 #else | 203 #else |
205 #define MAYBE_TestRollback DISABLED_TestRollback | 204 #define MAYBE_TestRollback DISABLED_TestRollback |
206 #endif | 205 #endif |
207 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, | 206 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
208 MAYBE_TestRollback) { | 207 MAYBE_TestRollback) { |
209 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 208 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
210 | 209 |
211 // Starting state: | 210 // Starting state: |
212 // other_node | 211 // other_node |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // Verify bookmarks are restored. | 249 // Verify bookmarks are restored. |
251 ASSERT_EQ(1, tier1_a->child_count()); | 250 ASSERT_EQ(1, tier1_a->child_count()); |
252 const BookmarkNode* url1 = tier1_a->GetChild(0); | 251 const BookmarkNode* url1 = tier1_a->GetChild(0); |
253 ASSERT_EQ(GURL("http://mail.google.com"), url1->url()); | 252 ASSERT_EQ(GURL("http://mail.google.com"), url1->url()); |
254 | 253 |
255 ASSERT_EQ(1, tier1_b->child_count()); | 254 ASSERT_EQ(1, tier1_b->child_count()); |
256 const BookmarkNode* url2 = tier1_b->GetChild(0); | 255 const BookmarkNode* url2 = tier1_b->GetChild(0); |
257 ASSERT_EQ(GURL("http://www.nhl.com"), url2->url()); | 256 ASSERT_EQ(GURL("http://www.nhl.com"), url2->url()); |
258 } | 257 } |
259 | 258 |
260 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) | 259 #if defined(ENABLE_PRE_SYNC_BACKUP) |
261 #define MAYBE_TestRollbackDisabled TestRollbackDisabled | 260 #define MAYBE_TestRollbackDisabled TestRollbackDisabled |
262 #else | 261 #else |
263 #define MAYBE_TestRollbackDisabled DISABLED_TestRollbackDisabled | 262 #define MAYBE_TestRollbackDisabled DISABLED_TestRollbackDisabled |
264 #endif | 263 #endif |
265 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, | 264 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
266 MAYBE_TestRollbackDisabled) { | 265 MAYBE_TestRollbackDisabled) { |
267 DisableRollback(); | 266 DisableRollback(); |
268 | 267 |
269 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 268 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
270 | 269 |
(...skipping 28 matching lines...) Expand all Loading... |
299 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); | 298 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); |
300 ASSERT_TRUE(shutdown_checker.Wait()); | 299 ASSERT_TRUE(shutdown_checker.Wait()); |
301 | 300 |
302 // With rollback disabled, bookmarks in backup DB should not be restored. | 301 // With rollback disabled, bookmarks in backup DB should not be restored. |
303 // Only bookmark added during sync is present. | 302 // Only bookmark added during sync is present. |
304 ASSERT_EQ(1, GetOtherNode(0)->child_count()); | 303 ASSERT_EQ(1, GetOtherNode(0)->child_count()); |
305 ASSERT_EQ(GURL("http://www.yahoo.com"), | 304 ASSERT_EQ(GURL("http://www.yahoo.com"), |
306 GetOtherNode(0)->GetChild(0)->url()); | 305 GetOtherNode(0)->GetChild(0)->url()); |
307 } | 306 } |
308 | 307 |
309 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) | 308 #if defined(ENABLE_PRE_SYNC_BACKUP) |
310 #define MAYBE_TestSyncDisabled TestSyncDisabled | 309 #define MAYBE_TestSyncDisabled TestSyncDisabled |
311 #else | 310 #else |
312 #define MAYBE_TestSyncDisabled DISABLED_TestSyncDisabled | 311 #define MAYBE_TestSyncDisabled DISABLED_TestSyncDisabled |
313 #endif | 312 #endif |
314 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, | 313 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
315 MAYBE_TestSyncDisabled) { | 314 MAYBE_TestSyncDisabled) { |
316 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 315 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
317 | 316 |
318 // Starting state: | 317 // Starting state: |
319 // other_node | 318 // other_node |
(...skipping 26 matching lines...) Expand all Loading... |
346 // Wait sync backend is completely shut down. | 345 // Wait sync backend is completely shut down. |
347 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); | 346 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); |
348 ASSERT_TRUE(shutdown_checker.Wait()); | 347 ASSERT_TRUE(shutdown_checker.Wait()); |
349 | 348 |
350 // Shouldn't restore bookmarks with sign-out only. | 349 // Shouldn't restore bookmarks with sign-out only. |
351 ASSERT_EQ(1, GetOtherNode(0)->child_count()); | 350 ASSERT_EQ(1, GetOtherNode(0)->child_count()); |
352 ASSERT_EQ(GURL("http://www.yahoo.com"), | 351 ASSERT_EQ(GURL("http://www.yahoo.com"), |
353 GetOtherNode(0)->GetChild(0)->url()); | 352 GetOtherNode(0)->GetChild(0)->url()); |
354 } | 353 } |
355 | 354 |
356 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) | 355 #if defined(ENABLE_PRE_SYNC_BACKUP) |
357 #define MAYBE_RollbackNoBackup RollbackNoBackup | 356 #define MAYBE_RollbackNoBackup RollbackNoBackup |
358 #else | 357 #else |
359 #define MAYBE_RollbackNoBackup DISABLED_RollbackNoBackup | 358 #define MAYBE_RollbackNoBackup DISABLED_RollbackNoBackup |
360 #endif | 359 #endif |
361 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, | 360 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
362 MAYBE_RollbackNoBackup) { | 361 MAYBE_RollbackNoBackup) { |
363 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 362 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
364 | 363 |
365 // Starting state: | 364 // Starting state: |
366 // other_node | 365 // other_node |
(...skipping 26 matching lines...) Expand all Loading... |
393 ASSERT_TRUE(rollback_checker.Wait()); | 392 ASSERT_TRUE(rollback_checker.Wait()); |
394 SyncBackendStoppedChecker checker(GetSyncService(0)); | 393 SyncBackendStoppedChecker checker(GetSyncService(0)); |
395 ASSERT_TRUE(checker.Wait()); | 394 ASSERT_TRUE(checker.Wait()); |
396 | 395 |
397 // Without backup DB, bookmarks remain at the state when sync stops. | 396 // Without backup DB, bookmarks remain at the state when sync stops. |
398 ASSERT_EQ(1, GetOtherNode(0)->child_count()); | 397 ASSERT_EQ(1, GetOtherNode(0)->child_count()); |
399 ASSERT_EQ(GURL("http://www.nhl.com"), | 398 ASSERT_EQ(GURL("http://www.nhl.com"), |
400 GetOtherNode(0)->GetChild(0)->url()); | 399 GetOtherNode(0)->GetChild(0)->url()); |
401 } | 400 } |
402 | 401 |
403 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) | 402 #if defined(ENABLE_PRE_SYNC_BACKUP) |
404 #define MAYBE_DontChangeBookmarkOrdering DontChangeBookmarkOrdering | 403 #define MAYBE_DontChangeBookmarkOrdering DontChangeBookmarkOrdering |
405 #else | 404 #else |
406 #define MAYBE_DontChangeBookmarkOrdering DISABLED_DontChangeBookmarkOrdering | 405 #define MAYBE_DontChangeBookmarkOrdering DISABLED_DontChangeBookmarkOrdering |
407 #endif | 406 #endif |
408 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, | 407 IN_PROC_BROWSER_TEST_F(SingleClientBackupRollbackTest, |
409 MAYBE_DontChangeBookmarkOrdering) { | 408 MAYBE_DontChangeBookmarkOrdering) { |
410 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 409 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
411 | 410 |
412 const BookmarkNode* sub_folder = AddFolder(0, GetOtherNode(0), 0, "test"); | 411 const BookmarkNode* sub_folder = AddFolder(0, GetOtherNode(0), 0, "test"); |
413 ASSERT_TRUE(AddURL(0, sub_folder, 0, "", GURL(kUrl1))); | 412 ASSERT_TRUE(AddURL(0, sub_folder, 0, "", GURL(kUrl1))); |
(...skipping 22 matching lines...) Expand all Loading... |
436 ASSERT_TRUE(rollback_checker.Wait()); | 435 ASSERT_TRUE(rollback_checker.Wait()); |
437 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); | 436 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); |
438 ASSERT_TRUE(shutdown_checker.Wait()); | 437 ASSERT_TRUE(shutdown_checker.Wait()); |
439 | 438 |
440 // Verify bookmarks are unchanged. | 439 // Verify bookmarks are unchanged. |
441 ASSERT_EQ(3, sub_folder->child_count()); | 440 ASSERT_EQ(3, sub_folder->child_count()); |
442 ASSERT_EQ(GURL(kUrl1), sub_folder->GetChild(0)->url()); | 441 ASSERT_EQ(GURL(kUrl1), sub_folder->GetChild(0)->url()); |
443 ASSERT_EQ(GURL(kUrl2), sub_folder->GetChild(1)->url()); | 442 ASSERT_EQ(GURL(kUrl2), sub_folder->GetChild(1)->url()); |
444 ASSERT_EQ(GURL(kUrl3), sub_folder->GetChild(2)->url()); | 443 ASSERT_EQ(GURL(kUrl3), sub_folder->GetChild(2)->url()); |
445 } | 444 } |
OLD | NEW |