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

Unified Diff: net/quic/quic_connection_test.cc

Issue 839143002: Roll Chrome into Mojo. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 11 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/quic_connection.cc ('k') | net/quic/quic_crypto_client_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection_test.cc
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index fe117665ec2b2ddfe1a0fee20faa54cef5a84e29..4ac928482a98d16c6f7480948a9ca380db658c7b 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -14,6 +14,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_ack_notifier.h"
#include "net/quic/quic_flags.h"
#include "net/quic/quic_protocol.h"
#include "net/quic/quic_utils.h"
@@ -26,6 +27,7 @@
#include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
#include "net/quic/test_tools/quic_test_utils.h"
#include "net/quic/test_tools/simple_quic_framer.h"
+#include "net/test/gtest_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -4136,7 +4138,7 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) {
ProcessFecPacket(2, 1, true, !kEntropyFlag, packet);
}
-TEST_P(QuicConnectionTest, NetworkChangeVisitorCallbacksChangeFecState) {
+TEST_P(QuicConnectionTest, NetworkChangeVisitorCwndCallbackChangesFecState) {
QuicPacketCreator* creator =
QuicConnectionPeer::GetPacketCreator(&connection_);
size_t max_packets_per_fec_group = creator->max_packets_per_fec_group();
@@ -4153,6 +4155,47 @@ TEST_P(QuicConnectionTest, NetworkChangeVisitorCallbacksChangeFecState) {
EXPECT_LT(max_packets_per_fec_group, creator->max_packets_per_fec_group());
}
+TEST_P(QuicConnectionTest, NetworkChangeVisitorConfigCallbackChangesFecState) {
+ QuicSentPacketManager* sent_packet_manager =
+ QuicConnectionPeer::GetSentPacketManager(&connection_);
+ QuicSentPacketManager::NetworkChangeVisitor* visitor =
+ QuicSentPacketManagerPeer::GetNetworkChangeVisitor(sent_packet_manager);
+ EXPECT_TRUE(visitor);
+
+ QuicPacketGenerator* generator =
+ QuicConnectionPeer::GetPacketGenerator(&connection_);
+ EXPECT_EQ(QuicTime::Delta::Zero(), generator->fec_timeout());
+
+ // Verify that sending a config with a new initial rtt changes fec timeout.
+ // Create and process a config with a non-zero initial RTT.
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
+ QuicConfig config;
+ config.SetInitialRoundTripTimeUsToSend(300000);
+ connection_.SetFromConfig(config);
+ EXPECT_LT(QuicTime::Delta::Zero(), generator->fec_timeout());
+}
+
+TEST_P(QuicConnectionTest, NetworkChangeVisitorRttCallbackChangesFecState) {
+ // Verify that sending a config with a new initial rtt changes fec timeout.
+ QuicSentPacketManager* sent_packet_manager =
+ QuicConnectionPeer::GetSentPacketManager(&connection_);
+ QuicSentPacketManager::NetworkChangeVisitor* visitor =
+ QuicSentPacketManagerPeer::GetNetworkChangeVisitor(sent_packet_manager);
+ EXPECT_TRUE(visitor);
+
+ QuicPacketGenerator* generator =
+ QuicConnectionPeer::GetPacketGenerator(&connection_);
+ EXPECT_EQ(QuicTime::Delta::Zero(), generator->fec_timeout());
+
+ // Increase FEC timeout by increasing RTT.
+ RttStats* rtt_stats =
+ QuicSentPacketManagerPeer::GetRttStats(sent_packet_manager);
+ rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(300),
+ QuicTime::Delta::Zero(), QuicTime::Zero());
+ visitor->OnRttChange();
+ EXPECT_LT(QuicTime::Delta::Zero(), generator->fec_timeout());
+}
+
class MockQuicConnectionDebugVisitor
: public QuicConnectionDebugVisitor {
public:
@@ -4248,6 +4291,17 @@ TEST_P(QuicConnectionTest, ControlFramesInstigateAcks) {
EXPECT_TRUE(ack_alarm->IsSet());
}
+TEST_P(QuicConnectionTest, NoDataNoFin) {
+ ValueRestore<bool> old_flag(&FLAGS_quic_empty_data_no_fin_early_return, true);
+ // Make sure that a call to SendStreamWithData, with no data and no FIN, does
+ // not result in a QuicAckNotifier being used-after-free (fail under ASAN).
+ // Regression test for b/18594622
+ scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
+ EXPECT_DFATAL(
+ connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()),
+ "Attempt to send empty stream frame");
+}
+
} // namespace
} // namespace test
} // namespace net
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_client_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698