| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/sync_file_system/sync_file_metadata.h" | 24 #include "chrome/browser/sync_file_system/sync_file_metadata.h" |
| 25 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" | 25 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" |
| 26 #include "chrome/browser/sync_file_system/sync_status_code.h" | 26 #include "chrome/browser/sync_file_system/sync_status_code.h" |
| 27 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 27 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
| 28 #include "chrome/test/base/testing_profile.h" | 28 #include "chrome/test/base/testing_profile.h" |
| 29 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/test/test_browser_thread_bundle.h" | 30 #include "content/public/test/test_browser_thread_bundle.h" |
| 31 #include "content/public/test/test_utils.h" | 31 #include "content/public/test/test_utils.h" |
| 32 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
| 35 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
| 34 #include "webkit/browser/fileapi/file_system_context.h" | 36 #include "webkit/browser/fileapi/file_system_context.h" |
| 35 | 37 |
| 36 using content::BrowserThread; | 38 using content::BrowserThread; |
| 37 using fileapi::FileSystemURL; | 39 using fileapi::FileSystemURL; |
| 38 using ::testing::_; | 40 using ::testing::_; |
| 39 using ::testing::AtLeast; | 41 using ::testing::AtLeast; |
| 40 using ::testing::InvokeWithoutArgs; | 42 using ::testing::InvokeWithoutArgs; |
| 41 using ::testing::StrictMock; | 43 using ::testing::StrictMock; |
| 42 | 44 |
| 43 namespace sync_file_system { | 45 namespace sync_file_system { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 : public testing::Test, | 104 : public testing::Test, |
| 103 public LocalFileSyncService::Observer { | 105 public LocalFileSyncService::Observer { |
| 104 protected: | 106 protected: |
| 105 LocalFileSyncServiceTest() | 107 LocalFileSyncServiceTest() |
| 106 : thread_bundle_(content::TestBrowserThreadBundle::REAL_FILE_THREAD | | 108 : thread_bundle_(content::TestBrowserThreadBundle::REAL_FILE_THREAD | |
| 107 content::TestBrowserThreadBundle::REAL_IO_THREAD), | 109 content::TestBrowserThreadBundle::REAL_IO_THREAD), |
| 108 num_changes_(0) {} | 110 num_changes_(0) {} |
| 109 | 111 |
| 110 virtual void SetUp() OVERRIDE { | 112 virtual void SetUp() OVERRIDE { |
| 111 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 113 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 114 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); |
| 112 | 115 |
| 113 file_system_.reset(new CannedSyncableFileSystem( | 116 file_system_.reset(new CannedSyncableFileSystem( |
| 114 GURL(kOrigin), | 117 GURL(kOrigin), |
| 118 in_memory_env_.get(), |
| 115 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 119 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
| 116 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); | 120 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); |
| 117 | 121 |
| 118 local_service_.reset(new LocalFileSyncService(&profile_)); | 122 local_service_ = LocalFileSyncService::CreateForTesting( |
| 123 &profile_, in_memory_env_.get()); |
| 119 | 124 |
| 120 file_system_->SetUp(); | 125 file_system_->SetUp(); |
| 121 | 126 |
| 122 base::RunLoop run_loop; | 127 base::RunLoop run_loop; |
| 123 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 128 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
| 124 local_service_->MaybeInitializeFileSystemContext( | 129 local_service_->MaybeInitializeFileSystemContext( |
| 125 GURL(kOrigin), file_system_->file_system_context(), | 130 GURL(kOrigin), file_system_->file_system_context(), |
| 126 AssignAndQuitCallback(&run_loop, &status)); | 131 AssignAndQuitCallback(&run_loop, &status)); |
| 127 run_loop.Run(); | 132 run_loop.Run(); |
| 128 | 133 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 return sync_status; | 190 return sync_status; |
| 186 } | 191 } |
| 187 | 192 |
| 188 int64 GetNumChangesInTracker() const { | 193 int64 GetNumChangesInTracker() const { |
| 189 return file_system_->backend()->change_tracker()->num_changes(); | 194 return file_system_->backend()->change_tracker()->num_changes(); |
| 190 } | 195 } |
| 191 | 196 |
| 192 content::TestBrowserThreadBundle thread_bundle_; | 197 content::TestBrowserThreadBundle thread_bundle_; |
| 193 | 198 |
| 194 ScopedEnableSyncFSDirectoryOperation enable_directory_operation_; | 199 ScopedEnableSyncFSDirectoryOperation enable_directory_operation_; |
| 200 base::ScopedTempDir temp_dir_; |
| 201 scoped_ptr<leveldb::Env> in_memory_env_; |
| 195 TestingProfile profile_; | 202 TestingProfile profile_; |
| 196 | 203 |
| 197 base::ScopedTempDir temp_dir_; | |
| 198 | |
| 199 scoped_ptr<CannedSyncableFileSystem> file_system_; | 204 scoped_ptr<CannedSyncableFileSystem> file_system_; |
| 200 scoped_ptr<LocalFileSyncService> local_service_; | 205 scoped_ptr<LocalFileSyncService> local_service_; |
| 201 | 206 |
| 202 int64 num_changes_; | 207 int64 num_changes_; |
| 203 }; | 208 }; |
| 204 | 209 |
| 205 // More complete tests for PrepareForProcessRemoteChange and ApplyRemoteChange | 210 // More complete tests for PrepareForProcessRemoteChange and ApplyRemoteChange |
| 206 // are also in content_unittest:LocalFileSyncContextTest. | 211 // are also in content_unittest:LocalFileSyncContextTest. |
| 207 TEST_F(LocalFileSyncServiceTest, RemoteSyncStepsSimple) { | 212 TEST_F(LocalFileSyncServiceTest, RemoteSyncStepsSimple) { |
| 208 const FileSystemURL kFile(file_system_->URL("file")); | 213 const FileSystemURL kFile(file_system_->URL("file")); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 DISABLED_LocalChangeObserverMultipleContexts | 292 DISABLED_LocalChangeObserverMultipleContexts |
| 288 #else | 293 #else |
| 289 #define MAYBE_LocalChangeObserverMultipleContexts\ | 294 #define MAYBE_LocalChangeObserverMultipleContexts\ |
| 290 LocalChangeObserverMultipleContexts | 295 LocalChangeObserverMultipleContexts |
| 291 #endif | 296 #endif |
| 292 | 297 |
| 293 TEST_F(LocalFileSyncServiceTest, MAYBE_LocalChangeObserverMultipleContexts) { | 298 TEST_F(LocalFileSyncServiceTest, MAYBE_LocalChangeObserverMultipleContexts) { |
| 294 const char kOrigin2[] = "http://foo"; | 299 const char kOrigin2[] = "http://foo"; |
| 295 CannedSyncableFileSystem file_system2( | 300 CannedSyncableFileSystem file_system2( |
| 296 GURL(kOrigin2), | 301 GURL(kOrigin2), |
| 302 in_memory_env_.get(), |
| 297 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 303 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
| 298 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 304 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
| 299 file_system2.SetUp(); | 305 file_system2.SetUp(); |
| 300 | 306 |
| 301 base::RunLoop run_loop; | 307 base::RunLoop run_loop; |
| 302 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 308 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
| 303 local_service_->MaybeInitializeFileSystemContext( | 309 local_service_->MaybeInitializeFileSystemContext( |
| 304 GURL(kOrigin2), file_system2.file_system_context(), | 310 GURL(kOrigin2), file_system2.file_system_context(), |
| 305 AssignAndQuitCallback(&run_loop, &status)); | 311 AssignAndQuitCallback(&run_loop, &status)); |
| 306 run_loop.Run(); | 312 run_loop.Run(); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 all_origins.insert(kOrigin2); | 727 all_origins.insert(kOrigin2); |
| 722 all_origins.insert(kOrigin3); | 728 all_origins.insert(kOrigin3); |
| 723 while (!all_origins.empty()) { | 729 while (!all_origins.empty()) { |
| 724 ASSERT_TRUE(NextOriginToProcess(&origin)); | 730 ASSERT_TRUE(NextOriginToProcess(&origin)); |
| 725 ASSERT_TRUE(ContainsKey(all_origins, origin)); | 731 ASSERT_TRUE(ContainsKey(all_origins, origin)); |
| 726 all_origins.erase(origin); | 732 all_origins.erase(origin); |
| 727 } | 733 } |
| 728 } | 734 } |
| 729 | 735 |
| 730 } // namespace sync_file_system | 736 } // namespace sync_file_system |
| OLD | NEW |