| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/sync_file_system/local/local_file_change_tracker.h" | 5 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <deque> | 9 #include <deque> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 | 12 |
| 13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" | 18 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" |
| 19 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 19 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
| 20 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 20 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
| 21 #include "chrome/browser/sync_file_system/sync_status_code.h" | 21 #include "chrome/browser/sync_file_system/sync_status_code.h" |
| 22 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 22 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
| 23 #include "content/public/test/mock_blob_url_request_context.h" | 23 #include "content/public/test/mock_blob_url_request_context.h" |
| 24 #include "content/public/test/test_browser_thread_bundle.h" |
| 24 #include "storage/browser/fileapi/file_system_context.h" | 25 #include "storage/browser/fileapi/file_system_context.h" |
| 25 #include "storage/browser/quota/quota_manager.h" | 26 #include "storage/browser/quota/quota_manager.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" | 28 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
| 28 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 29 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
| 29 | 30 |
| 31 using content::MockBlobURLRequestContext; |
| 32 using content::ScopedTextBlob; |
| 30 using storage::FileSystemContext; | 33 using storage::FileSystemContext; |
| 31 using storage::FileSystemURL; | 34 using storage::FileSystemURL; |
| 32 using storage::FileSystemURLSet; | 35 using storage::FileSystemURLSet; |
| 33 using content::MockBlobURLRequestContext; | |
| 34 using content::ScopedTextBlob; | |
| 35 | 36 |
| 36 namespace sync_file_system { | 37 namespace sync_file_system { |
| 37 | 38 |
| 38 class LocalFileChangeTrackerTest : public testing::Test { | 39 class LocalFileChangeTrackerTest : public testing::Test { |
| 39 public: | 40 public: |
| 40 LocalFileChangeTrackerTest() | 41 LocalFileChangeTrackerTest() |
| 41 : in_memory_env_(leveldb::NewMemEnv(leveldb::Env::Default())), | 42 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 43 in_memory_env_(leveldb::NewMemEnv(leveldb::Env::Default())), |
| 42 file_system_(GURL("http://example.com"), | 44 file_system_(GURL("http://example.com"), |
| 43 in_memory_env_.get(), | 45 in_memory_env_.get(), |
| 44 base::ThreadTaskRunnerHandle::Get().get(), | 46 base::ThreadTaskRunnerHandle::Get().get(), |
| 45 base::ThreadTaskRunnerHandle::Get().get()) {} | 47 base::ThreadTaskRunnerHandle::Get().get()) {} |
| 46 | 48 |
| 47 void SetUp() override { | 49 void SetUp() override { |
| 48 file_system_.SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); | 50 file_system_.SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); |
| 49 | 51 |
| 50 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); | 52 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); |
| 51 sync_context_ = | 53 sync_context_ = |
| 52 new LocalFileSyncContext(base_dir_.path(), | 54 new LocalFileSyncContext(base_dir_.path(), |
| 53 in_memory_env_.get(), | 55 in_memory_env_.get(), |
| 54 base::ThreadTaskRunnerHandle::Get().get(), | 56 base::ThreadTaskRunnerHandle::Get().get(), |
| 55 base::ThreadTaskRunnerHandle::Get().get()); | 57 base::ThreadTaskRunnerHandle::Get().get()); |
| 56 ASSERT_EQ( | 58 ASSERT_EQ( |
| 57 sync_file_system::SYNC_STATUS_OK, | 59 SYNC_STATUS_OK, |
| 58 file_system_.MaybeInitializeFileSystemContext(sync_context_.get())); | 60 file_system_.MaybeInitializeFileSystemContext(sync_context_.get())); |
| 59 } | 61 } |
| 60 | 62 |
| 61 void TearDown() override { | 63 void TearDown() override { |
| 62 if (sync_context_.get()) | 64 sync_context_->ShutdownOnUIThread(); |
| 63 sync_context_->ShutdownOnUIThread(); | |
| 64 sync_context_ = nullptr; | 65 sync_context_ = nullptr; |
| 65 | 66 |
| 66 message_loop_.RunUntilIdle(); | 67 base::RunLoop().RunUntilIdle(); |
| 67 file_system_.TearDown(); | 68 file_system_.TearDown(); |
| 68 // Make sure we don't leave the external filesystem. | 69 // Make sure we don't leave the external filesystem. |
| 69 // (CannedSyncableFileSystem::TearDown does not do this as there may be | 70 // (CannedSyncableFileSystem::TearDown does not do this as there may be |
| 70 // multiple syncable file systems registered for the name) | 71 // multiple syncable file systems registered for the name) |
| 71 RevokeSyncableFileSystem(); | 72 RevokeSyncableFileSystem(); |
| 72 } | 73 } |
| 73 | 74 |
| 74 protected: | 75 protected: |
| 75 FileSystemURL URL(const std::string& path) { | 76 FileSystemURL URL(const std::string& path) { |
| 76 return file_system_.URL(path); | 77 return file_system_.URL(path); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 105 } | 106 } |
| 106 | 107 |
| 107 void RestoreChangesFromTrackerDB() { | 108 void RestoreChangesFromTrackerDB() { |
| 108 change_tracker()->CollectLastDirtyChanges(file_system_context()); | 109 change_tracker()->CollectLastDirtyChanges(file_system_context()); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void GetAllChangedURLs(storage::FileSystemURLSet* urls) { | 112 void GetAllChangedURLs(storage::FileSystemURLSet* urls) { |
| 112 change_tracker()->GetAllChangedURLs(urls); | 113 change_tracker()->GetAllChangedURLs(urls); |
| 113 } | 114 } |
| 114 | 115 |
| 115 base::MessageLoopForIO message_loop_; | 116 content::TestBrowserThreadBundle thread_bundle_; |
| 116 base::ScopedTempDir base_dir_; | 117 base::ScopedTempDir base_dir_; |
| 117 std::unique_ptr<leveldb::Env> in_memory_env_; | 118 std::unique_ptr<leveldb::Env> in_memory_env_; |
| 118 CannedSyncableFileSystem file_system_; | 119 CannedSyncableFileSystem file_system_; |
| 119 | 120 |
| 120 private: | 121 private: |
| 121 scoped_refptr<LocalFileSyncContext> sync_context_; | 122 scoped_refptr<LocalFileSyncContext> sync_context_; |
| 122 | 123 |
| 123 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTrackerTest); | 124 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTrackerTest); |
| 124 }; | 125 }; |
| 125 | 126 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 EXPECT_EQ(URL(kPath3), urls_to_process[2]); | 244 EXPECT_EQ(URL(kPath3), urls_to_process[2]); |
| 244 EXPECT_EQ(URL(kPath5), urls_to_process[3]); | 245 EXPECT_EQ(URL(kPath5), urls_to_process[3]); |
| 245 EXPECT_EQ(URL(kPath4), urls_to_process[4]); | 246 EXPECT_EQ(URL(kPath4), urls_to_process[4]); |
| 246 | 247 |
| 247 // No changes to promote any more. | 248 // No changes to promote any more. |
| 248 EXPECT_FALSE(change_tracker()->PromoteDemotedChanges()); | 249 EXPECT_FALSE(change_tracker()->PromoteDemotedChanges()); |
| 249 | 250 |
| 250 | 251 |
| 251 VerifyAndClearChange(URL(kPath1), | 252 VerifyAndClearChange(URL(kPath1), |
| 252 FileChange(FileChange::FILE_CHANGE_DELETE, | 253 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 253 sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); | 254 SYNC_FILE_TYPE_DIRECTORY)); |
| 254 VerifyAndClearChange(URL(kPath2), | 255 VerifyAndClearChange(URL(kPath2), |
| 255 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 256 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 256 sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); | 257 SYNC_FILE_TYPE_DIRECTORY)); |
| 257 VerifyAndClearChange(URL(kPath3), | 258 VerifyAndClearChange(URL(kPath3), |
| 258 FileChange(FileChange::FILE_CHANGE_DELETE, | 259 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 259 sync_file_system::SYNC_FILE_TYPE_FILE)); | 260 SYNC_FILE_TYPE_FILE)); |
| 260 VerifyAndClearChange(URL(kPath4), | 261 VerifyAndClearChange(URL(kPath4), |
| 261 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 262 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 262 sync_file_system::SYNC_FILE_TYPE_FILE)); | 263 SYNC_FILE_TYPE_FILE)); |
| 263 VerifyAndClearChange(URL(kPath5), | 264 VerifyAndClearChange(URL(kPath5), |
| 264 FileChange(FileChange::FILE_CHANGE_DELETE, | 265 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 265 sync_file_system::SYNC_FILE_TYPE_FILE)); | 266 SYNC_FILE_TYPE_FILE)); |
| 266 } | 267 } |
| 267 | 268 |
| 268 TEST_F(LocalFileChangeTrackerTest, RestoreCreateAndModifyChanges) { | 269 TEST_F(LocalFileChangeTrackerTest, RestoreCreateAndModifyChanges) { |
| 269 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); | 270 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); |
| 270 | 271 |
| 271 FileSystemURLSet urls; | 272 FileSystemURLSet urls; |
| 272 | 273 |
| 273 const char kPath0[] = "file a"; | 274 const char kPath0[] = "file a"; |
| 274 const char kPath1[] = "dir a"; | 275 const char kPath1[] = "dir a"; |
| 275 const char kPath2[] = "dir a/dir"; | 276 const char kPath2[] = "dir a/dir"; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 ASSERT_EQ(0U, urls.size()); | 313 ASSERT_EQ(0U, urls.size()); |
| 313 | 314 |
| 314 RestoreChangesFromTrackerDB(); | 315 RestoreChangesFromTrackerDB(); |
| 315 | 316 |
| 316 // Make sure the changes are restored from the DB. | 317 // Make sure the changes are restored from the DB. |
| 317 file_system_.GetChangedURLsInTracker(&urls); | 318 file_system_.GetChangedURLsInTracker(&urls); |
| 318 EXPECT_EQ(5U, urls.size()); | 319 EXPECT_EQ(5U, urls.size()); |
| 319 | 320 |
| 320 VerifyAndClearChange(URL(kPath0), | 321 VerifyAndClearChange(URL(kPath0), |
| 321 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 322 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 322 sync_file_system::SYNC_FILE_TYPE_FILE)); | 323 SYNC_FILE_TYPE_FILE)); |
| 323 VerifyAndClearChange(URL(kPath1), | 324 VerifyAndClearChange(URL(kPath1), |
| 324 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 325 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 325 sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); | 326 SYNC_FILE_TYPE_DIRECTORY)); |
| 326 VerifyAndClearChange(URL(kPath2), | 327 VerifyAndClearChange(URL(kPath2), |
| 327 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 328 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 328 sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); | 329 SYNC_FILE_TYPE_DIRECTORY)); |
| 329 VerifyAndClearChange(URL(kPath3), | 330 VerifyAndClearChange(URL(kPath3), |
| 330 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 331 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 331 sync_file_system::SYNC_FILE_TYPE_FILE)); | 332 SYNC_FILE_TYPE_FILE)); |
| 332 VerifyAndClearChange(URL(kPath4), | 333 VerifyAndClearChange(URL(kPath4), |
| 333 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 334 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 334 sync_file_system::SYNC_FILE_TYPE_FILE)); | 335 SYNC_FILE_TYPE_FILE)); |
| 335 } | 336 } |
| 336 | 337 |
| 337 TEST_F(LocalFileChangeTrackerTest, RestoreRemoveChanges) { | 338 TEST_F(LocalFileChangeTrackerTest, RestoreRemoveChanges) { |
| 338 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); | 339 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); |
| 339 | 340 |
| 340 FileSystemURLSet urls; | 341 FileSystemURLSet urls; |
| 341 | 342 |
| 342 const char kPath0[] = "file"; | 343 const char kPath0[] = "file"; |
| 343 const char kPath1[] = "dir a"; | 344 const char kPath1[] = "dir a"; |
| 344 const char kPath2[] = "dir b"; | 345 const char kPath2[] = "dir b"; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 RestoreChangesFromTrackerDB(); | 386 RestoreChangesFromTrackerDB(); |
| 386 | 387 |
| 387 // Make sure the changes are restored from the DB. | 388 // Make sure the changes are restored from the DB. |
| 388 file_system_.GetChangedURLsInTracker(&urls); | 389 file_system_.GetChangedURLsInTracker(&urls); |
| 389 // Since directories to have been reverted (kPath1, kPath2, kPath4) are | 390 // Since directories to have been reverted (kPath1, kPath2, kPath4) are |
| 390 // treated as FILE_CHANGE_DELETE, the number of changes should be 6. | 391 // treated as FILE_CHANGE_DELETE, the number of changes should be 6. |
| 391 EXPECT_EQ(6U, urls.size()); | 392 EXPECT_EQ(6U, urls.size()); |
| 392 | 393 |
| 393 VerifyAndClearChange(URL(kPath0), | 394 VerifyAndClearChange(URL(kPath0), |
| 394 FileChange(FileChange::FILE_CHANGE_DELETE, | 395 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 395 sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); | 396 SYNC_FILE_TYPE_UNKNOWN)); |
| 396 VerifyAndClearChange(URL(kPath1), | 397 VerifyAndClearChange(URL(kPath1), |
| 397 FileChange(FileChange::FILE_CHANGE_DELETE, | 398 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 398 sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); | 399 SYNC_FILE_TYPE_UNKNOWN)); |
| 399 VerifyAndClearChange(URL(kPath2), | 400 VerifyAndClearChange(URL(kPath2), |
| 400 FileChange(FileChange::FILE_CHANGE_DELETE, | 401 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 401 sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); | 402 SYNC_FILE_TYPE_UNKNOWN)); |
| 402 VerifyAndClearChange(URL(kPath3), | 403 VerifyAndClearChange(URL(kPath3), |
| 403 FileChange(FileChange::FILE_CHANGE_DELETE, | 404 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 404 sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); | 405 SYNC_FILE_TYPE_UNKNOWN)); |
| 405 VerifyAndClearChange(URL(kPath4), | 406 VerifyAndClearChange(URL(kPath4), |
| 406 FileChange(FileChange::FILE_CHANGE_DELETE, | 407 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 407 sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); | 408 SYNC_FILE_TYPE_UNKNOWN)); |
| 408 VerifyAndClearChange(URL(kPath5), | 409 VerifyAndClearChange(URL(kPath5), |
| 409 FileChange(FileChange::FILE_CHANGE_DELETE, | 410 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 410 sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); | 411 SYNC_FILE_TYPE_UNKNOWN)); |
| 411 } | 412 } |
| 412 | 413 |
| 413 TEST_F(LocalFileChangeTrackerTest, RestoreCopyChanges) { | 414 TEST_F(LocalFileChangeTrackerTest, RestoreCopyChanges) { |
| 414 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); | 415 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); |
| 415 | 416 |
| 416 FileSystemURLSet urls; | 417 FileSystemURLSet urls; |
| 417 | 418 |
| 418 const char kPath0[] = "file a"; | 419 const char kPath0[] = "file a"; |
| 419 const char kPath1[] = "dir a"; | 420 const char kPath1[] = "dir a"; |
| 420 const char kPath2[] = "dir a/dir"; | 421 const char kPath2[] = "dir a/dir"; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 ASSERT_EQ(0U, urls.size()); | 480 ASSERT_EQ(0U, urls.size()); |
| 480 | 481 |
| 481 RestoreChangesFromTrackerDB(); | 482 RestoreChangesFromTrackerDB(); |
| 482 | 483 |
| 483 // Make sure the changes are restored from the DB. | 484 // Make sure the changes are restored from the DB. |
| 484 file_system_.GetChangedURLsInTracker(&urls); | 485 file_system_.GetChangedURLsInTracker(&urls); |
| 485 EXPECT_EQ(5U, urls.size()); | 486 EXPECT_EQ(5U, urls.size()); |
| 486 | 487 |
| 487 VerifyAndClearChange(URL(kPath0Copy), | 488 VerifyAndClearChange(URL(kPath0Copy), |
| 488 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 489 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 489 sync_file_system::SYNC_FILE_TYPE_FILE)); | 490 SYNC_FILE_TYPE_FILE)); |
| 490 VerifyAndClearChange(URL(kPath1Copy), | 491 VerifyAndClearChange(URL(kPath1Copy), |
| 491 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 492 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 492 sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); | 493 SYNC_FILE_TYPE_DIRECTORY)); |
| 493 VerifyAndClearChange(URL(kPath2Copy), | 494 VerifyAndClearChange(URL(kPath2Copy), |
| 494 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 495 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 495 sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); | 496 SYNC_FILE_TYPE_DIRECTORY)); |
| 496 VerifyAndClearChange(URL(kPath3Copy), | 497 VerifyAndClearChange(URL(kPath3Copy), |
| 497 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 498 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 498 sync_file_system::SYNC_FILE_TYPE_FILE)); | 499 SYNC_FILE_TYPE_FILE)); |
| 499 VerifyAndClearChange(URL(kPath4Copy), | 500 VerifyAndClearChange(URL(kPath4Copy), |
| 500 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 501 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 501 sync_file_system::SYNC_FILE_TYPE_FILE)); | 502 SYNC_FILE_TYPE_FILE)); |
| 502 } | 503 } |
| 503 | 504 |
| 504 TEST_F(LocalFileChangeTrackerTest, RestoreMoveChanges) { | 505 TEST_F(LocalFileChangeTrackerTest, RestoreMoveChanges) { |
| 505 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); | 506 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); |
| 506 | 507 |
| 507 FileSystemURLSet urls; | 508 FileSystemURLSet urls; |
| 508 | 509 |
| 509 const char kPath0[] = "file a"; | 510 const char kPath0[] = "file a"; |
| 510 const char kPath1[] = "dir a"; | 511 const char kPath1[] = "dir a"; |
| 511 const char kPath2[] = "dir a/file"; | 512 const char kPath2[] = "dir a/file"; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 RestoreChangesFromTrackerDB(); | 565 RestoreChangesFromTrackerDB(); |
| 565 | 566 |
| 566 // Make sure the changes are restored from the DB. | 567 // Make sure the changes are restored from the DB. |
| 567 file_system_.GetChangedURLsInTracker(&urls); | 568 file_system_.GetChangedURLsInTracker(&urls); |
| 568 // Deletion for child files in the deleted directory cannot be restored, | 569 // Deletion for child files in the deleted directory cannot be restored, |
| 569 // so we will only have 8 changes. | 570 // so we will only have 8 changes. |
| 570 EXPECT_EQ(10U, urls.size()); | 571 EXPECT_EQ(10U, urls.size()); |
| 571 | 572 |
| 572 VerifyAndClearChange(URL(kPath0), | 573 VerifyAndClearChange(URL(kPath0), |
| 573 FileChange(FileChange::FILE_CHANGE_DELETE, | 574 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 574 sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); | 575 SYNC_FILE_TYPE_UNKNOWN)); |
| 575 VerifyAndClearChange(URL(kPath1), | 576 VerifyAndClearChange(URL(kPath1), |
| 576 FileChange(FileChange::FILE_CHANGE_DELETE, | 577 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 577 sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); | 578 SYNC_FILE_TYPE_UNKNOWN)); |
| 578 VerifyAndClearChange(URL(kPath3), | 579 VerifyAndClearChange(URL(kPath3), |
| 579 FileChange(FileChange::FILE_CHANGE_DELETE, | 580 FileChange(FileChange::FILE_CHANGE_DELETE, |
| 580 sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); | 581 SYNC_FILE_TYPE_UNKNOWN)); |
| 581 VerifyAndClearChange(URL(kPath5), | 582 VerifyAndClearChange(URL(kPath5), |
| 582 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 583 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 583 sync_file_system::SYNC_FILE_TYPE_FILE)); | 584 SYNC_FILE_TYPE_FILE)); |
| 584 VerifyAndClearChange(URL(kPath6), | 585 VerifyAndClearChange(URL(kPath6), |
| 585 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 586 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 586 sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); | 587 SYNC_FILE_TYPE_DIRECTORY)); |
| 587 VerifyAndClearChange(URL(kPath7), | 588 VerifyAndClearChange(URL(kPath7), |
| 588 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 589 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 589 sync_file_system::SYNC_FILE_TYPE_FILE)); | 590 SYNC_FILE_TYPE_FILE)); |
| 590 VerifyAndClearChange(URL(kPath8), | 591 VerifyAndClearChange(URL(kPath8), |
| 591 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 592 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 592 sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); | 593 SYNC_FILE_TYPE_DIRECTORY)); |
| 593 VerifyAndClearChange(URL(kPath9), | 594 VerifyAndClearChange(URL(kPath9), |
| 594 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 595 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 595 sync_file_system::SYNC_FILE_TYPE_FILE)); | 596 SYNC_FILE_TYPE_FILE)); |
| 596 } | 597 } |
| 597 | 598 |
| 598 TEST_F(LocalFileChangeTrackerTest, NextChangedURLsWithRecursiveCopy) { | 599 TEST_F(LocalFileChangeTrackerTest, NextChangedURLsWithRecursiveCopy) { |
| 599 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); | 600 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); |
| 600 | 601 |
| 601 FileSystemURLSet urls; | 602 FileSystemURLSet urls; |
| 602 | 603 |
| 603 const char kPath0[] = "dir a"; | 604 const char kPath0[] = "dir a"; |
| 604 const char kPath1[] = "dir a/file"; | 605 const char kPath1[] = "dir a/file"; |
| 605 const char kPath2[] = "dir a/dir"; | 606 const char kPath2[] = "dir a/dir"; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 | 708 |
| 708 // Make sure they're gone from the database too. | 709 // Make sure they're gone from the database too. |
| 709 DropChangesInTracker(); | 710 DropChangesInTracker(); |
| 710 RestoreChangesFromTrackerDB(); | 711 RestoreChangesFromTrackerDB(); |
| 711 | 712 |
| 712 GetAllChangedURLs(&urls); | 713 GetAllChangedURLs(&urls); |
| 713 EXPECT_TRUE(urls.empty()); | 714 EXPECT_TRUE(urls.empty()); |
| 714 } | 715 } |
| 715 | 716 |
| 716 } // namespace sync_file_system | 717 } // namespace sync_file_system |
| OLD | NEW |