| 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 <deque> | 7 #include <deque> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 LocalFileChangeTrackerTest() | 38 LocalFileChangeTrackerTest() |
| 39 : in_memory_env_(leveldb::NewMemEnv(leveldb::Env::Default())), | 39 : in_memory_env_(leveldb::NewMemEnv(leveldb::Env::Default())), |
| 40 file_system_(GURL("http://example.com"), | 40 file_system_(GURL("http://example.com"), |
| 41 in_memory_env_.get(), | 41 in_memory_env_.get(), |
| 42 base::ThreadTaskRunnerHandle::Get().get(), | 42 base::ThreadTaskRunnerHandle::Get().get(), |
| 43 base::ThreadTaskRunnerHandle::Get().get()) {} | 43 base::ThreadTaskRunnerHandle::Get().get()) {} |
| 44 | 44 |
| 45 virtual void SetUp() OVERRIDE { | 45 virtual void SetUp() OVERRIDE { |
| 46 file_system_.SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); | 46 file_system_.SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); |
| 47 | 47 |
| 48 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); |
| 48 sync_context_ = | 49 sync_context_ = |
| 49 new LocalFileSyncContext(base::FilePath(), | 50 new LocalFileSyncContext(base_dir_.path(), |
| 50 in_memory_env_.get(), | 51 in_memory_env_.get(), |
| 51 base::ThreadTaskRunnerHandle::Get().get(), | 52 base::ThreadTaskRunnerHandle::Get().get(), |
| 52 base::ThreadTaskRunnerHandle::Get().get()); | 53 base::ThreadTaskRunnerHandle::Get().get()); |
| 53 ASSERT_EQ( | 54 ASSERT_EQ( |
| 54 sync_file_system::SYNC_STATUS_OK, | 55 sync_file_system::SYNC_STATUS_OK, |
| 55 file_system_.MaybeInitializeFileSystemContext(sync_context_.get())); | 56 file_system_.MaybeInitializeFileSystemContext(sync_context_.get())); |
| 56 } | 57 } |
| 57 | 58 |
| 58 virtual void TearDown() OVERRIDE { | 59 virtual void TearDown() OVERRIDE { |
| 59 if (sync_context_.get()) | 60 if (sync_context_.get()) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 104 |
| 104 void RestoreChangesFromTrackerDB() { | 105 void RestoreChangesFromTrackerDB() { |
| 105 change_tracker()->CollectLastDirtyChanges(file_system_context()); | 106 change_tracker()->CollectLastDirtyChanges(file_system_context()); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void GetAllChangedURLs(fileapi::FileSystemURLSet* urls) { | 109 void GetAllChangedURLs(fileapi::FileSystemURLSet* urls) { |
| 109 change_tracker()->GetAllChangedURLs(urls); | 110 change_tracker()->GetAllChangedURLs(urls); |
| 110 } | 111 } |
| 111 | 112 |
| 112 base::MessageLoopForIO message_loop_; | 113 base::MessageLoopForIO message_loop_; |
| 114 base::ScopedTempDir base_dir_; |
| 113 scoped_ptr<leveldb::Env> in_memory_env_; | 115 scoped_ptr<leveldb::Env> in_memory_env_; |
| 114 CannedSyncableFileSystem file_system_; | 116 CannedSyncableFileSystem file_system_; |
| 115 | 117 |
| 116 private: | 118 private: |
| 117 scoped_refptr<LocalFileSyncContext> sync_context_; | 119 scoped_refptr<LocalFileSyncContext> sync_context_; |
| 118 | 120 |
| 119 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTrackerTest); | 121 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTrackerTest); |
| 120 }; | 122 }; |
| 121 | 123 |
| 122 TEST_F(LocalFileChangeTrackerTest, GetChanges) { | 124 TEST_F(LocalFileChangeTrackerTest, GetChanges) { |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 | 678 |
| 677 // Make sure they're gone from the database too. | 679 // Make sure they're gone from the database too. |
| 678 DropChangesInTracker(); | 680 DropChangesInTracker(); |
| 679 RestoreChangesFromTrackerDB(); | 681 RestoreChangesFromTrackerDB(); |
| 680 | 682 |
| 681 GetAllChangedURLs(&urls); | 683 GetAllChangedURLs(&urls); |
| 682 EXPECT_TRUE(urls.empty()); | 684 EXPECT_TRUE(urls.empty()); |
| 683 } | 685 } |
| 684 | 686 |
| 685 } // namespace sync_file_system | 687 } // namespace sync_file_system |
| OLD | NEW |