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

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

Issue 8631021: [Sync] Prevent uploading throttled datatypes. (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_unittest.cc
diff --git a/chrome/browser/sync/engine/syncer_unittest.cc b/chrome/browser/sync/engine/syncer_unittest.cc
index b4b4003aaff2e0a6bdce01238739388c60c2b308..32938829163c996a64fc18265dd7f468b38177b8 100644
--- a/chrome/browser/sync/engine/syncer_unittest.cc
+++ b/chrome/browser/sync/engine/syncer_unittest.cc
@@ -369,7 +369,7 @@ class SyncerTest : public testing::Test,
GetModelSafeRoutingInfo(&routes);
GetCommitIdsCommand command(limit);
command.BuildCommitIds(session_->status_controller()->unsynced_handles(),
- session_->write_transaction(), routes);
+ session_->write_transaction(), routes, syncable::ModelTypeSet());
vector<syncable::Id> output =
command.ordered_commit_set_->GetAllCommitIds();
size_t truncated_size = std::min(limit, expected_id_order.size());
@@ -554,6 +554,53 @@ TEST_F(SyncerTest, GetCommitIdsCommandTruncates) {
DoTruncationTest(dir, unsynced_handle_view, expected_order);
}
+TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) {
+ ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
+ ASSERT_TRUE(dir.good());
+ syncable::ModelTypeSet throttled_types;
+ throttled_types.insert(syncable::BOOKMARKS);
+ KeyParams key_params = {"localhost", "dummy", "foobar"};
+ sync_pb::EntitySpecifics bookmark_data;
+ AddDefaultExtensionValue(syncable::BOOKMARKS, &bookmark_data);
+
+ mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10);
+ SyncShareAsDelegate();
+
+ {
+ WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
+ MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1));
+ ASSERT_TRUE(A.good());
+ A.Put(IS_UNSYNCED, true);
+ A.Put(SPECIFICS, bookmark_data);
+ A.Put(NON_UNIQUE_NAME, "bookmark");
+ }
+
+ // Now set the throttled types.
+ context_->SetUnthrottleTime(throttled_types,
akalin 2011/11/23 03:44:33 newline before throttled_types
+ base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1200));
+ SyncShareAsDelegate();
+
+ {
+ // Nothing should have been committed as bookmarks is throttled.
+ ReadTransaction rtrans(FROM_HERE, dir);
+ Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1));
+ ASSERT_TRUE(entryA.good());
+ EXPECT_TRUE(entryA.Get(IS_UNSYNCED));
+ }
+
+ // Now unthrottle.
+ context_->SetUnthrottleTime(throttled_types,
akalin 2011/11/23 03:44:33 here too
+ base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1200));
+ SyncShareAsDelegate();
+ {
+ // It should have been committed.
+ ReadTransaction rtrans(FROM_HERE, dir);
+ Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1));
+ ASSERT_TRUE(entryA.good());
+ EXPECT_FALSE(entryA.Get(IS_UNSYNCED));
+ }
+}
+
TEST_F(SyncerTest, GetCommitIdsFiltersUnreadyEntries) {
ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
ASSERT_TRUE(dir.good());

Powered by Google App Engine
This is Rietveld 408576698