| 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 "chrome/browser/sync_file_system/sync_file_system_service.h" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 | 8 #include <utility> |
| 7 #include <vector> | 9 #include <vector> |
| 8 | 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 11 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 12 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 13 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
| 15 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" | 17 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" |
| 16 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 18 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
| 17 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h" | 19 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h" |
| 18 #include "chrome/browser/sync_file_system/local/mock_sync_status_observer.h" | 20 #include "chrome/browser/sync_file_system/local/mock_sync_status_observer.h" |
| 19 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 21 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
| 20 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" | 22 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" |
| 21 #include "chrome/browser/sync_file_system/sync_callbacks.h" | 23 #include "chrome/browser/sync_file_system/sync_callbacks.h" |
| 22 #include "chrome/browser/sync_file_system/sync_event_observer.h" | 24 #include "chrome/browser/sync_file_system/sync_event_observer.h" |
| 23 #include "chrome/browser/sync_file_system/sync_file_metadata.h" | 25 #include "chrome/browser/sync_file_system/sync_file_metadata.h" |
| 24 #include "chrome/browser/sync_file_system/sync_file_system_service.h" | |
| 25 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" | 26 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" |
| 26 #include "chrome/browser/sync_file_system/sync_status_code.h" | 27 #include "chrome/browser/sync_file_system/sync_status_code.h" |
| 27 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 28 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
| 28 #include "chrome/test/base/testing_profile.h" | 29 #include "chrome/test/base/testing_profile.h" |
| 29 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/test/test_browser_thread_bundle.h" | 31 #include "content/public/test/test_browser_thread_bundle.h" |
| 31 #include "content/public/test/test_utils.h" | 32 #include "content/public/test/test_utils.h" |
| 32 #include "storage/browser/fileapi/file_system_context.h" | 33 #include "storage/browser/fileapi/file_system_context.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" | 35 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 AddServiceObserver(_)).Times(1); | 150 AddServiceObserver(_)).Times(1); |
| 150 EXPECT_CALL(*mock_remote_service(), | 151 EXPECT_CALL(*mock_remote_service(), |
| 151 AddFileStatusObserver(sync_service_.get())).Times(1); | 152 AddFileStatusObserver(sync_service_.get())).Times(1); |
| 152 EXPECT_CALL(*mock_remote_service(), | 153 EXPECT_CALL(*mock_remote_service(), |
| 153 GetLocalChangeProcessor()) | 154 GetLocalChangeProcessor()) |
| 154 .WillRepeatedly(Return(&local_change_processor_)); | 155 .WillRepeatedly(Return(&local_change_processor_)); |
| 155 EXPECT_CALL(*mock_remote_service(), | 156 EXPECT_CALL(*mock_remote_service(), |
| 156 SetRemoteChangeProcessor(local_service.get())).Times(1); | 157 SetRemoteChangeProcessor(local_service.get())).Times(1); |
| 157 | 158 |
| 158 sync_service_->Initialize( | 159 sync_service_->Initialize( |
| 159 local_service.Pass(), | 160 std::move(local_service), |
| 160 scoped_ptr<RemoteFileSyncService>(remote_service_)); | 161 scoped_ptr<RemoteFileSyncService>(remote_service_)); |
| 161 | 162 |
| 162 // Disable auto sync by default. | 163 // Disable auto sync by default. |
| 163 EXPECT_CALL(*mock_remote_service(), SetSyncEnabled(false)).Times(1); | 164 EXPECT_CALL(*mock_remote_service(), SetSyncEnabled(false)).Times(1); |
| 164 sync_service_->SetSyncEnabledForTesting(false); | 165 sync_service_->SetSyncEnabledForTesting(false); |
| 165 | 166 |
| 166 file_system_->SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); | 167 file_system_->SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); |
| 167 } | 168 } |
| 168 | 169 |
| 169 void TearDown() override { | 170 void TearDown() override { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 base::Bind(&AssignValueAndQuit<SyncFileStatus>, | 483 base::Bind(&AssignValueAndQuit<SyncFileStatus>, |
| 483 &run_loop, &status, &sync_file_status)); | 484 &run_loop, &status, &sync_file_status)); |
| 484 run_loop.Run(); | 485 run_loop.Run(); |
| 485 | 486 |
| 486 EXPECT_EQ(SYNC_STATUS_OK, status); | 487 EXPECT_EQ(SYNC_STATUS_OK, status); |
| 487 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status); | 488 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status); |
| 488 } | 489 } |
| 489 } | 490 } |
| 490 | 491 |
| 491 } // namespace sync_file_system | 492 } // namespace sync_file_system |
| OLD | NEW |