Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: net/quic/quic_framer_test.cc

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_packet_creator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <map> 6 #include <map>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 virtual void OnVersionNegotiationPacket( 184 virtual void OnVersionNegotiationPacket(
185 const QuicVersionNegotiationPacket& packet) OVERRIDE { 185 const QuicVersionNegotiationPacket& packet) OVERRIDE {
186 version_negotiation_packet_.reset(new QuicVersionNegotiationPacket(packet)); 186 version_negotiation_packet_.reset(new QuicVersionNegotiationPacket(packet));
187 } 187 }
188 188
189 virtual void OnRevivedPacket() OVERRIDE { 189 virtual void OnRevivedPacket() OVERRIDE {
190 revived_packets_++; 190 revived_packets_++;
191 } 191 }
192 192
193 virtual bool OnProtocolVersionMismatch( 193 virtual bool OnProtocolVersionMismatch(QuicTag version) OVERRIDE {
194 QuicVersionTag version) OVERRIDE {
195 DCHECK(false); 194 DCHECK(false);
196 return true; 195 return true;
197 } 196 }
198 197
199 virtual bool OnPacketHeader(const QuicPacketHeader& header) OVERRIDE { 198 virtual bool OnPacketHeader(const QuicPacketHeader& header) OVERRIDE {
200 packet_count_++; 199 packet_count_++;
201 header_.reset(new QuicPacketHeader(header)); 200 header_.reset(new QuicPacketHeader(header));
202 return accept_packet_; 201 return accept_packet_;
203 } 202 }
204 203
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } 565 }
567 566
568 TEST_F(QuicFramerTest, PacketHeaderWithVersionFlag) { 567 TEST_F(QuicFramerTest, PacketHeaderWithVersionFlag) {
569 unsigned char packet[] = { 568 unsigned char packet[] = {
570 // guid 569 // guid
571 0x10, 0x32, 0x54, 0x76, 570 0x10, 0x32, 0x54, 0x76,
572 0x98, 0xBA, 0xDC, 0xFE, 571 0x98, 0xBA, 0xDC, 0xFE,
573 // public flags (version) 572 // public flags (version)
574 0x01, 573 0x01,
575 // version tag 574 // version tag
576 'Q', '1', '.', '0', 575 'Q', '0', '0', '1',
577 // packet sequence number 576 // packet sequence number
578 0xBC, 0x9A, 0x78, 0x56, 577 0xBC, 0x9A, 0x78, 0x56,
579 0x34, 0x12, 578 0x34, 0x12,
580 // private flags 579 // private flags
581 0x00, 580 0x00,
582 // first fec protected packet offset 581 // first fec protected packet offset
583 0xFF, 582 0xFF,
584 }; 583 };
585 584
586 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 585 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 810 }
812 811
813 TEST_F(QuicFramerTest, StreamFrameWithVersion) { 812 TEST_F(QuicFramerTest, StreamFrameWithVersion) {
814 unsigned char packet[] = { 813 unsigned char packet[] = {
815 // guid 814 // guid
816 0x10, 0x32, 0x54, 0x76, 815 0x10, 0x32, 0x54, 0x76,
817 0x98, 0xBA, 0xDC, 0xFE, 816 0x98, 0xBA, 0xDC, 0xFE,
818 // public flags (version) 817 // public flags (version)
819 0x01, 818 0x01,
820 // version tag 819 // version tag
821 'Q', '1', '.', '0', 820 'Q', '0', '0', '1',
822 // packet sequence number 821 // packet sequence number
823 0xBC, 0x9A, 0x78, 0x56, 822 0xBC, 0x9A, 0x78, 0x56,
824 0x34, 0x12, 823 0x34, 0x12,
825 // private flags 824 // private flags
826 0x00, 825 0x00,
827 // first fec protected packet offset 826 // first fec protected packet offset
828 0xFF, 827 0xFF,
829 828
830 // frame type (stream frame) 829 // frame type (stream frame)
831 0x01, 830 0x01,
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 } 1619 }
1621 } 1620 }
1622 1621
1623 TEST_F(QuicFramerTest, VersionNegotiationPacket) { 1622 TEST_F(QuicFramerTest, VersionNegotiationPacket) {
1624 unsigned char packet[] = { 1623 unsigned char packet[] = {
1625 0x10, 0x32, 0x54, 0x76, 1624 0x10, 0x32, 0x54, 0x76,
1626 0x98, 0xBA, 0xDC, 0xFE, 1625 0x98, 0xBA, 0xDC, 0xFE,
1627 // public flags (version) 1626 // public flags (version)
1628 0x01, 1627 0x01,
1629 // version tag 1628 // version tag
1630 'Q', '1', '.', '0', 1629 'Q', '0', '0', '1',
1631 'Q', '2', '.', '0', 1630 'Q', '2', '.', '0',
1632 }; 1631 };
1633 1632
1634 QuicFramerPeer::SetIsServer(&framer_, false); 1633 QuicFramerPeer::SetIsServer(&framer_, false);
1635 1634
1636 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 1635 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
1637 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 1636 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
1638 ASSERT_EQ(QUIC_NO_ERROR, framer_.error()); 1637 ASSERT_EQ(QUIC_NO_ERROR, framer_.error());
1639 ASSERT_TRUE(visitor_.version_negotiation_packet_.get()); 1638 ASSERT_TRUE(visitor_.version_negotiation_packet_.get());
1640 EXPECT_EQ(2u, visitor_.version_negotiation_packet_->versions.size()); 1639 EXPECT_EQ(2u, visitor_.version_negotiation_packet_->versions.size());
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 QuicFrames frames; 1818 QuicFrames frames;
1820 frames.push_back(QuicFrame(&stream_frame)); 1819 frames.push_back(QuicFrame(&stream_frame));
1821 1820
1822 unsigned char packet[] = { 1821 unsigned char packet[] = {
1823 // guid 1822 // guid
1824 0x10, 0x32, 0x54, 0x76, 1823 0x10, 0x32, 0x54, 0x76,
1825 0x98, 0xBA, 0xDC, 0xFE, 1824 0x98, 0xBA, 0xDC, 0xFE,
1826 // public flags (version) 1825 // public flags (version)
1827 0x01, 1826 0x01,
1828 // version tag 1827 // version tag
1829 'Q', '1', '.', '0', 1828 'Q', '0', '0', '1',
1830 // packet sequence number 1829 // packet sequence number
1831 0xBC, 0x9A, 0x78, 0x56, 1830 0xBC, 0x9A, 0x78, 0x56,
1832 0x34, 0x12, 1831 0x34, 0x12,
1833 // private flags (entropy) 1832 // private flags (entropy)
1834 0x02, 1833 0x02,
1835 // first fec protected packet offset 1834 // first fec protected packet offset
1836 0xFF, 1835 0xFF,
1837 1836
1838 // frame type (stream frame) 1837 // frame type (stream frame)
1839 0x01, 1838 0x01,
(...skipping 27 matching lines...) Expand all
1867 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1866 header.guid = GG_UINT64_C(0xFEDCBA9876543210);
1868 header.reset_flag = false; 1867 header.reset_flag = false;
1869 header.version_flag = true; 1868 header.version_flag = true;
1870 1869
1871 unsigned char packet[] = { 1870 unsigned char packet[] = {
1872 0x10, 0x32, 0x54, 0x76, 1871 0x10, 0x32, 0x54, 0x76,
1873 0x98, 0xBA, 0xDC, 0xFE, 1872 0x98, 0xBA, 0xDC, 0xFE,
1874 // public flags (version) 1873 // public flags (version)
1875 0x01, 1874 0x01,
1876 // version tag 1875 // version tag
1877 'Q', '1', '.', '0', 1876 'Q', '0', '0', '1',
1878 'Q', '2', '.', '0', 1877 'Q', '2', '.', '0',
1879 }; 1878 };
1880 1879
1881 const int kQuicVersion2 = MakeQuicTag('Q', '2', '.', '0'); 1880 const int kQuicVersion2 = MakeQuicTag('Q', '2', '.', '0');
1882 QuicVersionTagList versions; 1881 QuicTagVector versions;
1883 versions.push_back(kQuicVersion1); 1882 versions.push_back(kQuicVersion1);
1884 versions.push_back(kQuicVersion2); 1883 versions.push_back(kQuicVersion2);
1885 scoped_ptr<QuicEncryptedPacket> data( 1884 scoped_ptr<QuicEncryptedPacket> data(
1886 framer_.ConstructVersionNegotiationPacket(header, versions)); 1885 framer_.ConstructVersionNegotiationPacket(header, versions));
1887 1886
1888 test::CompareCharArraysWithHexError("constructed packet", 1887 test::CompareCharArraysWithHexError("constructed packet",
1889 data->data(), data->length(), 1888 data->data(), data->length(),
1890 AsChars(packet), arraysize(packet)); 1889 AsChars(packet), arraysize(packet));
1891 } 1890 }
1892 1891
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
2797 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0); 2796 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0);
2798 EXPECT_CALL(visitor, OnPacketComplete()); 2797 EXPECT_CALL(visitor, OnPacketComplete());
2799 2798
2800 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 2799 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
2801 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 2800 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
2802 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 2801 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
2803 } 2802 }
2804 2803
2805 } // namespace test 2804 } // namespace test
2806 } // namespace net 2805 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_packet_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698