Index: sync/engine/throttled_data_type_tracker_unittest.cc |
diff --git a/sync/engine/throttled_data_type_tracker_unittest.cc b/sync/engine/throttled_data_type_tracker_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..28a7a5e2682135ff714c773540746158f0d17c6e |
--- /dev/null |
+++ b/sync/engine/throttled_data_type_tracker_unittest.cc |
@@ -0,0 +1,43 @@ |
+// Copyright (c) 2012 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 "sync/engine/throttled_data_type_tracker.h" |
+ |
+#include "sync/syncable/model_type.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace browser_sync { |
+ |
+TEST(ThrottledDataTypeTrackerTest, AddUnthrottleTimeTest) { |
+ const syncable::ModelTypeSet types(syncable::BOOKMARKS, syncable::PASSWORDS); |
+ |
+ ThrottledDataTypeTracker throttler; |
+ base::TimeTicks now = base::TimeTicks::Now(); |
+ throttler.SetUnthrottleTime(types, now); |
+ |
+ EXPECT_EQ(throttler.unthrottle_times_.size(), 2U); |
+ EXPECT_EQ(throttler.unthrottle_times_[syncable::BOOKMARKS], now); |
+ EXPECT_EQ(throttler.unthrottle_times_[syncable::PASSWORDS], now); |
+} |
+ |
+TEST(ThrottledDataTypeTrackerTest, GetCurrentlyThrottledTypesTest) { |
+ const syncable::ModelTypeSet types(syncable::BOOKMARKS, syncable::PASSWORDS); |
+ |
+ ThrottledDataTypeTracker throttler; |
+ base::TimeTicks now = base::TimeTicks::Now(); |
+ |
+ // Now update the throttled types with time set to 10 seconds earlier from |
+ // now. |
+ throttler.SetUnthrottleTime(types, now - base::TimeDelta::FromSeconds(10)); |
+ throttler.PruneUnthrottledTypes(base::TimeTicks::Now()); |
+ EXPECT_TRUE(throttler.GetThrottledTypes().Empty()); |
tim (not reviewing)
2012/06/11 18:53:46
It'd be nice to have a test that doesn't wind up p
rlarocque
2012/06/11 23:28:51
Good point. Done.
|
+ |
+ // Now update the throttled types with time set to 2 hours from now. |
+ throttler.SetUnthrottleTime(types, now + base::TimeDelta::FromSeconds(1200)); |
+ throttler.PruneUnthrottledTypes(base::TimeTicks::Now()); |
+ EXPECT_TRUE(throttler.GetThrottledTypes().Equals(types)); |
+} |
+ |
+} // namespace browser_sync |
+ |