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/quic_packet_creator.h" | 5 #include "net/quic/quic_packet_creator.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "net/quic/crypto/null_encrypter.h" | 10 #include "net/quic/crypto/null_encrypter.h" |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 1514 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
1515 | 1515 |
1516 // Change current path back. | 1516 // Change current path back. |
1517 creator_.SetCurrentPath(kDefaultPathId, 2, 10000 / kDefaultMaxPacketSize); | 1517 creator_.SetCurrentPath(kDefaultPathId, 2, 10000 / kDefaultMaxPacketSize); |
1518 // FEC packet consumes a packet number. | 1518 // FEC packet consumes a packet number. |
1519 EXPECT_EQ(64 * 256 - max_packets_per_fec_group, creator_.packet_number()); | 1519 EXPECT_EQ(64 * 256 - max_packets_per_fec_group, creator_.packet_number()); |
1520 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, | 1520 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, |
1521 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); | 1521 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
1522 } | 1522 } |
1523 | 1523 |
| 1524 TEST_P(QuicPacketCreatorTest, SerializePacketOnDifferentPath) { |
| 1525 // Current path is the default path. |
| 1526 EXPECT_EQ(kDefaultPathId, QuicPacketCreatorPeer::GetCurrentPath(&creator_)); |
| 1527 EXPECT_EQ(0, creator_.packet_number()); |
| 1528 // Add a stream frame to the creator and flush the packet. |
| 1529 QuicFrame frame; |
| 1530 QuicIOVector io_vector(MakeIOVector("test")); |
| 1531 ASSERT_TRUE(creator_.ConsumeData(1u, io_vector, 0u, 0u, false, false, &frame, |
| 1532 MAY_FEC_PROTECT)); |
| 1533 ASSERT_TRUE(frame.stream_frame); |
| 1534 size_t consumed = frame.stream_frame->frame_length; |
| 1535 EXPECT_EQ(4u, consumed); |
| 1536 EXPECT_TRUE(creator_.HasPendingFrames()); |
| 1537 EXPECT_EQ(0, creator_.packet_number()); |
| 1538 EXPECT_CALL(delegate_, OnSerializedPacket(_)) |
| 1539 .WillRepeatedly( |
| 1540 Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); |
| 1541 creator_.Flush(); |
| 1542 EXPECT_FALSE(creator_.HasPendingFrames()); |
| 1543 EXPECT_EQ(1, creator_.packet_number()); |
| 1544 // Verify serialized data packet's path id. |
| 1545 EXPECT_EQ(kDefaultPathId, serialized_packet_.path_id); |
| 1546 ClearSerializedPacket(&serialized_packet_); |
| 1547 |
| 1548 // Change to path 1. |
| 1549 QuicPathId kPathId1 = 1; |
| 1550 creator_.SetCurrentPath(kPathId1, 1, 0); |
| 1551 EXPECT_EQ(kPathId1, QuicPacketCreatorPeer::GetCurrentPath(&creator_)); |
| 1552 EXPECT_FALSE(creator_.HasPendingFrames()); |
| 1553 EXPECT_EQ(0, creator_.packet_number()); |
| 1554 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
| 1555 QuicPacketCreatorPeer::NextPacketNumberLength(&creator_)); |
| 1556 |
| 1557 // Add a stream frame to the creator and flush the packet. |
| 1558 ASSERT_TRUE(creator_.ConsumeData(1u, io_vector, 0u, 0u, false, false, &frame, |
| 1559 MAY_FEC_PROTECT)); |
| 1560 ASSERT_TRUE(frame.stream_frame); |
| 1561 consumed = frame.stream_frame->frame_length; |
| 1562 EXPECT_EQ(4u, consumed); |
| 1563 EXPECT_TRUE(creator_.HasPendingFrames()); |
| 1564 creator_.Flush(); |
| 1565 // Verify serialized data packet's path id. |
| 1566 EXPECT_EQ(kPathId1, serialized_packet_.path_id); |
| 1567 ClearSerializedPacket(&serialized_packet_); |
| 1568 } |
| 1569 |
1524 } // namespace | 1570 } // namespace |
1525 } // namespace test | 1571 } // namespace test |
1526 } // namespace net | 1572 } // namespace net |
OLD | NEW |