OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/fileapi/syncable/local_file_change_tracker.h" | 5 #include "webkit/fileapi/syncable/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" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/message_loop_proxy.h" | 14 #include "base/message_loop_proxy.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "webkit/blob/mock_blob_url_request_context.h" | 17 #include "webkit/blob/mock_blob_url_request_context.h" |
| 18 #include "webkit/blob/blob_storage_context.h" |
18 #include "webkit/fileapi/file_system_context.h" | 19 #include "webkit/fileapi/file_system_context.h" |
19 #include "webkit/fileapi/file_system_task_runners.h" | 20 #include "webkit/fileapi/file_system_task_runners.h" |
20 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" | 21 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" |
21 #include "webkit/fileapi/syncable/local_file_sync_context.h" | 22 #include "webkit/fileapi/syncable/local_file_sync_context.h" |
22 #include "webkit/fileapi/syncable/sync_status_code.h" | 23 #include "webkit/fileapi/syncable/sync_status_code.h" |
23 #include "webkit/fileapi/syncable/syncable_file_system_util.h" | 24 #include "webkit/fileapi/syncable/syncable_file_system_util.h" |
24 #include "webkit/quota/quota_manager.h" | 25 #include "webkit/quota/quota_manager.h" |
25 | 26 |
26 using fileapi::FileSystemContext; | 27 using fileapi::FileSystemContext; |
27 using fileapi::FileSystemURL; | 28 using fileapi::FileSystemURL; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 195 |
195 const char kPath0[] = "file a"; | 196 const char kPath0[] = "file a"; |
196 const char kPath1[] = "dir a"; | 197 const char kPath1[] = "dir a"; |
197 const char kPath2[] = "dir a/dir"; | 198 const char kPath2[] = "dir a/dir"; |
198 const char kPath3[] = "dir a/file a"; | 199 const char kPath3[] = "dir a/file a"; |
199 const char kPath4[] = "dir a/file b"; | 200 const char kPath4[] = "dir a/file b"; |
200 | 201 |
201 file_system_.GetChangedURLsInTracker(&urls); | 202 file_system_.GetChangedURLsInTracker(&urls); |
202 ASSERT_EQ(0U, urls.size()); | 203 ASSERT_EQ(0U, urls.size()); |
203 | 204 |
204 const GURL blob_url("blob:test"); | |
205 const std::string kData("Lorem ipsum."); | 205 const std::string kData("Lorem ipsum."); |
206 MockBlobURLRequestContext url_request_context(file_system_context()); | 206 MockBlobURLRequestContext url_request_context(file_system_context()); |
207 ScopedTextBlob blob(url_request_context, blob_url, kData); | 207 ScopedTextBlob blob(url_request_context, "blob_id:test", kData); |
208 | 208 |
209 // Create files and nested directories. | 209 // Create files and nested directories. |
210 EXPECT_EQ(base::PLATFORM_FILE_OK, | 210 EXPECT_EQ(base::PLATFORM_FILE_OK, |
211 file_system_.CreateFile(URL(kPath0))); // Creates a file. | 211 file_system_.CreateFile(URL(kPath0))); // Creates a file. |
212 EXPECT_EQ(base::PLATFORM_FILE_OK, | 212 EXPECT_EQ(base::PLATFORM_FILE_OK, |
213 file_system_.CreateDirectory(URL(kPath1))); // Creates a dir. | 213 file_system_.CreateDirectory(URL(kPath1))); // Creates a dir. |
214 EXPECT_EQ(base::PLATFORM_FILE_OK, | 214 EXPECT_EQ(base::PLATFORM_FILE_OK, |
215 file_system_.CreateDirectory(URL(kPath2))); // Creates another dir. | 215 file_system_.CreateDirectory(URL(kPath2))); // Creates another dir. |
216 EXPECT_EQ(base::PLATFORM_FILE_OK, | 216 EXPECT_EQ(base::PLATFORM_FILE_OK, |
217 file_system_.CreateFile(URL(kPath3))); // Creates a file. | 217 file_system_.CreateFile(URL(kPath3))); // Creates a file. |
218 EXPECT_EQ(base::PLATFORM_FILE_OK, | 218 EXPECT_EQ(base::PLATFORM_FILE_OK, |
219 file_system_.TruncateFile(URL(kPath3), 1)); // Modifies the file. | 219 file_system_.TruncateFile(URL(kPath3), 1)); // Modifies the file. |
220 EXPECT_EQ(base::PLATFORM_FILE_OK, | 220 EXPECT_EQ(base::PLATFORM_FILE_OK, |
221 file_system_.CreateFile(URL(kPath4))); // Creates another file. | 221 file_system_.CreateFile(URL(kPath4))); // Creates another file. |
222 EXPECT_EQ(static_cast<int64>(kData.size()), | 222 EXPECT_EQ(static_cast<int64>(kData.size()), |
223 file_system_.Write(&url_request_context, | 223 file_system_.Write(&url_request_context, // Modifies the file. |
224 URL(kPath4), blob_url)); // Modifies the file. | 224 URL(kPath4), blob.GetBlobDataHandle())); |
225 | 225 |
226 // Verify the changes. | 226 // Verify the changes. |
227 file_system_.GetChangedURLsInTracker(&urls); | 227 file_system_.GetChangedURLsInTracker(&urls); |
228 EXPECT_EQ(5U, urls.size()); | 228 EXPECT_EQ(5U, urls.size()); |
229 | 229 |
230 // Reset the changes in in-memory tracker. | 230 // Reset the changes in in-memory tracker. |
231 DropChangesInTracker(); | 231 DropChangesInTracker(); |
232 | 232 |
233 // Make sure we have no in-memory changes in the tracker. | 233 // Make sure we have no in-memory changes in the tracker. |
234 file_system_.GetChangedURLsInTracker(&urls); | 234 file_system_.GetChangedURLsInTracker(&urls); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 ASSERT_EQ(2U, urls_to_process.size()); | 592 ASSERT_EQ(2U, urls_to_process.size()); |
593 | 593 |
594 // The exact order of recursive removal cannot be determined. | 594 // The exact order of recursive removal cannot be determined. |
595 EXPECT_TRUE(URL(kPath1) == urls_to_process[0] || | 595 EXPECT_TRUE(URL(kPath1) == urls_to_process[0] || |
596 URL(kPath2) == urls_to_process[0]); | 596 URL(kPath2) == urls_to_process[0]); |
597 EXPECT_TRUE(URL(kPath1) == urls_to_process[1] || | 597 EXPECT_TRUE(URL(kPath1) == urls_to_process[1] || |
598 URL(kPath2) == urls_to_process[1]); | 598 URL(kPath2) == urls_to_process[1]); |
599 } | 599 } |
600 | 600 |
601 } // namespace sync_file_system | 601 } // namespace sync_file_system |
OLD | NEW |