| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 #include <utility> | 6 #include <utility> |
| 7 #include <vector> | 7 #include <vector> |
| 8 #include "chrome/common/instant_restricted_id_cache.h" | 8 #include "chrome/common/instant_restricted_id_cache.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 cache.GetCurrentItems(&output); | 385 cache.GetCurrentItems(&output); |
| 386 EXPECT_EQ(3u, output.size()); | 386 EXPECT_EQ(3u, output.size()); |
| 387 | 387 |
| 388 cache.AddItemsWithRestrictedID(std::vector<ItemIDPair>()); | 388 cache.AddItemsWithRestrictedID(std::vector<ItemIDPair>()); |
| 389 EXPECT_EQ(6u, cache.cache_.size()); | 389 EXPECT_EQ(6u, cache.cache_.size()); |
| 390 EXPECT_EQ(12, cache.last_restricted_id_); | 390 EXPECT_EQ(12, cache.last_restricted_id_); |
| 391 | 391 |
| 392 cache.GetCurrentItems(&output); | 392 cache.GetCurrentItems(&output); |
| 393 EXPECT_TRUE(output.empty()); | 393 EXPECT_TRUE(output.empty()); |
| 394 } | 394 } |
| 395 |
| 396 TEST_F(InstantRestrictedIDCacheTest, AddItemsWithRestrictedID) { |
| 397 InstantRestrictedIDCache<TestData> cache(29); |
| 398 EXPECT_EQ(0u, cache.cache_.size()); |
| 399 EXPECT_EQ(0, cache.last_restricted_id_); |
| 400 |
| 401 std::vector<ItemIDPair> input1; |
| 402 input1.push_back(std::make_pair(10, TestData("A"))); |
| 403 input1.push_back(std::make_pair(11, TestData("B"))); |
| 404 input1.push_back(std::make_pair(12, TestData("C"))); |
| 405 cache.AddItemsWithRestrictedID(input1); |
| 406 EXPECT_EQ(3u, cache.cache_.size()); |
| 407 EXPECT_EQ(12, cache.last_restricted_id_); |
| 408 EXPECT_EQ(10, cache.last_add_start_->first); |
| 409 |
| 410 std::vector<ItemIDPair> output; |
| 411 cache.GetCurrentItems(&output); |
| 412 EXPECT_EQ(3u, output.size()); |
| 413 |
| 414 // Add the same items again. |
| 415 cache.AddItemsWithRestrictedID(input1); |
| 416 |
| 417 // Make sure |cache.last_add_start_| is still valid. |
| 418 cache.GetCurrentItems(&output); |
| 419 EXPECT_EQ(3u, output.size()); |
| 420 EXPECT_EQ(3u, cache.cache_.size()); |
| 421 EXPECT_EQ(12, cache.last_restricted_id_); |
| 422 EXPECT_EQ(10, cache.last_add_start_->first); |
| 423 } |
| OLD | NEW |