OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "net/quic/crypto/crypto_framer.h" | 10 #include "net/quic/crypto/crypto_framer.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 char* AsChars(unsigned char* data) { return reinterpret_cast<char*>(data); } | 26 char* AsChars(unsigned char* data) { return reinterpret_cast<char*>(data); } |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 namespace test { | 30 namespace test { |
31 | 31 |
32 class TestCryptoVisitor : public ::net::CryptoFramerVisitorInterface { | 32 class TestCryptoVisitor : public ::net::CryptoFramerVisitorInterface { |
33 public: | 33 public: |
34 TestCryptoVisitor() : error_count_(0) {} | 34 TestCryptoVisitor() : error_count_(0) {} |
35 | 35 |
36 virtual void OnError(CryptoFramer* framer) override { | 36 void OnError(CryptoFramer* framer) override { |
37 DLOG(ERROR) << "CryptoFramer Error: " << framer->error(); | 37 DLOG(ERROR) << "CryptoFramer Error: " << framer->error(); |
38 ++error_count_; | 38 ++error_count_; |
39 } | 39 } |
40 | 40 |
41 virtual void OnHandshakeMessage( | 41 void OnHandshakeMessage(const CryptoHandshakeMessage& message) override { |
42 const CryptoHandshakeMessage& message) override { | |
43 messages_.push_back(message); | 42 messages_.push_back(message); |
44 } | 43 } |
45 | 44 |
46 // Counters from the visitor callbacks. | 45 // Counters from the visitor callbacks. |
47 int error_count_; | 46 int error_count_; |
48 | 47 |
49 vector<CryptoHandshakeMessage> messages_; | 48 vector<CryptoHandshakeMessage> messages_; |
50 }; | 49 }; |
51 | 50 |
52 TEST(CryptoFramerTest, ConstructHandshakeMessage) { | 51 TEST(CryptoFramerTest, ConstructHandshakeMessage) { |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 }; | 475 }; |
477 | 476 |
478 EXPECT_TRUE( | 477 EXPECT_TRUE( |
479 framer.ProcessInput(StringPiece(AsChars(input), arraysize(input)))); | 478 framer.ProcessInput(StringPiece(AsChars(input), arraysize(input)))); |
480 EXPECT_EQ(0, visitor.error_count_); | 479 EXPECT_EQ(0, visitor.error_count_); |
481 } | 480 } |
482 | 481 |
483 } // namespace test | 482 } // namespace test |
484 | 483 |
485 } // namespace net | 484 } // namespace net |
OLD | NEW |