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 "net/quic/test_tools/quic_test_utils.h" | 5 #include "net/quic/test_tools/quic_test_utils.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/string_number_conversions.h" |
8 #include "net/quic/crypto/crypto_framer.h" | 9 #include "net/quic/crypto/crypto_framer.h" |
9 #include "net/quic/crypto/crypto_handshake.h" | 10 #include "net/quic/crypto/crypto_handshake.h" |
10 #include "net/quic/crypto/crypto_utils.h" | 11 #include "net/quic/crypto/crypto_utils.h" |
11 #include "net/quic/crypto/null_encrypter.h" | 12 #include "net/quic/crypto/null_encrypter.h" |
12 #include "net/quic/crypto/quic_decrypter.h" | 13 #include "net/quic/crypto/quic_decrypter.h" |
13 #include "net/quic/crypto/quic_encrypter.h" | 14 #include "net/quic/crypto/quic_encrypter.h" |
14 #include "net/quic/quic_framer.h" | 15 #include "net/quic/quic_framer.h" |
15 #include "net/quic/quic_packet_creator.h" | 16 #include "net/quic/quic_packet_creator.h" |
16 #include "net/quic/test_tools/quic_connection_peer.h" | 17 #include "net/quic/test_tools/quic_connection_peer.h" |
17 #include "net/spdy/spdy_frame_builder.h" | 18 #include "net/spdy/spdy_frame_builder.h" |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 if (identical) return; | 380 if (identical) return; |
380 ADD_FAILURE() | 381 ADD_FAILURE() |
381 << "Description:\n" | 382 << "Description:\n" |
382 << description | 383 << description |
383 << "\n\nExpected:\n" | 384 << "\n\nExpected:\n" |
384 << HexDumpWithMarks(expected, expected_len, marks.get(), max_len) | 385 << HexDumpWithMarks(expected, expected_len, marks.get(), max_len) |
385 << "\nActual:\n" | 386 << "\nActual:\n" |
386 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len); | 387 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len); |
387 } | 388 } |
388 | 389 |
| 390 bool DecodeHexString(const base::StringPiece& hex, std::string* bytes) { |
| 391 bytes->clear(); |
| 392 if (hex.empty()) |
| 393 return true; |
| 394 std::vector<uint8> v; |
| 395 if (!base::HexStringToBytes(hex.as_string(), &v)) |
| 396 return false; |
| 397 if (!v.empty()) |
| 398 bytes->assign(reinterpret_cast<const char*>(&v[0]), v.size()); |
| 399 return true; |
| 400 } |
| 401 |
389 static QuicPacket* ConstructPacketFromHandshakeMessage( | 402 static QuicPacket* ConstructPacketFromHandshakeMessage( |
390 QuicGuid guid, | 403 QuicGuid guid, |
391 const CryptoHandshakeMessage& message, | 404 const CryptoHandshakeMessage& message, |
392 bool should_include_version) { | 405 bool should_include_version) { |
393 CryptoFramer crypto_framer; | 406 CryptoFramer crypto_framer; |
394 scoped_ptr<QuicData> data(crypto_framer.ConstructHandshakeMessage(message)); | 407 scoped_ptr<QuicData> data(crypto_framer.ConstructHandshakeMessage(message)); |
395 QuicFramer quic_framer(QuicSupportedVersions(), QuicTime::Zero(), false); | 408 QuicFramer quic_framer(QuicSupportedVersions(), QuicTime::Zero(), false); |
396 | 409 |
397 QuicPacketHeader header; | 410 QuicPacketHeader header; |
398 header.public_header.guid = guid; | 411 header.public_header.guid = guid; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 data.AppendToString(&data_); | 488 data.AppendToString(&data_); |
476 return true; | 489 return true; |
477 } | 490 } |
478 | 491 |
479 void TestDecompressorVisitor::OnDecompressionError() { | 492 void TestDecompressorVisitor::OnDecompressionError() { |
480 error_ = true; | 493 error_ = true; |
481 } | 494 } |
482 | 495 |
483 } // namespace test | 496 } // namespace test |
484 } // namespace net | 497 } // namespace net |
OLD | NEW |