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