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/drive_backend/conflict_resolver.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 typedef FakeRemoteChangeProcessor::URLToFileChangesMap URLToFileChangesMap; | 49 typedef FakeRemoteChangeProcessor::URLToFileChangesMap URLToFileChangesMap; |
50 | 50 |
51 ConflictResolverTest() | 51 ConflictResolverTest() |
52 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} | 52 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} |
53 virtual ~ConflictResolverTest() {} | 53 virtual ~ConflictResolverTest() {} |
54 | 54 |
55 virtual void SetUp() OVERRIDE { | 55 virtual void SetUp() OVERRIDE { |
56 ASSERT_TRUE(database_dir_.CreateUniqueTempDir()); | 56 ASSERT_TRUE(database_dir_.CreateUniqueTempDir()); |
57 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); | 57 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); |
58 | 58 |
59 fake_drive_service_.reset(new FakeDriveServiceWrapper); | 59 scoped_ptr<FakeDriveServiceWrapper> |
| 60 fake_drive_service(new FakeDriveServiceWrapper); |
60 | 61 |
61 drive_uploader_.reset(new FakeDriveUploader(fake_drive_service_.get())); | 62 drive_uploader_.reset(new FakeDriveUploader(fake_drive_service.get())); |
62 fake_drive_helper_.reset( | 63 fake_drive_helper_.reset( |
63 new FakeDriveServiceHelper(fake_drive_service_.get(), | 64 new FakeDriveServiceHelper(fake_drive_service.get(), |
64 drive_uploader_.get(), | 65 drive_uploader_.get(), |
65 kSyncRootFolderTitle)); | 66 kSyncRootFolderTitle)); |
66 fake_remote_change_processor_.reset(new FakeRemoteChangeProcessor); | 67 fake_remote_change_processor_.reset(new FakeRemoteChangeProcessor); |
67 | 68 |
68 context_.reset(new SyncEngineContext( | 69 context_.reset(new SyncEngineContext( |
69 fake_drive_service_.get(), | 70 fake_drive_service.PassAs<drive::DriveServiceInterface>(), |
70 drive_uploader_.get(), | 71 drive_uploader_.get(), |
71 base::MessageLoopProxy::current(), | 72 base::MessageLoopProxy::current(), |
72 base::MessageLoopProxy::current())); | 73 base::MessageLoopProxy::current())); |
73 context_->SetRemoteChangeProcessor(fake_remote_change_processor_.get()); | 74 context_->SetRemoteChangeProcessor(fake_remote_change_processor_.get()); |
74 | 75 |
75 RegisterSyncableFileSystem(); | 76 RegisterSyncableFileSystem(); |
76 | 77 |
77 sync_task_manager_.reset(new SyncTaskManager( | 78 sync_task_manager_.reset(new SyncTaskManager( |
78 base::WeakPtr<SyncTaskManager::Client>(), | 79 base::WeakPtr<SyncTaskManager::Client>(), |
79 10 /* maximum_background_task */)); | 80 10 /* maximum_background_task */)); |
80 sync_task_manager_->Initialize(SYNC_STATUS_OK); | 81 sync_task_manager_->Initialize(SYNC_STATUS_OK); |
81 } | 82 } |
82 | 83 |
83 virtual void TearDown() OVERRIDE { | 84 virtual void TearDown() OVERRIDE { |
84 sync_task_manager_.reset(); | 85 sync_task_manager_.reset(); |
85 fake_drive_service_.reset(); | |
86 drive_uploader_.reset(); | 86 drive_uploader_.reset(); |
87 | 87 |
88 RevokeSyncableFileSystem(); | 88 RevokeSyncableFileSystem(); |
89 | 89 |
90 fake_remote_change_processor_.reset(); | 90 fake_remote_change_processor_.reset(); |
91 fake_drive_helper_.reset(); | 91 fake_drive_helper_.reset(); |
92 context_.reset(); | 92 context_.reset(); |
93 base::RunLoop().RunUntilIdle(); | 93 base::RunLoop().RunUntilIdle(); |
94 } | 94 } |
95 | 95 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 const URLToFileChangesMap& expected_changes) { | 265 const URLToFileChangesMap& expected_changes) { |
266 fake_remote_change_processor_->VerifyConsistency(expected_changes); | 266 fake_remote_change_processor_->VerifyConsistency(expected_changes); |
267 } | 267 } |
268 | 268 |
269 private: | 269 private: |
270 content::TestBrowserThreadBundle thread_bundle_; | 270 content::TestBrowserThreadBundle thread_bundle_; |
271 base::ScopedTempDir database_dir_; | 271 base::ScopedTempDir database_dir_; |
272 scoped_ptr<leveldb::Env> in_memory_env_; | 272 scoped_ptr<leveldb::Env> in_memory_env_; |
273 | 273 |
274 scoped_ptr<SyncEngineContext> context_; | 274 scoped_ptr<SyncEngineContext> context_; |
275 scoped_ptr<FakeDriveServiceWrapper> fake_drive_service_; | |
276 scoped_ptr<drive::DriveUploaderInterface> drive_uploader_; | 275 scoped_ptr<drive::DriveUploaderInterface> drive_uploader_; |
277 scoped_ptr<FakeDriveServiceHelper> fake_drive_helper_; | 276 scoped_ptr<FakeDriveServiceHelper> fake_drive_helper_; |
278 scoped_ptr<FakeRemoteChangeProcessor> fake_remote_change_processor_; | 277 scoped_ptr<FakeRemoteChangeProcessor> fake_remote_change_processor_; |
279 | 278 |
280 scoped_ptr<SyncTaskManager> sync_task_manager_; | 279 scoped_ptr<SyncTaskManager> sync_task_manager_; |
281 | 280 |
282 DISALLOW_COPY_AND_ASSIGN(ConflictResolverTest); | 281 DISALLOW_COPY_AND_ASSIGN(ConflictResolverTest); |
283 }; | 282 }; |
284 | 283 |
285 TEST_F(ConflictResolverTest, NoFileToBeResolved) { | 284 TEST_F(ConflictResolverTest, NoFileToBeResolved) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 | 517 |
519 EXPECT_EQ(4, CountParents(file)); | 518 EXPECT_EQ(4, CountParents(file)); |
520 | 519 |
521 EXPECT_EQ(SYNC_STATUS_OK, RunConflictResolver()); | 520 EXPECT_EQ(SYNC_STATUS_OK, RunConflictResolver()); |
522 | 521 |
523 EXPECT_EQ(1, CountParents(file)); | 522 EXPECT_EQ(1, CountParents(file)); |
524 } | 523 } |
525 | 524 |
526 } // namespace drive_backend | 525 } // namespace drive_backend |
527 } // namespace sync_file_system | 526 } // namespace sync_file_system |
OLD | NEW |