| 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 #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" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 EXPECT_TRUE(directory()->store_birthday().empty()); | 200 EXPECT_TRUE(directory()->store_birthday().empty()); |
| 201 ClientToServerMessage msg; | 201 ClientToServerMessage msg; |
| 202 SyncerProtoUtil::AddRequestBirthday(directory(), &msg); | 202 SyncerProtoUtil::AddRequestBirthday(directory(), &msg); |
| 203 EXPECT_FALSE(msg.has_store_birthday()); | 203 EXPECT_FALSE(msg.has_store_birthday()); |
| 204 | 204 |
| 205 directory()->set_store_birthday("meat"); | 205 directory()->set_store_birthday("meat"); |
| 206 SyncerProtoUtil::AddRequestBirthday(directory(), &msg); | 206 SyncerProtoUtil::AddRequestBirthday(directory(), &msg); |
| 207 EXPECT_EQ(msg.store_birthday(), "meat"); | 207 EXPECT_EQ(msg.store_birthday(), "meat"); |
| 208 } | 208 } |
| 209 | 209 |
| 210 class DummyConnectionManager : public syncer::ServerConnectionManager { | 210 class DummyConnectionManager : public ServerConnectionManager { |
| 211 public: | 211 public: |
| 212 DummyConnectionManager() | 212 DummyConnectionManager() |
| 213 : ServerConnectionManager("unused", 0, false), | 213 : ServerConnectionManager("unused", 0, false), |
| 214 send_error_(false), | 214 send_error_(false), |
| 215 access_denied_(false) {} | 215 access_denied_(false) {} |
| 216 | 216 |
| 217 virtual ~DummyConnectionManager() {} | 217 virtual ~DummyConnectionManager() {} |
| 218 virtual bool PostBufferWithCachedAuth( | 218 virtual bool PostBufferWithCachedAuth( |
| 219 PostBufferParams* params, | 219 PostBufferParams* params, |
| 220 ScopedServerStatusWatcher* watcher) OVERRIDE { | 220 ScopedServerStatusWatcher* watcher) OVERRIDE { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 msg, &response)); | 261 msg, &response)); |
| 262 | 262 |
| 263 dcm.set_access_denied(true); | 263 dcm.set_access_denied(true); |
| 264 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, | 264 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, |
| 265 msg, &response)); | 265 msg, &response)); |
| 266 } | 266 } |
| 267 | 267 |
| 268 TEST_F(SyncerProtoUtilTest, HandleThrottlingWithDatatypes) { | 268 TEST_F(SyncerProtoUtilTest, HandleThrottlingWithDatatypes) { |
| 269 ThrottledDataTypeTracker tracker(NULL); | 269 ThrottledDataTypeTracker tracker(NULL); |
| 270 SyncProtocolError error; | 270 SyncProtocolError error; |
| 271 error.error_type = syncer::THROTTLED; | 271 error.error_type = THROTTLED; |
| 272 syncer::ModelTypeSet types; | 272 ModelTypeSet types; |
| 273 types.Put(syncer::BOOKMARKS); | 273 types.Put(BOOKMARKS); |
| 274 types.Put(syncer::PASSWORDS); | 274 types.Put(PASSWORDS); |
| 275 error.error_data_types = types; | 275 error.error_data_types = types; |
| 276 | 276 |
| 277 base::TimeTicks ticks = base::TimeTicks::FromInternalValue(1); | 277 base::TimeTicks ticks = base::TimeTicks::FromInternalValue(1); |
| 278 SyncerProtoUtil::HandleThrottleError(error, ticks, &tracker, NULL); | 278 SyncerProtoUtil::HandleThrottleError(error, ticks, &tracker, NULL); |
| 279 EXPECT_TRUE(tracker.GetThrottledTypes().Equals(types)); | 279 EXPECT_TRUE(tracker.GetThrottledTypes().Equals(types)); |
| 280 } | 280 } |
| 281 | 281 |
| 282 TEST_F(SyncerProtoUtilTest, HandleThrottlingNoDatatypes) { | 282 TEST_F(SyncerProtoUtilTest, HandleThrottlingNoDatatypes) { |
| 283 ThrottledDataTypeTracker tracker(NULL); | 283 ThrottledDataTypeTracker tracker(NULL); |
| 284 MockDelegate delegate; | 284 MockDelegate delegate; |
| 285 SyncProtocolError error; | 285 SyncProtocolError error; |
| 286 error.error_type = syncer::THROTTLED; | 286 error.error_type = THROTTLED; |
| 287 | 287 |
| 288 base::TimeTicks ticks = base::TimeTicks::FromInternalValue(1); | 288 base::TimeTicks ticks = base::TimeTicks::FromInternalValue(1); |
| 289 | 289 |
| 290 EXPECT_CALL(delegate, OnSilencedUntil(ticks)); | 290 EXPECT_CALL(delegate, OnSilencedUntil(ticks)); |
| 291 | 291 |
| 292 SyncerProtoUtil::HandleThrottleError(error, ticks, &tracker, &delegate); | 292 SyncerProtoUtil::HandleThrottleError(error, ticks, &tracker, &delegate); |
| 293 EXPECT_TRUE(tracker.GetThrottledTypes().Empty()); | 293 EXPECT_TRUE(tracker.GetThrottledTypes().Empty()); |
| 294 } | 294 } |
| 295 } // namespace syncer | 295 } // namespace syncer |
| OLD | NEW |