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

Unified Diff: chrome/browser/sync/sessions/sync_session_context_unittest.cc

Issue 8631021: [Sync] Prevent uploading throttled datatypes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For committing. 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
« no previous file with comments | « chrome/browser/sync/sessions/sync_session_context.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/sessions/sync_session_context_unittest.cc
diff --git a/chrome/browser/sync/sessions/sync_session_context_unittest.cc b/chrome/browser/sync/sessions/sync_session_context_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b855b90dee328fe3e46a3697cab095fd8a07dcd2
--- /dev/null
+++ b/chrome/browser/sync/sessions/sync_session_context_unittest.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/sessions/sync_session_context.h"
+
+#include "chrome/browser/sync/syncable/model_type.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace browser_sync {
+namespace sessions {
+TEST(SyncSessionContextTest, AddUnthrottleTimeTest) {
+ syncable::ModelTypeSet types;
+ types.insert(syncable::BOOKMARKS);
+ types.insert(syncable::PASSWORDS);
+
+ SyncSessionContext context;
+ base::TimeTicks now = base::TimeTicks::Now();
+ context.SetUnthrottleTime(types, now);
+
+ EXPECT_EQ(context.unthrottle_times_.size(), 2U);
+ EXPECT_EQ(context.unthrottle_times_[syncable::BOOKMARKS], now);
+ EXPECT_EQ(context.unthrottle_times_[syncable::PASSWORDS], now);
+}
+
+TEST(SyncSessionContextTest, GetCurrentlyThrottledTypesTest) {
+ syncable::ModelTypeSet types;
+ types.insert(syncable::BOOKMARKS);
+ types.insert(syncable::PASSWORDS);
+
+ SyncSessionContext context;
+ base::TimeTicks now = base::TimeTicks::Now();
+
+ // Now update the throttled types with time set to 10 seconds earlier from
+ // now.
+ context.SetUnthrottleTime(types, now - base::TimeDelta::FromSeconds(10));
+ context.PruneUnthrottledTypes(base::TimeTicks::Now());
+ EXPECT_EQ(context.GetThrottledTypes(), syncable::ModelTypeSet());
+
+ // Now update the throttled types with time set to 2 hours from now.
+ context.SetUnthrottleTime(types, now + base::TimeDelta::FromSeconds(1200));
+ context.PruneUnthrottledTypes(base::TimeTicks::Now());
+ EXPECT_EQ(context.GetThrottledTypes(), types);
+}
+} // namespace sessions.
+} // namespace browser_sync
+
« no previous file with comments | « chrome/browser/sync/sessions/sync_session_context.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698