| 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 #ifndef SYNC_TEST_ENGINE_SYNCER_COMMAND_TEST_H_ | 5 #ifndef SYNC_TEST_ENGINE_SYNCER_COMMAND_TEST_H_ |
| 6 #define SYNC_TEST_ENGINE_SYNCER_COMMAND_TEST_H_ | 6 #define SYNC_TEST_ENGINE_SYNCER_COMMAND_TEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "sync/engine/model_changing_syncer_command.h" | 16 #include "sync/engine/model_changing_syncer_command.h" |
| 17 #include "sync/engine/model_safe_worker.h" | 17 #include "sync/engine/model_safe_worker.h" |
| 18 #include "sync/engine/traffic_recorder.h" |
| 18 #include "sync/sessions/debug_info_getter.h" | 19 #include "sync/sessions/debug_info_getter.h" |
| 19 #include "sync/sessions/sync_session.h" | 20 #include "sync/sessions/sync_session.h" |
| 20 #include "sync/sessions/sync_session_context.h" | 21 #include "sync/sessions/sync_session_context.h" |
| 21 #include "sync/syncable/syncable_mock.h" | 22 #include "sync/syncable/syncable_mock.h" |
| 22 #include "sync/test/engine/mock_connection_manager.h" | 23 #include "sync/test/engine/mock_connection_manager.h" |
| 23 #include "sync/test/engine/fake_model_worker.h" | 24 #include "sync/test/engine/fake_model_worker.h" |
| 24 #include "sync/test/engine/test_directory_setter_upper.h" | 25 #include "sync/test/engine/test_directory_setter_upper.h" |
| 25 #include "sync/test/fake_extensions_activity_monitor.h" | 26 #include "sync/test/fake_extensions_activity_monitor.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 120 |
| 120 void ClearSession() { | 121 void ClearSession() { |
| 121 session_.reset(); | 122 session_.reset(); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void ResetContext() { | 125 void ResetContext() { |
| 125 context_.reset(new sessions::SyncSessionContext( | 126 context_.reset(new sessions::SyncSessionContext( |
| 126 mock_server_.get(), directory(), | 127 mock_server_.get(), directory(), |
| 127 registrar(), &extensions_activity_monitor_, | 128 registrar(), &extensions_activity_monitor_, |
| 128 std::vector<SyncEngineEventListener*>(), | 129 std::vector<SyncEngineEventListener*>(), |
| 129 &mock_debug_info_getter_)); | 130 &mock_debug_info_getter_, |
| 131 &traffic_recorder_)); |
| 130 context_->set_account_name(directory()->name()); | 132 context_->set_account_name(directory()->name()); |
| 131 ClearSession(); | 133 ClearSession(); |
| 132 } | 134 } |
| 133 | 135 |
| 134 // Install a MockServerConnection. Resets the context. By default, | 136 // Install a MockServerConnection. Resets the context. By default, |
| 135 // the context does not have a MockServerConnection attached. | 137 // the context does not have a MockServerConnection attached. |
| 136 void ConfigureMockServerConnection() { | 138 void ConfigureMockServerConnection() { |
| 137 mock_server_.reset(new MockConnectionManager(directory())); | 139 mock_server_.reset(new MockConnectionManager(directory())); |
| 138 ResetContext(); | 140 ResetContext(); |
| 139 } | 141 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 194 |
| 193 private: | 195 private: |
| 194 MessageLoop message_loop_; | 196 MessageLoop message_loop_; |
| 195 scoped_ptr<sessions::SyncSessionContext> context_; | 197 scoped_ptr<sessions::SyncSessionContext> context_; |
| 196 scoped_ptr<MockConnectionManager> mock_server_; | 198 scoped_ptr<MockConnectionManager> mock_server_; |
| 197 scoped_ptr<sessions::SyncSession> session_; | 199 scoped_ptr<sessions::SyncSession> session_; |
| 198 std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 200 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
| 199 ModelSafeRoutingInfo routing_info_; | 201 ModelSafeRoutingInfo routing_info_; |
| 200 NiceMock<MockDebugInfoGetter> mock_debug_info_getter_; | 202 NiceMock<MockDebugInfoGetter> mock_debug_info_getter_; |
| 201 FakeExtensionsActivityMonitor extensions_activity_monitor_; | 203 FakeExtensionsActivityMonitor extensions_activity_monitor_; |
| 204 TrafficRecorder traffic_recorder_; |
| 202 DISALLOW_COPY_AND_ASSIGN(SyncerCommandTestBase); | 205 DISALLOW_COPY_AND_ASSIGN(SyncerCommandTestBase); |
| 203 }; | 206 }; |
| 204 | 207 |
| 205 class SyncerCommandTest : public SyncerCommandTestBase { | 208 class SyncerCommandTest : public SyncerCommandTestBase { |
| 206 public: | 209 public: |
| 207 virtual void SetUp() OVERRIDE; | 210 virtual void SetUp() OVERRIDE; |
| 208 virtual void TearDown() OVERRIDE; | 211 virtual void TearDown() OVERRIDE; |
| 209 virtual Directory* directory() OVERRIDE; | 212 virtual Directory* directory() OVERRIDE; |
| 210 | 213 |
| 211 private: | 214 private: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 224 | 227 |
| 225 virtual void SetUp() OVERRIDE; | 228 virtual void SetUp() OVERRIDE; |
| 226 | 229 |
| 227 TestUnrecoverableErrorHandler handler_; | 230 TestUnrecoverableErrorHandler handler_; |
| 228 MockDirectory mock_directory_; | 231 MockDirectory mock_directory_; |
| 229 }; | 232 }; |
| 230 | 233 |
| 231 } // namespace browser_sync | 234 } // namespace browser_sync |
| 232 | 235 |
| 233 #endif // SYNC_TEST_ENGINE_SYNCER_COMMAND_TEST_H_ | 236 #endif // SYNC_TEST_ENGINE_SYNCER_COMMAND_TEST_H_ |
| OLD | NEW |