| 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 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "sync/test/engine/mock_connection_manager.h" | 24 #include "sync/test/engine/mock_connection_manager.h" |
| 25 #include "sync/test/engine/test_directory_setter_upper.h" | 25 #include "sync/test/engine/test_directory_setter_upper.h" |
| 26 #include "sync/test/fake_extensions_activity_monitor.h" | 26 #include "sync/test/fake_extensions_activity_monitor.h" |
| 27 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 29 |
| 30 using ::testing::NiceMock; | 30 using ::testing::NiceMock; |
| 31 | 31 |
| 32 namespace syncer { | 32 namespace syncer { |
| 33 | 33 |
| 34 class MockDebugInfoGetter : public syncer::sessions::DebugInfoGetter { | 34 class MockDebugInfoGetter : public sessions::DebugInfoGetter { |
| 35 public: | 35 public: |
| 36 MockDebugInfoGetter(); | 36 MockDebugInfoGetter(); |
| 37 virtual ~MockDebugInfoGetter(); | 37 virtual ~MockDebugInfoGetter(); |
| 38 MOCK_METHOD1(GetAndClearDebugInfo, void(sync_pb::DebugInfo* debug_info)); | 38 MOCK_METHOD1(GetAndClearDebugInfo, void(sync_pb::DebugInfo* debug_info)); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // A test fixture that simplifies writing unit tests for individual | 41 // A test fixture that simplifies writing unit tests for individual |
| 42 // SyncerCommands, providing convenient access to a test directory | 42 // SyncerCommands, providing convenient access to a test directory |
| 43 // and a syncer session. | 43 // and a syncer session. |
| 44 class SyncerCommandTestBase : public testing::Test, | 44 class SyncerCommandTestBase : public testing::Test, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 virtual ~SyncerCommandTestBase(); | 94 virtual ~SyncerCommandTestBase(); |
| 95 virtual void SetUp(); | 95 virtual void SetUp(); |
| 96 virtual void TearDown(); | 96 virtual void TearDown(); |
| 97 | 97 |
| 98 sessions::SyncSessionContext* context() const { return context_.get(); } | 98 sessions::SyncSessionContext* context() const { return context_.get(); } |
| 99 sessions::SyncSession::Delegate* delegate() { return this; } | 99 sessions::SyncSession::Delegate* delegate() { return this; } |
| 100 | 100 |
| 101 // Lazily create a session requesting all datatypes with no payload. | 101 // Lazily create a session requesting all datatypes with no payload. |
| 102 sessions::SyncSession* session() { | 102 sessions::SyncSession* session() { |
| 103 syncer::ModelTypePayloadMap types = | 103 ModelTypePayloadMap types = |
| 104 ModelSafeRoutingInfoToPayloadMap(routing_info_, std::string()); | 104 ModelSafeRoutingInfoToPayloadMap(routing_info_, std::string()); |
| 105 return session(sessions::SyncSourceInfo(types)); | 105 return session(sessions::SyncSourceInfo(types)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Create a session with the provided source. | 108 // Create a session with the provided source. |
| 109 sessions::SyncSession* session(const sessions::SyncSourceInfo& source) { | 109 sessions::SyncSession* session(const sessions::SyncSourceInfo& source) { |
| 110 if (!session_.get()) { | 110 if (!session_.get()) { |
| 111 std::vector<ModelSafeWorker*> workers = GetWorkers(); | 111 std::vector<ModelSafeWorker*> workers = GetWorkers(); |
| 112 session_.reset(new sessions::SyncSession(context(), delegate(), source, | 112 session_.reset(new sessions::SyncSession(context(), delegate(), source, |
| 113 routing_info_, workers)); | 113 routing_info_, workers)); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 virtual void SetUp() OVERRIDE; | 228 virtual void SetUp() OVERRIDE; |
| 229 | 229 |
| 230 TestUnrecoverableErrorHandler handler_; | 230 TestUnrecoverableErrorHandler handler_; |
| 231 syncable::MockDirectory mock_directory_; | 231 syncable::MockDirectory mock_directory_; |
| 232 }; | 232 }; |
| 233 | 233 |
| 234 } // namespace syncer | 234 } // namespace syncer |
| 235 | 235 |
| 236 #endif // SYNC_TEST_ENGINE_SYNCER_COMMAND_TEST_H_ | 236 #endif // SYNC_TEST_ENGINE_SYNCER_COMMAND_TEST_H_ |
| OLD | NEW |