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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_ack_notifier.cc ('k') | net/quic/quic_client_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/quic/quic_ack_notifier.h"
6
7 #include "net/quic/test_tools/quic_test_utils.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace net {
12 namespace test {
13 namespace {
14
15 class QuicAckNotifierTest : public ::testing::Test {
16 protected:
17 virtual void SetUp() {
18 notifier_.reset(new QuicAckNotifier(&delegate_));
19
20 sequence_numbers_.insert(26);
21 sequence_numbers_.insert(99);
22 sequence_numbers_.insert(1234);
23 notifier_->AddSequenceNumbers(sequence_numbers_);
24 }
25
26 SequenceNumberSet sequence_numbers_;
27 MockAckNotifierDelegate delegate_;
28 scoped_ptr<QuicAckNotifier> notifier_;
29 };
30
31 // Should trigger callback when we receive acks for all the registered seqnums.
32 TEST_F(QuicAckNotifierTest, TriggerCallback) {
33 EXPECT_CALL(delegate_, OnAckNotification()).Times(1);
34 EXPECT_TRUE(notifier_->OnAck(sequence_numbers_));
35 }
36
37 // Should trigger callback when we receive acks for all the registered seqnums,
38 // even though they are interspersed with other seqnums.
39 TEST_F(QuicAckNotifierTest, TriggerCallbackInterspersed) {
40 sequence_numbers_.insert(3);
41 sequence_numbers_.insert(55);
42 sequence_numbers_.insert(805);
43
44 EXPECT_CALL(delegate_, OnAckNotification()).Times(1);
45 EXPECT_TRUE(notifier_->OnAck(sequence_numbers_));
46 }
47
48 // Should trigger callback when we receive acks for all the registered seqnums,
49 // even though they are split over multiple calls to OnAck.
50 TEST_F(QuicAckNotifierTest, TriggerCallbackMultipleCalls) {
51 SequenceNumberSet seqnums;
52 seqnums.insert(26);
53 EXPECT_CALL(delegate_, OnAckNotification()).Times(0);
54 EXPECT_FALSE(notifier_->OnAck(seqnums));
55
56 seqnums.clear();
57 seqnums.insert(55);
58 seqnums.insert(9001);
59 seqnums.insert(99);
60 EXPECT_CALL(delegate_, OnAckNotification()).Times(0);
61 EXPECT_FALSE(notifier_->OnAck(seqnums));
62
63 seqnums.clear();
64 seqnums.insert(1234);
65 EXPECT_CALL(delegate_, OnAckNotification()).Times(1);
66 EXPECT_TRUE(notifier_->OnAck(seqnums));
67 }
68
69 // Should not trigger callback if we never provide all the seqnums.
70 TEST_F(QuicAckNotifierTest, DoesNotTrigger) {
71 SequenceNumberSet different_seqnums;
72 different_seqnums.insert(14);
73 different_seqnums.insert(15);
74 different_seqnums.insert(16);
75
76 // Should not trigger callback as not all packets have been seen.
77 EXPECT_CALL(delegate_, OnAckNotification()).Times(0);
78 EXPECT_FALSE(notifier_->OnAck(different_seqnums));
79 }
80
81 // Should trigger even after updating sequence numbers and receiving ACKs for
82 // new sequeunce numbers.
83 TEST_F(QuicAckNotifierTest, UpdateSeqNums) {
84 // Uninteresting sequeunce numbers shouldn't trigger callback.
85 SequenceNumberSet seqnums;
86 seqnums.insert(6);
87 seqnums.insert(7);
88 seqnums.insert(2000);
89 EXPECT_CALL(delegate_, OnAckNotification()).Times(0);
90 EXPECT_FALSE(notifier_->OnAck(seqnums));
91
92 // Update a couple of the sequence numbers (i.e. retransmitted packets)
93 notifier_->UpdateSequenceNumber(99, 3000);
94 notifier_->UpdateSequenceNumber(1234, 3001);
95
96 seqnums.clear();
97 seqnums.insert(26); // original, unchanged
98 seqnums.insert(3000); // updated
99 seqnums.insert(3001); // updated
100 EXPECT_CALL(delegate_, OnAckNotification()).Times(1);
101 EXPECT_TRUE(notifier_->OnAck(seqnums));
102 }
103
104 } // namespace
105 } // namespace test
106 } // namespace net
OLDNEW
« 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