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

Unified Diff: net/quic/core/quic_packet_creator_test.cc

Issue 2963763003: In QUIC, send data is copied to streams rather than frames. Protected by FLAGS_quic_reloadable_flag… (Closed)
Patch Set: Rebase Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/quic_packet_creator.cc ('k') | net/quic/core/quic_packet_generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/quic_packet_creator_test.cc
diff --git a/net/quic/core/quic_packet_creator_test.cc b/net/quic/core/quic_packet_creator_test.cc
index ae317668d6023f5da47749426c6e07e69e642e64..285006bf1f623d08d15b096640963f192dc8a0bf 100644
--- a/net/quic/core/quic_packet_creator_test.cc
+++ b/net/quic/core/quic_packet_creator_test.cc
@@ -13,6 +13,7 @@
#include "net/quic/core/crypto/null_encrypter.h"
#include "net/quic/core/crypto/quic_decrypter.h"
#include "net/quic/core/crypto/quic_encrypter.h"
+#include "net/quic/core/quic_data_writer.h"
#include "net/quic/core/quic_pending_retransmission.h"
#include "net/quic/core/quic_simple_buffer_allocator.h"
#include "net/quic/core/quic_utils.h"
@@ -22,6 +23,7 @@
#include "net/quic/test_tools/quic_framer_peer.h"
#include "net/quic/test_tools/quic_packet_creator_peer.h"
#include "net/quic/test_tools/quic_test_utils.h"
+#include "net/quic/test_tools/simple_data_producer.h"
using std::string;
using testing::DoAll;
@@ -41,21 +43,25 @@ const QuicStreamId kGetNthClientInitiatedStreamId1 = kHeadersStreamId + 2;
struct TestParams {
TestParams(QuicVersion version,
bool version_serialization,
- QuicConnectionIdLength length)
+ QuicConnectionIdLength length,
+ bool delegate_saves_data)
: version(version),
connection_id_length(length),
- version_serialization(version_serialization) {}
+ version_serialization(version_serialization),
+ delegate_saves_data(delegate_saves_data) {}
friend std::ostream& operator<<(std::ostream& os, const TestParams& p) {
os << "{ client_version: " << QuicVersionToString(p.version)
<< " connection id length: " << p.connection_id_length
- << " include version: " << p.version_serialization << " }";
+ << " include version: " << p.version_serialization
+ << " delegate_saves_data: " << p.delegate_saves_data << " }";
return os;
}
QuicVersion version;
QuicConnectionIdLength connection_id_length;
bool version_serialization;
+ bool delegate_saves_data;
};
// Constructs various test permutations.
@@ -63,31 +69,22 @@ std::vector<TestParams> GetTestParams() {
std::vector<TestParams> params;
constexpr QuicConnectionIdLength kMax = PACKET_8BYTE_CONNECTION_ID;
QuicVersionVector all_supported_versions = AllSupportedVersions();
- for (size_t i = 0; i < all_supported_versions.size(); ++i) {
- params.push_back(TestParams(all_supported_versions[i], true, kMax));
- params.push_back(TestParams(all_supported_versions[i], false, kMax));
+ for (bool delegate_saves_data : {true, false}) {
+ for (size_t i = 0; i < all_supported_versions.size(); ++i) {
+ params.push_back(TestParams(all_supported_versions[i], true, kMax,
+ delegate_saves_data));
+ params.push_back(TestParams(all_supported_versions[i], false, kMax,
+ delegate_saves_data));
+ }
+ params.push_back(TestParams(all_supported_versions[0], true,
+ PACKET_0BYTE_CONNECTION_ID,
+ delegate_saves_data));
+ params.push_back(
+ TestParams(all_supported_versions[0], true, kMax, delegate_saves_data));
}
- params.push_back(
- TestParams(all_supported_versions[0], true, PACKET_0BYTE_CONNECTION_ID));
- params.push_back(TestParams(all_supported_versions[0], true, kMax));
return params;
}
-class MockDelegate : public QuicPacketCreator::DelegateInterface {
- public:
- MockDelegate() {}
- ~MockDelegate() override {}
-
- MOCK_METHOD1(OnSerializedPacket, void(SerializedPacket* packet));
- MOCK_METHOD3(OnUnrecoverableError,
- void(QuicErrorCode,
- const string&,
- ConnectionCloseSource source));
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockDelegate);
-};
-
class QuicPacketCreatorTest : public QuicTestWithParam<TestParams> {
public:
void ClearSerializedPacketForTests(SerializedPacket* serialized_packet) {
@@ -136,6 +133,9 @@ class QuicPacketCreatorTest : public QuicTestWithParam<TestParams> {
new NullEncrypter(Perspective::IS_CLIENT));
client_framer_.set_visitor(&framer_visitor_);
server_framer_.set_visitor(&framer_visitor_);
+ if (GetParam().delegate_saves_data) {
+ creator_.set_delegate_saves_data(true);
+ }
}
~QuicPacketCreatorTest() override {
@@ -165,8 +165,19 @@ class QuicPacketCreatorTest : public QuicTestWithParam<TestParams> {
EXPECT_EQ(STREAM_FRAME, frame.type);
ASSERT_TRUE(frame.stream_frame);
EXPECT_EQ(stream_id, frame.stream_frame->stream_id);
- EXPECT_EQ(data, QuicStringPiece(frame.stream_frame->data_buffer,
- frame.stream_frame->data_length));
+ if (GetParam().delegate_saves_data) {
+ char buf[kMaxPacketSize];
+ QuicDataWriter writer(kMaxPacketSize, buf, Perspective::IS_CLIENT,
+ HOST_BYTE_ORDER);
+ if (frame.stream_frame->data_length > 0) {
+ delegate_.WriteStreamData(stream_id, frame.stream_frame->offset,
+ frame.stream_frame->data_length, &writer);
+ }
+ EXPECT_EQ(data, QuicStringPiece(buf, frame.stream_frame->data_length));
+ } else {
+ EXPECT_EQ(data, QuicStringPiece(frame.stream_frame->data_buffer,
+ frame.stream_frame->data_length));
+ }
EXPECT_EQ(offset, frame.stream_frame->offset);
EXPECT_EQ(fin, frame.stream_frame->fin);
}
@@ -216,13 +227,14 @@ class QuicPacketCreatorTest : public QuicTestWithParam<TestParams> {
QuicFramer server_framer_;
QuicFramer client_framer_;
StrictMock<MockFramerVisitor> framer_visitor_;
- StrictMock<MockDelegate> delegate_;
+ StrictMock<MockPacketCreatorDelegate> delegate_;
QuicConnectionId connection_id_;
string data_;
struct iovec iov_;
SimpleBufferAllocator buffer_allocator_;
QuicPacketCreator creator_;
SerializedPacket serialized_packet_;
+ SimpleDataProducer producer_;
};
// Run all packet creator tests with all supported versions of QUIC, and with
« no previous file with comments | « net/quic/core/quic_packet_creator.cc ('k') | net/quic/core/quic_packet_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698