| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 base::MessageLoopForIO message_loop_; | 112 base::MessageLoopForIO message_loop_; |
| 113 scoped_ptr<leveldb::Env> in_memory_env_; | 113 scoped_ptr<leveldb::Env> in_memory_env_; |
| 114 CannedSyncableFileSystem file_system_; | 114 CannedSyncableFileSystem file_system_; |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 scoped_refptr<LocalFileSyncContext> sync_context_; | 117 scoped_refptr<LocalFileSyncContext> sync_context_; |
| 118 | 118 |
| 119 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTrackerTest); | 119 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTrackerTest); |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 TEST_F(LocalFileChangeTrackerTest, DemoteAndPromote) { |
| 123 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); |
| 124 |
| 125 const char kPath[] = "foo/bar"; |
| 126 change_tracker()->OnCreateDirectory(URL(kPath)); |
| 127 |
| 128 FileSystemURLSet urls; |
| 129 file_system_.GetChangedURLsInTracker(&urls); |
| 130 ASSERT_EQ(1u, urls.size()); |
| 131 EXPECT_EQ(URL(kPath), *urls.begin()); |
| 132 |
| 133 change_tracker()->DemoteChangesForURL(URL(kPath)); |
| 134 |
| 135 file_system_.GetChangedURLsInTracker(&urls); |
| 136 ASSERT_TRUE(urls.empty()); |
| 137 |
| 138 change_tracker()->PromoteDemotedChangesForURL(URL(kPath)); |
| 139 |
| 140 file_system_.GetChangedURLsInTracker(&urls); |
| 141 ASSERT_EQ(1u, urls.size()); |
| 142 EXPECT_EQ(URL(kPath), *urls.begin()); |
| 143 |
| 144 change_tracker()->DemoteChangesForURL(URL(kPath)); |
| 145 change_tracker()->OnRemoveDirectory(URL(kPath)); |
| 146 |
| 147 file_system_.GetChangedURLsInTracker(&urls); |
| 148 ASSERT_TRUE(urls.empty()); |
| 149 } |
| 150 |
| 122 TEST_F(LocalFileChangeTrackerTest, GetChanges) { | 151 TEST_F(LocalFileChangeTrackerTest, GetChanges) { |
| 123 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); | 152 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); |
| 124 | 153 |
| 125 // Test URLs (no parent/child relationships, as we test such cases | 154 // Test URLs (no parent/child relationships, as we test such cases |
| 126 // mainly in LocalFileSyncStatusTest). | 155 // mainly in LocalFileSyncStatusTest). |
| 127 const char kPath0[] = "test/dir a/dir"; | 156 const char kPath0[] = "test/dir a/dir"; |
| 128 const char kPath1[] = "test/dir b"; | 157 const char kPath1[] = "test/dir b"; |
| 129 const char kPath2[] = "test/foo.txt"; | 158 const char kPath2[] = "test/foo.txt"; |
| 130 const char kPath3[] = "test/bar"; | 159 const char kPath3[] = "test/bar"; |
| 131 const char kPath4[] = "temporary/dir a"; | 160 const char kPath4[] = "temporary/dir a"; |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 | 705 |
| 677 // Make sure they're gone from the database too. | 706 // Make sure they're gone from the database too. |
| 678 DropChangesInTracker(); | 707 DropChangesInTracker(); |
| 679 RestoreChangesFromTrackerDB(); | 708 RestoreChangesFromTrackerDB(); |
| 680 | 709 |
| 681 GetAllChangedURLs(&urls); | 710 GetAllChangedURLs(&urls); |
| 682 EXPECT_TRUE(urls.empty()); | 711 EXPECT_TRUE(urls.empty()); |
| 683 } | 712 } |
| 684 | 713 |
| 685 } // namespace sync_file_system | 714 } // namespace sync_file_system |
| OLD | NEW |