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

Unified Diff: net/quic/quic_packet_generator_test.cc

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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
Index: net/quic/quic_packet_generator_test.cc
diff --git a/net/quic/quic_packet_generator_test.cc b/net/quic/quic_packet_generator_test.cc
index ac99144fc2af5157929a4254d604a2397db7d073..7eea015f022342ed4ff2050a82247b695bde0c69 100644
--- a/net/quic/quic_packet_generator_test.cc
+++ b/net/quic/quic_packet_generator_test.cc
@@ -10,6 +10,7 @@
#include "net/quic/crypto/null_encrypter.h"
#include "net/quic/crypto/quic_decrypter.h"
#include "net/quic/crypto/quic_encrypter.h"
+#include "net/quic/quic_flags.h"
#include "net/quic/quic_utils.h"
#include "net/quic/test_tools/quic_packet_creator_peer.h"
#include "net/quic/test_tools/quic_packet_generator_peer.h"
@@ -315,6 +316,30 @@ TEST_F(QuicPacketGeneratorTest,
CheckPacketContains(contents, packet_);
}
+TEST_F(QuicPacketGeneratorTest, ShouldSendAck_MultipleCalls) {
+ ValueRestore<bool> old_flag(&FLAGS_quic_disallow_multiple_pending_ack_frames,
+ true);
+
+ // Make sure that calling SetShouldSendAck multiple times does not result in a
+ // crash. Previously this would result in multiple QuicFrames queued in the
+ // packet generator, with all but the last with internal pointers to freed
+ // memory.
+ delegate_.SetCanWriteAnything();
+
+ // Only one AckFrame should be created.
+ EXPECT_CALL(delegate_, CreateAckFrame())
+ .Times(1)
+ .WillOnce(Return(CreateAckFrame()));
+ EXPECT_CALL(delegate_, OnSerializedPacket(_))
+ .Times(1)
+ .WillOnce(SaveArg<0>(&packet_));
+
+ generator_.StartBatchOperations();
+ generator_.SetShouldSendAck(false, false);
+ generator_.SetShouldSendAck(false, false);
+ generator_.FinishBatchOperations();
+}
+
TEST_F(QuicPacketGeneratorTest, AddControlFrame_NotWritable) {
delegate_.SetCanNotWrite();

Powered by Google App Engine
This is Rietveld 408576698