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

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

Issue 47283002: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation error Created 7 years, 1 month 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_stream_factory_test.cc ('k') | net/quic/quic_utils.cc » ('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 "net/quic/quic_stream_sequencer.h" 5 #include "net/quic/quic_stream_sequencer.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "net/base/ip_endpoint.h"
11 #include "net/quic/reliable_quic_stream.h" 12 #include "net/quic/reliable_quic_stream.h"
13 #include "net/quic/test_tools/quic_test_utils.h"
12 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 16
15 using base::StringPiece; 17 using base::StringPiece;
16 using std::min; 18 using std::min;
17 using std::pair; 19 using std::pair;
18 using std::vector; 20 using std::vector;
19 using testing::_; 21 using testing::_;
20 using testing::AnyNumber; 22 using testing::AnyNumber;
21 using testing::InSequence; 23 using testing::InSequence;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 }; 80 };
79 81
80 namespace { 82 namespace {
81 83
82 static const char kPayload[] = 84 static const char kPayload[] =
83 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 85 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
84 86
85 class QuicStreamSequencerTest : public ::testing::Test { 87 class QuicStreamSequencerTest : public ::testing::Test {
86 protected: 88 protected:
87 QuicStreamSequencerTest() 89 QuicStreamSequencerTest()
88 : session_(NULL), 90 : connection_(new MockConnection(1, IPEndPoint(), false)),
89 stream_(session_, 1), 91 session_(connection_, true),
92 stream_(&session_, 1),
90 sequencer_(new QuicStreamSequencerPeer(&stream_)) { 93 sequencer_(new QuicStreamSequencerPeer(&stream_)) {
91 } 94 }
92 95
93 bool VerifyReadableRegions(const char** expected, size_t num_expected) { 96 bool VerifyReadableRegions(const char** expected, size_t num_expected) {
94 iovec iovecs[5]; 97 iovec iovecs[5];
95 size_t num_iovecs = sequencer_->GetReadableRegions(iovecs, 98 size_t num_iovecs = sequencer_->GetReadableRegions(iovecs,
96 arraysize(iovecs)); 99 arraysize(iovecs));
97 return VerifyIovecs(iovecs, num_iovecs, expected, num_expected); 100 return VerifyIovecs(iovecs, num_iovecs, expected, num_expected);
98 } 101 }
99 102
(...skipping 21 matching lines...) Expand all
121 return false; 124 return false;
122 } 125 }
123 if (memcmp(iovec.iov_base, expected.data(), expected.length()) != 0) { 126 if (memcmp(iovec.iov_base, expected.data(), expected.length()) != 0) {
124 LOG(ERROR) << "Invalid data: " << static_cast<char*>(iovec.iov_base) 127 LOG(ERROR) << "Invalid data: " << static_cast<char*>(iovec.iov_base)
125 << " vs " << expected.data(); 128 << " vs " << expected.data();
126 return false; 129 return false;
127 } 130 }
128 return true; 131 return true;
129 } 132 }
130 133
131 QuicSession* session_; 134 MockConnection* connection_;
135 MockSession session_;
132 testing::StrictMock<MockStream> stream_; 136 testing::StrictMock<MockStream> stream_;
133 scoped_ptr<QuicStreamSequencerPeer> sequencer_; 137 scoped_ptr<QuicStreamSequencerPeer> sequencer_;
134 }; 138 };
135 139
136 TEST_F(QuicStreamSequencerTest, RejectOldFrame) { 140 TEST_F(QuicStreamSequencerTest, RejectOldFrame) {
137 EXPECT_CALL(stream_, ProcessData(StrEq("abc"), 3)) 141 EXPECT_CALL(stream_, ProcessData(StrEq("abc"), 3))
138 .WillOnce(Return(3)); 142 .WillOnce(Return(3));
139 143
140 EXPECT_TRUE(sequencer_->OnFrame(0, "abc")); 144 EXPECT_TRUE(sequencer_->OnFrame(0, "abc"));
141 EXPECT_EQ(0u, sequencer_->frames()->size()); 145 EXPECT_EQ(0u, sequencer_->frames()->size());
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 573
570 if (acked) { 574 if (acked) {
571 list_.erase(list_.begin() + index); 575 list_.erase(list_.begin() + index);
572 } 576 }
573 } 577 }
574 } 578 }
575 579
576 } // namespace 580 } // namespace
577 } // namespace test 581 } // namespace test
578 } // namespace net 582 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory_test.cc ('k') | net/quic/quic_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698