| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "sync/internal_api/public/activation_context.h" | 10 #include "sync/internal_api/public/activation_context.h" |
| 11 #include "sync/internal_api/public/base/model_type.h" | 11 #include "sync/internal_api/public/base/model_type.h" |
| 12 #include "sync/internal_api/public/shared_model_type_processor.h" | 12 #include "sync/internal_api/public/shared_model_type_processor.h" |
| 13 #include "sync/internal_api/public/sync_context.h" | 13 #include "sync/internal_api/public/sync_context.h" |
| 14 #include "sync/internal_api/public/test/fake_model_type_service.h" |
| 14 #include "sync/internal_api/sync_context_proxy_impl.h" | 15 #include "sync/internal_api/sync_context_proxy_impl.h" |
| 15 #include "sync/sessions/model_type_registry.h" | 16 #include "sync/sessions/model_type_registry.h" |
| 16 #include "sync/test/engine/mock_nudge_handler.h" | 17 #include "sync/test/engine/mock_nudge_handler.h" |
| 17 #include "sync/test/engine/test_directory_setter_upper.h" | 18 #include "sync/test/engine/test_directory_setter_upper.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 namespace syncer_v2 { | 21 namespace syncer_v2 { |
| 21 | 22 |
| 22 class SyncContextProxyImplTest : public ::testing::Test { | 23 class SyncContextProxyImplTest : public ::testing::Test, FakeModelTypeService { |
| 23 public: | 24 public: |
| 24 SyncContextProxyImplTest() | 25 SyncContextProxyImplTest() |
| 25 : sync_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 26 : sync_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 26 type_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 27 type_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
| 27 | 28 |
| 28 void SetUp() override { | 29 void SetUp() override { |
| 29 dir_maker_.SetUp(); | 30 dir_maker_.SetUp(); |
| 30 registry_.reset(new syncer::ModelTypeRegistry( | 31 registry_.reset(new syncer::ModelTypeRegistry( |
| 31 workers_, dir_maker_.directory(), &nudge_handler_)); | 32 workers_, dir_maker_.directory(), &nudge_handler_)); |
| 32 context_proxy_.reset( | 33 context_proxy_.reset( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 47 processor->Start(base::Bind(&SyncContextProxyImplTest::StartDone, | 48 processor->Start(base::Bind(&SyncContextProxyImplTest::StartDone, |
| 48 base::Unretained(this))); | 49 base::Unretained(this))); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void StartDone(syncer::SyncError error, | 52 void StartDone(syncer::SyncError error, |
| 52 scoped_ptr<ActivationContext> context) { | 53 scoped_ptr<ActivationContext> context) { |
| 53 context_proxy_->ConnectTypeToSync(syncer::THEMES, context.Pass()); | 54 context_proxy_->ConnectTypeToSync(syncer::THEMES, context.Pass()); |
| 54 } | 55 } |
| 55 | 56 |
| 56 scoped_ptr<SharedModelTypeProcessor> CreateModelTypeProcessor() { | 57 scoped_ptr<SharedModelTypeProcessor> CreateModelTypeProcessor() { |
| 57 return make_scoped_ptr(new SharedModelTypeProcessor( | 58 return make_scoped_ptr(new SharedModelTypeProcessor(syncer::THEMES, this)); |
| 58 syncer::THEMES, base::WeakPtr<ModelTypeStore>())); | |
| 59 } | 59 } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 base::MessageLoop loop_; | 62 base::MessageLoop loop_; |
| 63 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner_; | 63 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner_; |
| 64 scoped_refptr<base::SingleThreadTaskRunner> type_task_runner_; | 64 scoped_refptr<base::SingleThreadTaskRunner> type_task_runner_; |
| 65 | 65 |
| 66 std::vector<scoped_refptr<syncer::ModelSafeWorker>> workers_; | 66 std::vector<scoped_refptr<syncer::ModelSafeWorker>> workers_; |
| 67 syncer::TestDirectorySetterUpper dir_maker_; | 67 syncer::TestDirectorySetterUpper dir_maker_; |
| 68 syncer::MockNudgeHandler nudge_handler_; | 68 syncer::MockNudgeHandler nudge_handler_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 Start(processor.get()); | 111 Start(processor.get()); |
| 112 | 112 |
| 113 base::RunLoop run_loop_; | 113 base::RunLoop run_loop_; |
| 114 run_loop_.RunUntilIdle(); | 114 run_loop_.RunUntilIdle(); |
| 115 | 115 |
| 116 EXPECT_TRUE(processor->IsConnected()); | 116 EXPECT_TRUE(processor->IsConnected()); |
| 117 DisableSync(); | 117 DisableSync(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace syncer | 120 } // namespace syncer |
| OLD | NEW |