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