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

Unified Diff: chrome/common/instant_restricted_id_cache_unittest.cc

Issue 14660022: Move most visited item state info from InstantController to InstantService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 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 | « chrome/common/instant_restricted_id_cache.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/instant_restricted_id_cache_unittest.cc
diff --git a/chrome/common/instant_restricted_id_cache_unittest.cc b/chrome/common/instant_restricted_id_cache_unittest.cc
index e7e97be5fc6e823e51a232f9bb71ae1d37a7f76b..92a6f10b9d28d80d4b458fd98d677e3902a03d57 100644
--- a/chrome/common/instant_restricted_id_cache_unittest.cc
+++ b/chrome/common/instant_restricted_id_cache_unittest.cc
@@ -392,3 +392,32 @@ TEST_F(InstantRestrictedIDCacheTest, AddEmptySet) {
cache.GetCurrentItems(&output);
EXPECT_TRUE(output.empty());
}
+
+TEST_F(InstantRestrictedIDCacheTest, AddItemsWithRestrictedID) {
+ InstantRestrictedIDCache<TestData> cache(29);
+ EXPECT_EQ(0u, cache.cache_.size());
+ EXPECT_EQ(0, cache.last_restricted_id_);
+
+ std::vector<ItemIDPair> input1;
+ input1.push_back(std::make_pair(10, TestData("A")));
+ input1.push_back(std::make_pair(11, TestData("B")));
+ input1.push_back(std::make_pair(12, TestData("C")));
+ cache.AddItemsWithRestrictedID(input1);
+ EXPECT_EQ(3u, cache.cache_.size());
+ EXPECT_EQ(12, cache.last_restricted_id_);
+ EXPECT_EQ(10, cache.last_add_start_->first);
+
+ std::vector<ItemIDPair> output;
+ cache.GetCurrentItems(&output);
+ EXPECT_EQ(3u, output.size());
+
+ // Add the same items again.
+ cache.AddItemsWithRestrictedID(input1);
+
+ // Make sure |cache.last_add_start_| is still valid.
+ cache.GetCurrentItems(&output);
+ EXPECT_EQ(3u, output.size());
+ EXPECT_EQ(3u, cache.cache_.size());
+ EXPECT_EQ(12, cache.last_restricted_id_);
+ EXPECT_EQ(10, cache.last_add_start_->first);
+}
« no previous file with comments | « chrome/common/instant_restricted_id_cache.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698