| 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/sequenced_task_runner.h" | 7 #include "base/sequenced_task_runner.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "sync/engine/model_type_sync_proxy_impl.h" | 9 #include "sync/engine/model_type_sync_proxy_impl.h" |
| 10 #include "sync/internal_api/public/base/model_type.h" | 10 #include "sync/internal_api/public/base/model_type.h" |
| 11 #include "sync/internal_api/public/sync_context.h" | 11 #include "sync/internal_api/public/sync_context.h" |
| 12 #include "sync/internal_api/sync_context_proxy_impl.h" | 12 #include "sync/internal_api/sync_context_proxy_impl.h" |
| 13 #include "sync/sessions/model_type_registry.h" | 13 #include "sync/sessions/model_type_registry.h" |
| 14 #include "sync/test/engine/mock_nudge_handler.h" | 14 #include "sync/test/engine/mock_nudge_handler.h" |
| 15 #include "sync/test/engine/test_directory_setter_upper.h" | 15 #include "sync/test/engine/test_directory_setter_upper.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace syncer { | 18 namespace syncer { |
| 19 | 19 |
| 20 class SyncContextProxyImplTest : public ::testing::Test { | 20 class SyncContextProxyImplTest : public ::testing::Test { |
| 21 public: | 21 public: |
| 22 SyncContextProxyImplTest() | 22 SyncContextProxyImplTest() |
| 23 : sync_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 23 : sync_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 24 type_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 24 type_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
| 25 | 25 |
| 26 virtual void SetUp() { | 26 void SetUp() override { |
| 27 dir_maker_.SetUp(); | 27 dir_maker_.SetUp(); |
| 28 registry_.reset(new ModelTypeRegistry( | 28 registry_.reset(new ModelTypeRegistry( |
| 29 workers_, dir_maker_.directory(), &nudge_handler_)); | 29 workers_, dir_maker_.directory(), &nudge_handler_)); |
| 30 context_proxy_.reset( | 30 context_proxy_.reset( |
| 31 new SyncContextProxyImpl(sync_task_runner_, registry_->AsWeakPtr())); | 31 new SyncContextProxyImpl(sync_task_runner_, registry_->AsWeakPtr())); |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual void TearDown() { | 34 void TearDown() override { |
| 35 context_proxy_.reset(); | 35 context_proxy_.reset(); |
| 36 registry_.reset(); | 36 registry_.reset(); |
| 37 dir_maker_.TearDown(); | 37 dir_maker_.TearDown(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // The sync thread could be shut down at any time without warning. This | 40 // The sync thread could be shut down at any time without warning. This |
| 41 // function simulates such an event. | 41 // function simulates such an event. |
| 42 void DisableSync() { registry_.reset(); } | 42 void DisableSync() { registry_.reset(); } |
| 43 | 43 |
| 44 scoped_ptr<SyncContextProxy> GetProxy() { return context_proxy_->Clone(); } | 44 scoped_ptr<SyncContextProxy> GetProxy() { return context_proxy_->Clone(); } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 themes_sync_proxy->Enable(GetProxy()); | 98 themes_sync_proxy->Enable(GetProxy()); |
| 99 | 99 |
| 100 base::RunLoop run_loop_; | 100 base::RunLoop run_loop_; |
| 101 run_loop_.RunUntilIdle(); | 101 run_loop_.RunUntilIdle(); |
| 102 | 102 |
| 103 EXPECT_TRUE(themes_sync_proxy->IsConnected()); | 103 EXPECT_TRUE(themes_sync_proxy->IsConnected()); |
| 104 DisableSync(); | 104 DisableSync(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace syncer | 107 } // namespace syncer |
| OLD | NEW |