| Index: chrome/browser/sync/engine/syncer_proto_util_unittest.cc
|
| diff --git a/chrome/browser/sync/engine/syncer_proto_util_unittest.cc b/chrome/browser/sync/engine/syncer_proto_util_unittest.cc
|
| index a22e1a37431be8fa2c70f52956fab5789a74e023..60745700849ea653da4f479a682fbf0a520d8f7f 100644
|
| --- a/chrome/browser/sync/engine/syncer_proto_util_unittest.cc
|
| +++ b/chrome/browser/sync/engine/syncer_proto_util_unittest.cc
|
| @@ -8,7 +8,14 @@
|
|
|
| #include "base/basictypes.h"
|
| #include "base/compiler_specific.h"
|
| +#include "base/time.h"
|
| #include "chrome/browser/sync/engine/syncproto.h"
|
| +#include "chrome/browser/sync/sessions/session_state.h"
|
| +#include "chrome/browser/sync/sessions/sync_session_context.h"
|
| +#include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
|
| +#include "chrome/browser/sync/protocol/password_specifics.pb.h"
|
| +#include "chrome/browser/sync/protocol/sync.pb.h"
|
| +#include "chrome/browser/sync/sessions/sync_session_unittest.cc"
|
| #include "chrome/browser/sync/syncable/blob.h"
|
| #include "chrome/browser/sync/syncable/directory_manager.h"
|
| #include "chrome/browser/sync/syncable/syncable.h"
|
| @@ -19,8 +26,33 @@
|
|
|
| using syncable::Blob;
|
| using syncable::ScopedDirLookup;
|
| +using syncable::ModelTypeSet;
|
| +using ::testing::_;
|
|
|
| namespace browser_sync {
|
| +using sessions::SyncSessionContext;
|
| +
|
| +class MockSyncSessionContext : public SyncSessionContext {
|
| + public:
|
| + MockSyncSessionContext() {}
|
| + ~MockSyncSessionContext() {}
|
| + MOCK_METHOD2(AddUnthrottleTime, void(const ModelTypeSet&,
|
| + const base::TimeTicks&));
|
| +};
|
| +
|
| +class MockDelegate : public sessions::SyncSession::Delegate {
|
| + public:
|
| + MockDelegate() {}
|
| + ~MockDelegate() {}
|
| +
|
| + MOCK_METHOD0(IsSyncingCurrentlySilenced, bool());
|
| + MOCK_METHOD1(OnReceivedShortPollIntervalUpdate, void(const base::TimeDelta&));
|
| + MOCK_METHOD1(OnReceivedLongPollIntervalUpdate ,void(const base::TimeDelta&));
|
| + MOCK_METHOD1(OnReceivedSessionsCommitDelay, void(const base::TimeDelta&));
|
| + MOCK_METHOD1(OnSyncProtocolError, void(const sessions::SyncSessionSnapshot&));
|
| + MOCK_METHOD0(OnShouldStopSyncingPermanently, void());
|
| + MOCK_METHOD1(OnSilencedUntil, void(const base::TimeTicks&));
|
| +};
|
|
|
| TEST(SyncerProtoUtil, TestBlobToProtocolBufferBytesUtilityFunctions) {
|
| unsigned char test_data1[] = {1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 4, 2, 9};
|
| @@ -238,4 +270,31 @@ TEST_F(SyncerProtoUtilTest, PostAndProcessHeaders) {
|
| msg, &response));
|
| }
|
|
|
| +TEST_F(SyncerProtoUtilTest, HandleThrottlingWithDatatypes) {
|
| + MockSyncSessionContext context;
|
| + SyncProtocolError error;
|
| + error.error_type = browser_sync::THROTTLED;
|
| + syncable::ModelTypeSet types;
|
| + types.insert(syncable::BOOKMARKS);
|
| + types.insert(syncable::PASSWORDS);
|
| + error.throttled_types = types;
|
| +
|
| + base::TimeTicks ticks = base::TimeTicks::Now();
|
| +
|
| + EXPECT_CALL(context, AddUnthrottleTime(types, ticks));
|
| +
|
| + SyncerProtoUtil::HandleThrottling(error, ticks, &context, NULL);
|
| +}
|
| +
|
| +TEST_F(SyncerProtoUtilTest, HandleThrottlingNoDatatypes) {
|
| + MockDelegate delegate;
|
| + SyncProtocolError error;
|
| + error.error_type = browser_sync::THROTTLED;
|
| +
|
| + base::TimeTicks ticks = base::TimeTicks::Now();
|
| +
|
| + EXPECT_CALL(delegate, OnSilencedUntil(ticks));
|
| +
|
| + SyncerProtoUtil::HandleThrottling(error, ticks, NULL, &delegate);
|
| +}
|
| } // namespace browser_sync
|
|
|