Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: webkit/browser/fileapi/syncable/local_file_sync_context_unittest.cc

Issue 18668003: SyncFS: Introduce SyncFileSystemBackend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lazy initialization Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "webkit/browser/fileapi/syncable/local_file_sync_context.h" 5 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/platform_file.h" 13 #include "base/platform_file.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webkit/browser/blob/mock_blob_url_request_context.h" 18 #include "webkit/browser/blob/mock_blob_url_request_context.h"
19 #include "webkit/browser/fileapi/file_system_context.h" 19 #include "webkit/browser/fileapi/file_system_context.h"
20 #include "webkit/browser/fileapi/file_system_operation_runner.h" 20 #include "webkit/browser/fileapi/file_system_operation_runner.h"
21 #include "webkit/browser/fileapi/isolated_context.h" 21 #include "webkit/browser/fileapi/isolated_context.h"
22 #include "webkit/browser/fileapi/syncable/canned_syncable_file_system.h" 22 #include "webkit/browser/fileapi/syncable/canned_syncable_file_system.h"
23 #include "webkit/browser/fileapi/syncable/file_change.h" 23 #include "webkit/browser/fileapi/syncable/file_change.h"
24 #include "webkit/browser/fileapi/syncable/local_file_change_tracker.h" 24 #include "webkit/browser/fileapi/syncable/local_file_change_tracker.h"
25 #include "webkit/browser/fileapi/syncable/sync_file_metadata.h" 25 #include "webkit/browser/fileapi/syncable/sync_file_metadata.h"
26 #include "webkit/browser/fileapi/syncable/sync_file_system_backend.h"
26 #include "webkit/browser/fileapi/syncable/sync_status_code.h" 27 #include "webkit/browser/fileapi/syncable/sync_status_code.h"
27 #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h" 28 #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h"
28 29
29 #define FPL FILE_PATH_LITERAL 30 #define FPL FILE_PATH_LITERAL
30 31
31 using fileapi::FileSystemContext; 32 using fileapi::FileSystemContext;
32 using fileapi::FileSystemURL; 33 using fileapi::FileSystemURL;
33 using fileapi::FileSystemURLSet; 34 using fileapi::FileSystemURLSet;
34 35
35 // This tests LocalFileSyncContext behavior in multi-thread / 36 // This tests LocalFileSyncContext behavior in multi-thread /
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 222
222 sync_context_ = 223 sync_context_ =
223 new LocalFileSyncContext(ui_task_runner_.get(), io_task_runner_.get()); 224 new LocalFileSyncContext(ui_task_runner_.get(), io_task_runner_.get());
224 225
225 // Initializes file_system using |sync_context_|. 226 // Initializes file_system using |sync_context_|.
226 EXPECT_EQ(SYNC_STATUS_OK, 227 EXPECT_EQ(SYNC_STATUS_OK,
227 file_system.MaybeInitializeFileSystemContext(sync_context_.get())); 228 file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
228 229
229 // Make sure everything's set up for file_system to be able to handle 230 // Make sure everything's set up for file_system to be able to handle
230 // syncable file system operations. 231 // syncable file system operations.
231 EXPECT_TRUE(file_system.file_system_context()->sync_context() != NULL); 232 EXPECT_TRUE(file_system.backend()->sync_context() != NULL);
232 EXPECT_TRUE(file_system.file_system_context()->change_tracker() != NULL); 233 EXPECT_TRUE(file_system.backend()->change_tracker() != NULL);
233 EXPECT_EQ(sync_context_.get(), 234 EXPECT_EQ(sync_context_.get(), file_system.backend()->sync_context());
234 file_system.file_system_context()->sync_context());
235 235
236 // Calling MaybeInitialize for the same context multiple times must be ok. 236 // Calling MaybeInitialize for the same context multiple times must be ok.
237 EXPECT_EQ(SYNC_STATUS_OK, 237 EXPECT_EQ(SYNC_STATUS_OK,
238 file_system.MaybeInitializeFileSystemContext(sync_context_.get())); 238 file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
239 EXPECT_EQ(sync_context_.get(), 239 EXPECT_EQ(sync_context_.get(), file_system.backend()->sync_context());
240 file_system.file_system_context()->sync_context());
241 240
242 // Opens the file_system, perform some operation and see if the change tracker 241 // Opens the file_system, perform some operation and see if the change tracker
243 // correctly captures the change. 242 // correctly captures the change.
244 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.OpenFileSystem()); 243 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.OpenFileSystem());
245 244
246 const FileSystemURL kURL(file_system.URL("foo")); 245 const FileSystemURL kURL(file_system.URL("foo"));
247 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.CreateFile(kURL)); 246 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.CreateFile(kURL));
248 247
249 FileSystemURLSet urls; 248 FileSystemURLSet urls;
250 file_system.GetChangedURLsInTracker(&urls); 249 file_system.GetChangedURLsInTracker(&urls);
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 685
687 // Make sure kDir and kFile are created by ApplyRemoteChange. 686 // Make sure kDir and kFile are created by ApplyRemoteChange.
688 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.FileExists(kFile)); 687 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.FileExists(kFile));
689 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.DirectoryExists(kDir)); 688 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.DirectoryExists(kDir));
690 689
691 sync_context_->ShutdownOnUIThread(); 690 sync_context_->ShutdownOnUIThread();
692 file_system.TearDown(); 691 file_system.TearDown();
693 } 692 }
694 693
695 } // namespace sync_file_system 694 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698