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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 virtual ~SyncerCommandTestBase(); | 97 virtual ~SyncerCommandTestBase(); |
98 virtual void SetUp(); | 98 virtual void SetUp(); |
99 virtual void TearDown(); | 99 virtual void TearDown(); |
100 | 100 |
101 sessions::SyncSessionContext* context() const { return context_.get(); } | 101 sessions::SyncSessionContext* context() const { return context_.get(); } |
102 sessions::SyncSession::Delegate* delegate() { return this; } | 102 sessions::SyncSession::Delegate* delegate() { return this; } |
103 | 103 |
104 // Lazily create a session requesting all datatypes with no state. | 104 // Lazily create a session requesting all datatypes with no state. |
105 sessions::SyncSession* session() { | 105 sessions::SyncSession* session() { |
106 ModelTypeInvalidationMap types = | 106 if (!session_.get()) |
107 ModelSafeRoutingInfoToInvalidationMap(routing_info_, std::string()); | 107 session_.reset(sessions::SyncSession::Build(context(), delegate())); |
108 return session(sessions::SyncSourceInfo(types)); | |
109 } | |
110 | |
111 // Create a session with the provided source. | |
112 sessions::SyncSession* session(const sessions::SyncSourceInfo& source) { | |
113 // These sources require a valid nudge tracker. | |
114 DCHECK_NE(sync_pb::GetUpdatesCallerInfo::LOCAL, source.updates_source); | |
115 DCHECK_NE(sync_pb::GetUpdatesCallerInfo::NOTIFICATION, | |
116 source.updates_source); | |
117 DCHECK_NE(sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH, | |
118 source.updates_source); | |
119 if (!session_.get()) { | |
120 std::vector<ModelSafeWorker*> workers = GetWorkers(); | |
121 session_.reset( | |
122 sessions::SyncSession::Build(context(), delegate(), source)); | |
123 } | |
124 return session_.get(); | 108 return session_.get(); |
125 } | 109 } |
126 | 110 |
127 void ClearSession() { | 111 void ClearSession() { |
128 session_.reset(); | 112 session_.reset(); |
129 } | 113 } |
130 | 114 |
131 void ResetContext() { | 115 void ResetContext() { |
132 context_.reset(new sessions::SyncSessionContext( | 116 context_.reset(new sessions::SyncSessionContext( |
133 mock_server_.get(), directory(), | 117 mock_server_.get(), directory(), |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 virtual void TearDown() OVERRIDE; | 205 virtual void TearDown() OVERRIDE; |
222 virtual syncable::Directory* directory() OVERRIDE; | 206 virtual syncable::Directory* directory() OVERRIDE; |
223 | 207 |
224 private: | 208 private: |
225 TestDirectorySetterUpper dir_maker_; | 209 TestDirectorySetterUpper dir_maker_; |
226 }; | 210 }; |
227 | 211 |
228 } // namespace syncer | 212 } // namespace syncer |
229 | 213 |
230 #endif // SYNC_TEST_ENGINE_SYNCER_COMMAND_TEST_H_ | 214 #endif // SYNC_TEST_ENGINE_SYNCER_COMMAND_TEST_H_ |
OLD | NEW |