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

Side by Side Diff: chrome/browser/sync_file_system/local_file_sync_service_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 (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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "chrome/browser/sync_file_system/local_file_sync_service.h" 13 #include "chrome/browser/sync_file_system/local_file_sync_service.h"
14 #include "chrome/browser/sync_file_system/mock_local_change_processor.h" 14 #include "chrome/browser/sync_file_system/mock_local_change_processor.h"
15 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" 15 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
16 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "webkit/browser/fileapi/file_system_context.h" 19 #include "webkit/browser/fileapi/file_system_context.h"
20 #include "webkit/browser/fileapi/syncable/canned_syncable_file_system.h" 20 #include "webkit/browser/fileapi/syncable/canned_syncable_file_system.h"
21 #include "webkit/browser/fileapi/syncable/file_change.h" 21 #include "webkit/browser/fileapi/syncable/file_change.h"
22 #include "webkit/browser/fileapi/syncable/local_file_change_tracker.h" 22 #include "webkit/browser/fileapi/syncable/local_file_change_tracker.h"
23 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h" 23 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h"
24 #include "webkit/browser/fileapi/syncable/local_file_sync_status.h" 24 #include "webkit/browser/fileapi/syncable/local_file_sync_status.h"
25 #include "webkit/browser/fileapi/syncable/mock_sync_status_observer.h" 25 #include "webkit/browser/fileapi/syncable/mock_sync_status_observer.h"
26 #include "webkit/browser/fileapi/syncable/sync_file_metadata.h" 26 #include "webkit/browser/fileapi/syncable/sync_file_metadata.h"
27 #include "webkit/browser/fileapi/syncable/sync_file_system_backend.h"
27 #include "webkit/browser/fileapi/syncable/sync_status_code.h" 28 #include "webkit/browser/fileapi/syncable/sync_status_code.h"
28 #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h" 29 #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h"
29 30
30 using fileapi::FileSystemURL; 31 using fileapi::FileSystemURL;
31 using ::testing::_; 32 using ::testing::_;
32 using ::testing::AtLeast; 33 using ::testing::AtLeast;
33 using ::testing::InvokeWithoutArgs; 34 using ::testing::InvokeWithoutArgs;
34 using ::testing::StrictMock; 35 using ::testing::StrictMock;
35 36
36 namespace sync_file_system { 37 namespace sync_file_system {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 118 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
118 local_service_->MaybeInitializeFileSystemContext( 119 local_service_->MaybeInitializeFileSystemContext(
119 GURL(kOrigin), file_system_->file_system_context(), 120 GURL(kOrigin), file_system_->file_system_context(),
120 AssignAndQuitCallback(&run_loop, &status)); 121 AssignAndQuitCallback(&run_loop, &status));
121 run_loop.Run(); 122 run_loop.Run();
122 123
123 local_service_->AddChangeObserver(this); 124 local_service_->AddChangeObserver(this);
124 125
125 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->OpenFileSystem()); 126 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->OpenFileSystem());
126 127
127 file_system_->file_system_context()->sync_context()-> 128 file_system_->backend()->sync_context()->
128 set_mock_notify_changes_duration_in_sec(0); 129 set_mock_notify_changes_duration_in_sec(0);
129 } 130 }
130 131
131 virtual void TearDown() OVERRIDE { 132 virtual void TearDown() OVERRIDE {
132 local_service_->Shutdown(); 133 local_service_->Shutdown();
133 file_system_->TearDown(); 134 file_system_->TearDown();
134 RevokeSyncableFileSystem(); 135 RevokeSyncableFileSystem();
135 136
136 thread_helper_.TearDown(); 137 thread_helper_.TearDown();
137 } 138 }
(...skipping 25 matching lines...) Expand all
163 base::RunLoop run_loop; 164 base::RunLoop run_loop;
164 SyncStatusCode sync_status = SYNC_STATUS_UNKNOWN; 165 SyncStatusCode sync_status = SYNC_STATUS_UNKNOWN;
165 local_service_->ApplyRemoteChange( 166 local_service_->ApplyRemoteChange(
166 change, local_path, url, 167 change, local_path, url,
167 AssignAndQuitCallback(&run_loop, &sync_status)); 168 AssignAndQuitCallback(&run_loop, &sync_status));
168 run_loop.Run(); 169 run_loop.Run();
169 return sync_status; 170 return sync_status;
170 } 171 }
171 172
172 int64 GetNumChangesInTracker() const { 173 int64 GetNumChangesInTracker() const {
173 return file_system_->file_system_context()->change_tracker()->num_changes(); 174 return file_system_->backend()->change_tracker()->num_changes();
174 } 175 }
175 176
176 ScopedEnableSyncFSDirectoryOperation enable_directory_operation_; 177 ScopedEnableSyncFSDirectoryOperation enable_directory_operation_;
177 TestingProfile profile_; 178 TestingProfile profile_;
178 179
179 MultiThreadTestHelper thread_helper_; 180 MultiThreadTestHelper thread_helper_;
180 181
181 base::ScopedTempDir temp_dir_; 182 base::ScopedTempDir temp_dir_;
182 183
183 scoped_ptr<CannedSyncableFileSystem> file_system_; 184 scoped_ptr<CannedSyncableFileSystem> file_system_;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 file_system2.SetUp(); 284 file_system2.SetUp();
284 285
285 base::RunLoop run_loop; 286 base::RunLoop run_loop;
286 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 287 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
287 local_service_->MaybeInitializeFileSystemContext( 288 local_service_->MaybeInitializeFileSystemContext(
288 GURL(kOrigin2), file_system2.file_system_context(), 289 GURL(kOrigin2), file_system2.file_system_context(),
289 AssignAndQuitCallback(&run_loop, &status)); 290 AssignAndQuitCallback(&run_loop, &status));
290 run_loop.Run(); 291 run_loop.Run();
291 292
292 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system2.OpenFileSystem()); 293 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system2.OpenFileSystem());
293 file_system2.file_system_context()->sync_context()-> 294 file_system2.backend()->sync_context()->
294 set_mock_notify_changes_duration_in_sec(0); 295 set_mock_notify_changes_duration_in_sec(0);
295 296
296 const FileSystemURL kFile1(file_system_->URL("file1")); 297 const FileSystemURL kFile1(file_system_->URL("file1"));
297 const FileSystemURL kFile2(file_system_->URL("file2")); 298 const FileSystemURL kFile2(file_system_->URL("file2"));
298 const FileSystemURL kFile3(file_system2.URL("file3")); 299 const FileSystemURL kFile3(file_system2.URL("file3"));
299 const FileSystemURL kFile4(file_system2.URL("file4")); 300 const FileSystemURL kFile4(file_system2.URL("file4"));
300 301
301 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile1)); 302 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile1));
302 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile2)); 303 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile2));
303 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system2.CreateFile(kFile3)); 304 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system2.CreateFile(kFile3));
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 all_origins.insert(kOrigin2); 698 all_origins.insert(kOrigin2);
698 all_origins.insert(kOrigin3); 699 all_origins.insert(kOrigin3);
699 while (!all_origins.empty()) { 700 while (!all_origins.empty()) {
700 ASSERT_TRUE(NextOriginToProcess(&origin)); 701 ASSERT_TRUE(NextOriginToProcess(&origin));
701 ASSERT_TRUE(ContainsKey(all_origins, origin)); 702 ASSERT_TRUE(ContainsKey(all_origins, origin));
702 all_origins.erase(origin); 703 all_origins.erase(origin);
703 } 704 }
704 } 705 }
705 706
706 } // namespace sync_file_system 707 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698