| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ | 5 #ifndef CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ |
| 6 #define CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ | 6 #define CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <algorithm> |
| 10 #include <string> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 #include "chrome/browser/sync/engine/model_safe_worker.h" | 13 #include "chrome/browser/sync/engine/model_safe_worker.h" |
| 12 #include "chrome/browser/sync/sessions/sync_session.h" | 14 #include "chrome/browser/sync/sessions/sync_session.h" |
| 13 #include "chrome/browser/sync/sessions/sync_session_context.h" | 15 #include "chrome/browser/sync/sessions/sync_session_context.h" |
| 14 #include "chrome/test/sync/engine/mock_connection_manager.h" | 16 #include "chrome/test/sync/engine/mock_connection_manager.h" |
| 15 #include "chrome/test/sync/engine/test_directory_setter_upper.h" | 17 #include "chrome/test/sync/engine/test_directory_setter_upper.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 19 |
| 18 namespace browser_sync { | 20 namespace browser_sync { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 ResetContext(); | 77 ResetContext(); |
| 76 } | 78 } |
| 77 virtual void TearDown() { | 79 virtual void TearDown() { |
| 78 syncdb_->TearDown(); | 80 syncdb_->TearDown(); |
| 79 } | 81 } |
| 80 | 82 |
| 81 TestDirectorySetterUpper* syncdb() { return syncdb_.get(); } | 83 TestDirectorySetterUpper* syncdb() { return syncdb_.get(); } |
| 82 sessions::SyncSessionContext* context() const { return context_.get(); } | 84 sessions::SyncSessionContext* context() const { return context_.get(); } |
| 83 sessions::SyncSession::Delegate* delegate() { return this; } | 85 sessions::SyncSession::Delegate* delegate() { return this; } |
| 84 ModelSafeWorkerRegistrar* registrar() { return this; } | 86 ModelSafeWorkerRegistrar* registrar() { return this; } |
| 85 // Lazily create a session. | 87 // Lazily create a session requesting all datatypes. |
| 86 sessions::SyncSession* session() { | 88 sessions::SyncSession* session() { |
| 87 if (!session_.get()) { | 89 if (!session_.get()) { |
| 88 std::vector<ModelSafeWorker*> workers; | 90 std::vector<ModelSafeWorker*> workers; |
| 89 GetWorkers(&workers); | 91 GetWorkers(&workers); |
| 92 ModelSafeRoutingInfo routes = routing_info(); |
| 93 sessions::TypePayloadMap types = |
| 94 sessions::RoutingInfoToTypePayloadMap(routes, std::string()); |
| 90 session_.reset(new sessions::SyncSession(context(), delegate(), | 95 session_.reset(new sessions::SyncSession(context(), delegate(), |
| 91 sessions::SyncSourceInfo(), routing_info_, workers)); | 96 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, |
| 97 types), |
| 98 routing_info_, workers)); |
| 92 } | 99 } |
| 93 return session_.get(); | 100 return session_.get(); |
| 94 } | 101 } |
| 95 void ClearSession() { | 102 void ClearSession() { |
| 96 session_.reset(); | 103 session_.reset(); |
| 97 } | 104 } |
| 98 | 105 |
| 99 void ResetContext() { | 106 void ResetContext() { |
| 100 context_.reset(new sessions::SyncSessionContext( | 107 context_.reset(new sessions::SyncSessionContext( |
| 101 mock_server_.get(), syncdb_->manager(), registrar(), | 108 mock_server_.get(), syncdb_->manager(), registrar(), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 : SyncerCommandTestWithParam<void*>( | 149 : SyncerCommandTestWithParam<void*>( |
| 143 SyncerCommandTestWithParam<void*>::USE_MOCK_DIRECTORY) {} | 150 SyncerCommandTestWithParam<void*>::USE_MOCK_DIRECTORY) {} |
| 144 MockDirectorySetterUpper::MockDirectory* mock_directory() { | 151 MockDirectorySetterUpper::MockDirectory* mock_directory() { |
| 145 return static_cast<MockDirectorySetterUpper*>(syncdb())->directory(); | 152 return static_cast<MockDirectorySetterUpper*>(syncdb())->directory(); |
| 146 } | 153 } |
| 147 }; | 154 }; |
| 148 | 155 |
| 149 } // namespace browser_sync | 156 } // namespace browser_sync |
| 150 | 157 |
| 151 #endif // CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ | 158 #endif // CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ |
| OLD | NEW |