Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: sync/engine/syncer_proto_util_unittest.cc

Issue 10735041: Remove syncproto.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address most comments Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/engine/syncer_proto_util.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "sync/engine/syncer_proto_util.h" 5 #include "sync/engine/syncer_proto_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "sync/engine/syncproto.h"
14 #include "sync/engine/throttled_data_type_tracker.h" 13 #include "sync/engine/throttled_data_type_tracker.h"
15 #include "sync/internal_api/public/base/model_type_test_util.h" 14 #include "sync/internal_api/public/base/model_type_test_util.h"
16 #include "sync/protocol/bookmark_specifics.pb.h" 15 #include "sync/protocol/bookmark_specifics.pb.h"
17 #include "sync/protocol/password_specifics.pb.h" 16 #include "sync/protocol/password_specifics.pb.h"
18 #include "sync/protocol/sync.pb.h" 17 #include "sync/protocol/sync.pb.h"
19 #include "sync/protocol/sync_enums.pb.h" 18 #include "sync/protocol/sync_enums.pb.h"
20 #include "sync/sessions/session_state.h" 19 #include "sync/sessions/session_state.h"
21 #include "sync/sessions/sync_session_context.h" 20 #include "sync/sessions/sync_session_context.h"
22 #include "sync/syncable/blob.h" 21 #include "sync/syncable/blob.h"
23 #include "sync/syncable/directory.h" 22 #include "sync/syncable/directory.h"
24 #include "sync/test/engine/mock_connection_manager.h" 23 #include "sync/test/engine/mock_connection_manager.h"
25 #include "sync/test/engine/test_directory_setter_upper.h" 24 #include "sync/test/engine/test_directory_setter_upper.h"
26 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
27 26
28 using ::testing::_; 27 using ::testing::_;
29 28
29 using sync_pb::ClientToServerMessage;
30 using sync_pb::CommitResponse_EntryResponse;
31 using sync_pb::SyncEntity;
32
30 namespace syncer { 33 namespace syncer {
31 34
32 using sessions::SyncSessionContext; 35 using sessions::SyncSessionContext;
33 using syncable::Blob; 36 using syncable::Blob;
34 37
35 class MockDelegate : public sessions::SyncSession::Delegate { 38 class MockDelegate : public sessions::SyncSession::Delegate {
36 public: 39 public:
37 MockDelegate() {} 40 MockDelegate() {}
38 ~MockDelegate() {} 41 ~MockDelegate() {}
39 42
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 168 }
166 169
167 protected: 170 protected:
168 MessageLoop message_loop_; 171 MessageLoop message_loop_;
169 TestDirectorySetterUpper dir_maker_; 172 TestDirectorySetterUpper dir_maker_;
170 }; 173 };
171 174
172 TEST_F(SyncerProtoUtilTest, VerifyResponseBirthday) { 175 TEST_F(SyncerProtoUtilTest, VerifyResponseBirthday) {
173 // Both sides empty 176 // Both sides empty
174 EXPECT_TRUE(directory()->store_birthday().empty()); 177 EXPECT_TRUE(directory()->store_birthday().empty());
175 ClientToServerResponse response; 178 sync_pb::ClientToServerResponse response;
176 EXPECT_FALSE(SyncerProtoUtil::VerifyResponseBirthday(directory(), &response)); 179 EXPECT_FALSE(SyncerProtoUtil::VerifyResponseBirthday(directory(), &response));
177 180
178 // Remote set, local empty 181 // Remote set, local empty
179 response.set_store_birthday("flan"); 182 response.set_store_birthday("flan");
180 EXPECT_TRUE(SyncerProtoUtil::VerifyResponseBirthday(directory(), &response)); 183 EXPECT_TRUE(SyncerProtoUtil::VerifyResponseBirthday(directory(), &response));
181 EXPECT_EQ(directory()->store_birthday(), "flan"); 184 EXPECT_EQ(directory()->store_birthday(), "flan");
182 185
183 // Remote empty, local set. 186 // Remote empty, local set.
184 response.clear_store_birthday(); 187 response.clear_store_birthday();
185 EXPECT_TRUE(SyncerProtoUtil::VerifyResponseBirthday(directory(), &response)); 188 EXPECT_TRUE(SyncerProtoUtil::VerifyResponseBirthday(directory(), &response));
(...skipping 26 matching lines...) Expand all
212 access_denied_(false) {} 215 access_denied_(false) {}
213 216
214 virtual ~DummyConnectionManager() {} 217 virtual ~DummyConnectionManager() {}
215 virtual bool PostBufferWithCachedAuth( 218 virtual bool PostBufferWithCachedAuth(
216 PostBufferParams* params, 219 PostBufferParams* params,
217 ScopedServerStatusWatcher* watcher) OVERRIDE { 220 ScopedServerStatusWatcher* watcher) OVERRIDE {
218 if (send_error_) { 221 if (send_error_) {
219 return false; 222 return false;
220 } 223 }
221 224
222 ClientToServerResponse response; 225 sync_pb::ClientToServerResponse response;
223 if (access_denied_) { 226 if (access_denied_) {
224 response.set_error_code(sync_pb::SyncEnums::ACCESS_DENIED); 227 response.set_error_code(sync_pb::SyncEnums::ACCESS_DENIED);
225 } 228 }
226 response.SerializeToString(&params->buffer_out); 229 response.SerializeToString(&params->buffer_out);
227 230
228 return true; 231 return true;
229 } 232 }
230 233
231 void set_send_error(bool send) { 234 void set_send_error(bool send) {
232 send_error_ = send; 235 send_error_ = send;
233 } 236 }
234 237
235 void set_access_denied(bool denied) { 238 void set_access_denied(bool denied) {
236 access_denied_ = denied; 239 access_denied_ = denied;
237 } 240 }
238 241
239 private: 242 private:
240 bool send_error_; 243 bool send_error_;
241 bool access_denied_; 244 bool access_denied_;
242 }; 245 };
243 246
244 TEST_F(SyncerProtoUtilTest, PostAndProcessHeaders) { 247 TEST_F(SyncerProtoUtilTest, PostAndProcessHeaders) {
245 DummyConnectionManager dcm; 248 DummyConnectionManager dcm;
246 ClientToServerMessage msg; 249 ClientToServerMessage msg;
250 SyncerProtoUtil::SetProtocolVersion(&msg);
247 msg.set_share("required"); 251 msg.set_share("required");
248 msg.set_message_contents(ClientToServerMessage::GET_UPDATES); 252 msg.set_message_contents(ClientToServerMessage::GET_UPDATES);
249 ClientToServerResponse response; 253 sync_pb::ClientToServerResponse response;
250 254
251 dcm.set_send_error(true); 255 dcm.set_send_error(true);
252 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, 256 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL,
253 msg, &response)); 257 msg, &response));
254 258
255 dcm.set_send_error(false); 259 dcm.set_send_error(false);
256 EXPECT_TRUE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, 260 EXPECT_TRUE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL,
257 msg, &response)); 261 msg, &response));
258 262
259 dcm.set_access_denied(true); 263 dcm.set_access_denied(true);
(...skipping 22 matching lines...) Expand all
282 error.error_type = syncer::THROTTLED; 286 error.error_type = syncer::THROTTLED;
283 287
284 base::TimeTicks ticks = base::TimeTicks::FromInternalValue(1); 288 base::TimeTicks ticks = base::TimeTicks::FromInternalValue(1);
285 289
286 EXPECT_CALL(delegate, OnSilencedUntil(ticks)); 290 EXPECT_CALL(delegate, OnSilencedUntil(ticks));
287 291
288 SyncerProtoUtil::HandleThrottleError(error, ticks, &tracker, &delegate); 292 SyncerProtoUtil::HandleThrottleError(error, ticks, &tracker, &delegate);
289 EXPECT_TRUE(tracker.GetThrottledTypes().Empty()); 293 EXPECT_TRUE(tracker.GetThrottledTypes().Empty());
290 } 294 }
291 } // namespace syncer 295 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/syncer_proto_util.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698