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

Unified Diff: chrome/browser/sync/engine/syncer_proto_util_unittest.cc

Issue 8595023: [Sync] Parse and save per-data type throttle data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..d2f6e8edb85a10708876b2b9a3f7c9567fd825aa 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.error_data_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

Powered by Google App Engine
This is Rietveld 408576698