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

Unified Diff: sync/engine/syncer_proto_util_unittest.cc

Issue 10454105: sync: Refactor per-datatype throttling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/engine/syncer_proto_util.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/syncer_proto_util_unittest.cc
diff --git a/sync/engine/syncer_proto_util_unittest.cc b/sync/engine/syncer_proto_util_unittest.cc
index a1431abbde6c34e8e0ea852e19296d285c4bb5c6..fe9f0dc291d074211ed770b1d27fe52037382c2c 100644
--- a/sync/engine/syncer_proto_util_unittest.cc
+++ b/sync/engine/syncer_proto_util_unittest.cc
@@ -11,6 +11,7 @@
#include "base/message_loop.h"
#include "base/time.h"
#include "sync/engine/syncproto.h"
+#include "sync/engine/throttled_data_type_tracker.h"
#include "sync/internal_api/public/syncable/model_type_test_util.h"
#include "sync/protocol/bookmark_specifics.pb.h"
#include "sync/protocol/password_specifics.pb.h"
@@ -31,14 +32,6 @@ using ::testing::_;
namespace browser_sync {
using sessions::SyncSessionContext;
-class MockSyncSessionContext : public SyncSessionContext {
- public:
- MockSyncSessionContext() {}
- ~MockSyncSessionContext() {}
- MOCK_METHOD2(SetUnthrottleTime, void(syncable::ModelTypeSet,
- const base::TimeTicks&));
-};
-
class MockDelegate : public sessions::SyncSession::Delegate {
public:
MockDelegate() {}
@@ -269,7 +262,7 @@ TEST_F(SyncerProtoUtilTest, PostAndProcessHeaders) {
}
TEST_F(SyncerProtoUtilTest, HandleThrottlingWithDatatypes) {
- MockSyncSessionContext context;
+ ThrottledDataTypeTracker tracker(NULL);
SyncProtocolError error;
error.error_type = browser_sync::THROTTLED;
syncable::ModelTypeSet types;
@@ -277,22 +270,22 @@ TEST_F(SyncerProtoUtilTest, HandleThrottlingWithDatatypes) {
types.Put(syncable::PASSWORDS);
error.error_data_types = types;
- base::TimeTicks ticks = base::TimeTicks::Now();
-
- EXPECT_CALL(context, SetUnthrottleTime(HasModelTypes(types), ticks));
-
- SyncerProtoUtil::HandleThrottleError(error, ticks, &context, NULL);
+ base::TimeTicks ticks = base::TimeTicks::FromInternalValue(1);
+ SyncerProtoUtil::HandleThrottleError(error, ticks, &tracker, NULL);
+ EXPECT_TRUE(tracker.GetThrottledTypes().Equals(types));
}
TEST_F(SyncerProtoUtilTest, HandleThrottlingNoDatatypes) {
+ ThrottledDataTypeTracker tracker(NULL);
MockDelegate delegate;
SyncProtocolError error;
error.error_type = browser_sync::THROTTLED;
- base::TimeTicks ticks = base::TimeTicks::Now();
+ base::TimeTicks ticks = base::TimeTicks::FromInternalValue(1);
EXPECT_CALL(delegate, OnSilencedUntil(ticks));
- SyncerProtoUtil::HandleThrottleError(error, ticks, NULL, &delegate);
+ SyncerProtoUtil::HandleThrottleError(error, ticks, &tracker, &delegate);
+ EXPECT_TRUE(tracker.GetThrottledTypes().Empty());
}
} // namespace browser_sync
« 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