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

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

Issue 23717047: Retry: sync: Gracefully handle early shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renames Created 7 years, 3 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.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/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "sync/internal_api/public/base/cancelation_signal.h"
13 #include "sync/internal_api/public/base/model_type_test_util.h" 14 #include "sync/internal_api/public/base/model_type_test_util.h"
14 #include "sync/protocol/bookmark_specifics.pb.h" 15 #include "sync/protocol/bookmark_specifics.pb.h"
15 #include "sync/protocol/password_specifics.pb.h" 16 #include "sync/protocol/password_specifics.pb.h"
16 #include "sync/protocol/sync.pb.h" 17 #include "sync/protocol/sync.pb.h"
17 #include "sync/protocol/sync_enums.pb.h" 18 #include "sync/protocol/sync_enums.pb.h"
18 #include "sync/sessions/sync_session_context.h" 19 #include "sync/sessions/sync_session_context.h"
19 #include "sync/syncable/blob.h" 20 #include "sync/syncable/blob.h"
20 #include "sync/syncable/directory.h" 21 #include "sync/syncable/directory.h"
21 #include "sync/test/engine/mock_connection_manager.h" 22 #include "sync/test/engine/mock_connection_manager.h"
22 #include "sync/test/engine/test_directory_setter_upper.h" 23 #include "sync/test/engine/test_directory_setter_upper.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 SyncerProtoUtil::AddRequestBirthday(directory(), &msg); 248 SyncerProtoUtil::AddRequestBirthday(directory(), &msg);
248 EXPECT_FALSE(msg.has_store_birthday()); 249 EXPECT_FALSE(msg.has_store_birthday());
249 250
250 directory()->set_store_birthday("meat"); 251 directory()->set_store_birthday("meat");
251 SyncerProtoUtil::AddRequestBirthday(directory(), &msg); 252 SyncerProtoUtil::AddRequestBirthday(directory(), &msg);
252 EXPECT_EQ(msg.store_birthday(), "meat"); 253 EXPECT_EQ(msg.store_birthday(), "meat");
253 } 254 }
254 255
255 class DummyConnectionManager : public ServerConnectionManager { 256 class DummyConnectionManager : public ServerConnectionManager {
256 public: 257 public:
257 DummyConnectionManager() 258 DummyConnectionManager(CancelationSignal* signal)
258 : ServerConnectionManager("unused", 0, false, false), 259 : ServerConnectionManager("unused", 0, false, false, signal),
259 send_error_(false), 260 send_error_(false),
260 access_denied_(false) {} 261 access_denied_(false) {}
261 262
262 virtual ~DummyConnectionManager() {} 263 virtual ~DummyConnectionManager() {}
263 virtual bool PostBufferWithCachedAuth( 264 virtual bool PostBufferWithCachedAuth(
264 PostBufferParams* params, 265 PostBufferParams* params,
265 ScopedServerStatusWatcher* watcher) OVERRIDE { 266 ScopedServerStatusWatcher* watcher) OVERRIDE {
266 if (send_error_) { 267 if (send_error_) {
267 return false; 268 return false;
268 } 269 }
(...skipping 14 matching lines...) Expand all
283 void set_access_denied(bool denied) { 284 void set_access_denied(bool denied) {
284 access_denied_ = denied; 285 access_denied_ = denied;
285 } 286 }
286 287
287 private: 288 private:
288 bool send_error_; 289 bool send_error_;
289 bool access_denied_; 290 bool access_denied_;
290 }; 291 };
291 292
292 TEST_F(SyncerProtoUtilTest, PostAndProcessHeaders) { 293 TEST_F(SyncerProtoUtilTest, PostAndProcessHeaders) {
293 DummyConnectionManager dcm; 294 CancelationSignal signal;
295 DummyConnectionManager dcm(&signal);
294 ClientToServerMessage msg; 296 ClientToServerMessage msg;
295 SyncerProtoUtil::SetProtocolVersion(&msg); 297 SyncerProtoUtil::SetProtocolVersion(&msg);
296 msg.set_share("required"); 298 msg.set_share("required");
297 msg.set_message_contents(ClientToServerMessage::GET_UPDATES); 299 msg.set_message_contents(ClientToServerMessage::GET_UPDATES);
298 sync_pb::ClientToServerResponse response; 300 sync_pb::ClientToServerResponse response;
299 301
300 dcm.set_send_error(true); 302 dcm.set_send_error(true);
301 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, 303 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL,
302 msg, &response)); 304 msg, &response));
303 305
304 dcm.set_send_error(false); 306 dcm.set_send_error(false);
305 EXPECT_TRUE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, 307 EXPECT_TRUE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL,
306 msg, &response)); 308 msg, &response));
307 309
308 dcm.set_access_denied(true); 310 dcm.set_access_denied(true);
309 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, 311 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL,
310 msg, &response)); 312 msg, &response));
311 } 313 }
312 314
313 } // namespace syncer 315 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/syncer.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698