| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "net/base/keygen_handler.h" | 5 #include "net/base/keygen_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 TEST(KeygenHandlerTest, Cache) { | 68 TEST(KeygenHandlerTest, Cache) { |
| 69 KeygenHandler::Cache* cache = KeygenHandler::Cache::GetInstance(); | 69 KeygenHandler::Cache* cache = KeygenHandler::Cache::GetInstance(); |
| 70 KeygenHandler::KeyLocation location1; | 70 KeygenHandler::KeyLocation location1; |
| 71 KeygenHandler::KeyLocation location2; | 71 KeygenHandler::KeyLocation location2; |
| 72 | 72 |
| 73 std::string key1("abcd"); | 73 std::string key1("abcd"); |
| 74 cache->Insert(key1, location1); | 74 cache->Insert(key1, location1); |
| 75 | 75 |
| 76 // The cache should have stored location1 at key1 | 76 // The cache should have stored location1 at key1. |
| 77 EXPECT_TRUE(cache->Find(key1, &location2)); | 77 EXPECT_TRUE(cache->Find(key1, &location2)); |
| 78 | 78 |
| 79 // The cache should have retrieved it into location2, and their equality | 79 // The cache should have retrieved it into location2, and their equality |
| 80 // should be reflexive | 80 // should be reflexive. |
| 81 EXPECT_TRUE(location1.Equals(location2)); | 81 EXPECT_TRUE(location1.Equals(location2)); |
| 82 EXPECT_TRUE(location2.Equals(location1)); | 82 EXPECT_TRUE(location2.Equals(location1)); |
| 83 | 83 |
| 84 location2 = ValidKeyLocation(); | 84 location2 = ValidKeyLocation(); |
| 85 KeygenHandler::KeyLocation location3 = ValidKeyLocation(); | 85 KeygenHandler::KeyLocation location3 = ValidKeyLocation(); |
| 86 EXPECT_FALSE(location1.Equals(location2)); | 86 EXPECT_FALSE(location1.Equals(location2)); |
| 87 | 87 |
| 88 // The cache should miss for an unregistered key | 88 // The cache should miss for an unregistered key. |
| 89 std::string key2("def"); | 89 std::string key2("def"); |
| 90 EXPECT_FALSE(cache->Find(key2, &location2)); | 90 EXPECT_FALSE(cache->Find(key2, &location2)); |
| 91 | 91 |
| 92 // A cache miss should leave the original location unmolested | 92 // A cache miss should leave the original location unmolested. |
| 93 EXPECT_TRUE(location2.Equals(location3)); | 93 EXPECT_TRUE(location2.Equals(location3)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace | 96 } // namespace |
| 97 | 97 |
| 98 } // namespace net | 98 } // namespace net |
| OLD | NEW |