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 sessions::SyncSourceInfo::ModelTypeMap types; |
| 93 ModelSafeRoutingInfo routes = routing_info(); |
| 94 for (ModelSafeRoutingInfo::const_iterator i = routes.begin(); |
| 95 i != routes.end(); ++i) { |
| 96 types[i->first] = std::string(""); |
| 97 } |
90 session_.reset(new sessions::SyncSession(context(), delegate(), | 98 session_.reset(new sessions::SyncSession(context(), delegate(), |
91 sessions::SyncSourceInfo(), routing_info_, workers)); | 99 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, |
| 100 types), |
| 101 routing_info_, workers)); |
92 } | 102 } |
93 return session_.get(); | 103 return session_.get(); |
94 } | 104 } |
95 void ClearSession() { | 105 void ClearSession() { |
96 session_.reset(); | 106 session_.reset(); |
97 } | 107 } |
98 | 108 |
99 void ResetContext() { | 109 void ResetContext() { |
100 context_.reset(new sessions::SyncSessionContext( | 110 context_.reset(new sessions::SyncSessionContext( |
101 mock_server_.get(), syncdb_->manager(), registrar(), | 111 mock_server_.get(), syncdb_->manager(), registrar(), |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 : SyncerCommandTestWithParam<void*>( | 152 : SyncerCommandTestWithParam<void*>( |
143 SyncerCommandTestWithParam<void*>::USE_MOCK_DIRECTORY) {} | 153 SyncerCommandTestWithParam<void*>::USE_MOCK_DIRECTORY) {} |
144 MockDirectorySetterUpper::MockDirectory* mock_directory() { | 154 MockDirectorySetterUpper::MockDirectory* mock_directory() { |
145 return static_cast<MockDirectorySetterUpper*>(syncdb())->directory(); | 155 return static_cast<MockDirectorySetterUpper*>(syncdb())->directory(); |
146 } | 156 } |
147 }; | 157 }; |
148 | 158 |
149 } // namespace browser_sync | 159 } // namespace browser_sync |
150 | 160 |
151 #endif // CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ | 161 #endif // CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ |
OLD | NEW |