| 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 "net/quic/crypto/quic_crypto_client_config.h" | 5 #include "net/quic/crypto/quic_crypto_client_config.h" | 
| 6 | 6 | 
| 7 #include "net/quic/crypto/proof_verifier.h" | 7 #include "net/quic/crypto/proof_verifier.h" | 
| 8 #include "net/quic/quic_server_id.h" | 8 #include "net/quic/quic_server_id.h" | 
| 9 #include "net/quic/test_tools/mock_random.h" | 9 #include "net/quic/test_tools/mock_random.h" | 
| 10 #include "net/quic/test_tools/quic_test_utils.h" | 10 #include "net/quic/test_tools/quic_test_utils.h" | 
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" | 
| 12 | 12 | 
| 13 using std::string; | 13 using std::string; | 
| 14 using std::vector; | 14 using std::vector; | 
| 15 | 15 | 
| 16 namespace net { | 16 namespace net { | 
| 17 namespace test { | 17 namespace test { | 
|  | 18 namespace { | 
|  | 19 | 
|  | 20 class TestProofVerifyDetails : public ProofVerifyDetails { | 
|  | 21   virtual ~TestProofVerifyDetails() {} | 
|  | 22 | 
|  | 23   // ProofVerifyDetails implementation | 
|  | 24   virtual ProofVerifyDetails* Clone() const OVERRIDE { | 
|  | 25     return new TestProofVerifyDetails; | 
|  | 26   } | 
|  | 27 }; | 
|  | 28 | 
|  | 29 }  // namespace | 
| 18 | 30 | 
| 19 TEST(QuicCryptoClientConfigTest, CachedState_IsEmpty) { | 31 TEST(QuicCryptoClientConfigTest, CachedState_IsEmpty) { | 
| 20   QuicCryptoClientConfig::CachedState state; | 32   QuicCryptoClientConfig::CachedState state; | 
| 21   EXPECT_TRUE(state.IsEmpty()); | 33   EXPECT_TRUE(state.IsEmpty()); | 
| 22 } | 34 } | 
| 23 | 35 | 
| 24 TEST(QuicCryptoClientConfigTest, CachedState_IsComplete) { | 36 TEST(QuicCryptoClientConfigTest, CachedState_IsComplete) { | 
| 25   QuicCryptoClientConfig::CachedState state; | 37   QuicCryptoClientConfig::CachedState state; | 
| 26   EXPECT_FALSE(state.IsComplete(QuicWallTime::FromUNIXSeconds(0))); | 38   EXPECT_FALSE(state.IsComplete(QuicWallTime::FromUNIXSeconds(0))); | 
| 27 } | 39 } | 
| 28 | 40 | 
| 29 TEST(QuicCryptoClientConfigTest, CachedState_GenerationCounter) { | 41 TEST(QuicCryptoClientConfigTest, CachedState_GenerationCounter) { | 
| 30   QuicCryptoClientConfig::CachedState state; | 42   QuicCryptoClientConfig::CachedState state; | 
| 31   EXPECT_EQ(0u, state.generation_counter()); | 43   EXPECT_EQ(0u, state.generation_counter()); | 
| 32   state.SetProofInvalid(); | 44   state.SetProofInvalid(); | 
| 33   EXPECT_EQ(1u, state.generation_counter()); | 45   EXPECT_EQ(1u, state.generation_counter()); | 
| 34 } | 46 } | 
| 35 | 47 | 
| 36 TEST(QuicCryptoClientConfigTest, CachedState_SetProofVerifyDetails) { | 48 TEST(QuicCryptoClientConfigTest, CachedState_SetProofVerifyDetails) { | 
| 37   QuicCryptoClientConfig::CachedState state; | 49   QuicCryptoClientConfig::CachedState state; | 
| 38   EXPECT_TRUE(state.proof_verify_details() == NULL); | 50   EXPECT_TRUE(state.proof_verify_details() == NULL); | 
| 39   ProofVerifyDetails* details = new ProofVerifyDetails; | 51   ProofVerifyDetails* details = new TestProofVerifyDetails; | 
| 40   state.SetProofVerifyDetails(details); | 52   state.SetProofVerifyDetails(details); | 
| 41   EXPECT_EQ(details, state.proof_verify_details()); | 53   EXPECT_EQ(details, state.proof_verify_details()); | 
| 42 } | 54 } | 
| 43 | 55 | 
| 44 TEST(QuicCryptoClientConfigTest, CachedState_InitializeFrom) { | 56 TEST(QuicCryptoClientConfigTest, CachedState_InitializeFrom) { | 
| 45   QuicCryptoClientConfig::CachedState state; | 57   QuicCryptoClientConfig::CachedState state; | 
| 46   QuicCryptoClientConfig::CachedState other; | 58   QuicCryptoClientConfig::CachedState other; | 
| 47   state.set_source_address_token("TOKEN"); | 59   state.set_source_address_token("TOKEN"); | 
| 48   // TODO(rch): Populate other fields of |state|. | 60   // TODO(rch): Populate other fields of |state|. | 
| 49   other.InitializeFrom(state); | 61   other.InitializeFrom(state); | 
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 250   EXPECT_EQ(state, cleared_cache); | 262   EXPECT_EQ(state, cleared_cache); | 
| 251   EXPECT_FALSE(cleared_cache->proof_valid()); | 263   EXPECT_FALSE(cleared_cache->proof_valid()); | 
| 252   EXPECT_TRUE(cleared_cache->server_config().empty()); | 264   EXPECT_TRUE(cleared_cache->server_config().empty()); | 
| 253   EXPECT_TRUE(cleared_cache->certs().empty()); | 265   EXPECT_TRUE(cleared_cache->certs().empty()); | 
| 254   EXPECT_TRUE(cleared_cache->signature().empty()); | 266   EXPECT_TRUE(cleared_cache->signature().empty()); | 
| 255   EXPECT_EQ(2u, cleared_cache->generation_counter()); | 267   EXPECT_EQ(2u, cleared_cache->generation_counter()); | 
| 256 } | 268 } | 
| 257 | 269 | 
| 258 }  // namespace test | 270 }  // namespace test | 
| 259 }  // namespace net | 271 }  // namespace net | 
| OLD | NEW | 
|---|