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

Unified Diff: net/quic/quic_ack_notifier_test.cc

Issue 23464033: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix valgrind error Created 7 years, 3 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_ack_notifier.cc ('k') | net/quic/quic_client_session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_ack_notifier_test.cc
diff --git a/net/quic/quic_ack_notifier_test.cc b/net/quic/quic_ack_notifier_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1899dd1346bd7f34d00fdd23fdbdf5d28c124d0d
--- /dev/null
+++ b/net/quic/quic_ack_notifier_test.cc
@@ -0,0 +1,106 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/quic/quic_ack_notifier.h"
+
+#include "net/quic/test_tools/quic_test_utils.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace test {
+namespace {
+
+class QuicAckNotifierTest : public ::testing::Test {
+ protected:
+ virtual void SetUp() {
+ notifier_.reset(new QuicAckNotifier(&delegate_));
+
+ sequence_numbers_.insert(26);
+ sequence_numbers_.insert(99);
+ sequence_numbers_.insert(1234);
+ notifier_->AddSequenceNumbers(sequence_numbers_);
+ }
+
+ SequenceNumberSet sequence_numbers_;
+ MockAckNotifierDelegate delegate_;
+ scoped_ptr<QuicAckNotifier> notifier_;
+};
+
+// Should trigger callback when we receive acks for all the registered seqnums.
+TEST_F(QuicAckNotifierTest, TriggerCallback) {
+ EXPECT_CALL(delegate_, OnAckNotification()).Times(1);
+ EXPECT_TRUE(notifier_->OnAck(sequence_numbers_));
+}
+
+// Should trigger callback when we receive acks for all the registered seqnums,
+// even though they are interspersed with other seqnums.
+TEST_F(QuicAckNotifierTest, TriggerCallbackInterspersed) {
+ sequence_numbers_.insert(3);
+ sequence_numbers_.insert(55);
+ sequence_numbers_.insert(805);
+
+ EXPECT_CALL(delegate_, OnAckNotification()).Times(1);
+ EXPECT_TRUE(notifier_->OnAck(sequence_numbers_));
+}
+
+// Should trigger callback when we receive acks for all the registered seqnums,
+// even though they are split over multiple calls to OnAck.
+TEST_F(QuicAckNotifierTest, TriggerCallbackMultipleCalls) {
+ SequenceNumberSet seqnums;
+ seqnums.insert(26);
+ EXPECT_CALL(delegate_, OnAckNotification()).Times(0);
+ EXPECT_FALSE(notifier_->OnAck(seqnums));
+
+ seqnums.clear();
+ seqnums.insert(55);
+ seqnums.insert(9001);
+ seqnums.insert(99);
+ EXPECT_CALL(delegate_, OnAckNotification()).Times(0);
+ EXPECT_FALSE(notifier_->OnAck(seqnums));
+
+ seqnums.clear();
+ seqnums.insert(1234);
+ EXPECT_CALL(delegate_, OnAckNotification()).Times(1);
+ EXPECT_TRUE(notifier_->OnAck(seqnums));
+}
+
+// Should not trigger callback if we never provide all the seqnums.
+TEST_F(QuicAckNotifierTest, DoesNotTrigger) {
+ SequenceNumberSet different_seqnums;
+ different_seqnums.insert(14);
+ different_seqnums.insert(15);
+ different_seqnums.insert(16);
+
+ // Should not trigger callback as not all packets have been seen.
+ EXPECT_CALL(delegate_, OnAckNotification()).Times(0);
+ EXPECT_FALSE(notifier_->OnAck(different_seqnums));
+}
+
+// Should trigger even after updating sequence numbers and receiving ACKs for
+// new sequeunce numbers.
+TEST_F(QuicAckNotifierTest, UpdateSeqNums) {
+ // Uninteresting sequeunce numbers shouldn't trigger callback.
+ SequenceNumberSet seqnums;
+ seqnums.insert(6);
+ seqnums.insert(7);
+ seqnums.insert(2000);
+ EXPECT_CALL(delegate_, OnAckNotification()).Times(0);
+ EXPECT_FALSE(notifier_->OnAck(seqnums));
+
+ // Update a couple of the sequence numbers (i.e. retransmitted packets)
+ notifier_->UpdateSequenceNumber(99, 3000);
+ notifier_->UpdateSequenceNumber(1234, 3001);
+
+ seqnums.clear();
+ seqnums.insert(26); // original, unchanged
+ seqnums.insert(3000); // updated
+ seqnums.insert(3001); // updated
+ EXPECT_CALL(delegate_, OnAckNotification()).Times(1);
+ EXPECT_TRUE(notifier_->OnAck(seqnums));
+}
+
+} // namespace
+} // namespace test
+} // namespace net
« no previous file with comments | « net/quic/quic_ack_notifier.cc ('k') | net/quic/quic_client_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698