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

Side by Side Diff: net/quic/quic_ack_notifier_test.cc

Issue 127633002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_ack_notifier.cc ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_ack_notifier.h" 5 #include "net/quic/quic_ack_notifier.h"
6 6
7 #include "net/quic/test_tools/quic_test_utils.h" 7 #include "net/quic/test_tools/quic_test_utils.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace net { 11 namespace net {
12 namespace test { 12 namespace test {
13 namespace { 13 namespace {
14 14
15 class QuicAckNotifierTest : public ::testing::Test { 15 class QuicAckNotifierTest : public ::testing::Test {
16 protected: 16 protected:
17 virtual void SetUp() { 17 virtual void SetUp() {
18 notifier_.reset(new QuicAckNotifier(&delegate_)); 18 delegate_ = new MockAckNotifierDelegate;
19 notifier_.reset(new QuicAckNotifier(delegate_));
19 20
20 sequence_numbers_.insert(26); 21 sequence_numbers_.insert(26);
21 sequence_numbers_.insert(99); 22 sequence_numbers_.insert(99);
22 sequence_numbers_.insert(1234); 23 sequence_numbers_.insert(1234);
23 notifier_->AddSequenceNumbers(sequence_numbers_); 24 notifier_->AddSequenceNumbers(sequence_numbers_);
24 } 25 }
25 26
26 SequenceNumberSet sequence_numbers_; 27 SequenceNumberSet sequence_numbers_;
27 MockAckNotifierDelegate delegate_; 28 MockAckNotifierDelegate* delegate_;
28 scoped_ptr<QuicAckNotifier> notifier_; 29 scoped_ptr<QuicAckNotifier> notifier_;
29 }; 30 };
30 31
31 // Should trigger callback when we receive acks for all the registered seqnums. 32 // Should trigger callback when we receive acks for all the registered seqnums.
32 TEST_F(QuicAckNotifierTest, TriggerCallback) { 33 TEST_F(QuicAckNotifierTest, TriggerCallback) {
33 EXPECT_CALL(delegate_, OnAckNotification()).Times(1); 34 EXPECT_CALL(*delegate_, OnAckNotification()).Times(1);
34 EXPECT_FALSE(notifier_->OnAck(26)); 35 EXPECT_FALSE(notifier_->OnAck(26));
35 EXPECT_FALSE(notifier_->OnAck(99)); 36 EXPECT_FALSE(notifier_->OnAck(99));
36 EXPECT_TRUE(notifier_->OnAck(1234)); 37 EXPECT_TRUE(notifier_->OnAck(1234));
37 } 38 }
38 39
39 // Should not trigger callback if we never provide all the seqnums. 40 // Should not trigger callback if we never provide all the seqnums.
40 TEST_F(QuicAckNotifierTest, DoesNotTrigger) { 41 TEST_F(QuicAckNotifierTest, DoesNotTrigger) {
41 // Should not trigger callback as not all packets have been seen. 42 // Should not trigger callback as not all packets have been seen.
42 EXPECT_CALL(delegate_, OnAckNotification()).Times(0); 43 EXPECT_CALL(*delegate_, OnAckNotification()).Times(0);
43 EXPECT_FALSE(notifier_->OnAck(26)); 44 EXPECT_FALSE(notifier_->OnAck(26));
44 EXPECT_FALSE(notifier_->OnAck(99)); 45 EXPECT_FALSE(notifier_->OnAck(99));
45 } 46 }
46 47
47 // Should trigger even after updating sequence numbers and receiving ACKs for 48 // Should trigger even after updating sequence numbers and receiving ACKs for
48 // new sequeunce numbers. 49 // new sequeunce numbers.
49 TEST_F(QuicAckNotifierTest, UpdateSeqNums) { 50 TEST_F(QuicAckNotifierTest, UpdateSeqNums) {
50 // Update a couple of the sequence numbers (i.e. retransmitted packets) 51 // Update a couple of the sequence numbers (i.e. retransmitted packets)
51 notifier_->UpdateSequenceNumber(99, 3000); 52 notifier_->UpdateSequenceNumber(99, 3000);
52 notifier_->UpdateSequenceNumber(1234, 3001); 53 notifier_->UpdateSequenceNumber(1234, 3001);
53 54
54 EXPECT_CALL(delegate_, OnAckNotification()).Times(1); 55 EXPECT_CALL(*delegate_, OnAckNotification()).Times(1);
55 EXPECT_FALSE(notifier_->OnAck(26)); // original 56 EXPECT_FALSE(notifier_->OnAck(26)); // original
56 EXPECT_FALSE(notifier_->OnAck(3000)); // updated 57 EXPECT_FALSE(notifier_->OnAck(3000)); // updated
57 EXPECT_TRUE(notifier_->OnAck(3001)); // updated 58 EXPECT_TRUE(notifier_->OnAck(3001)); // updated
58 } 59 }
59 60
60 } // namespace 61 } // namespace
61 } // namespace test 62 } // namespace test
62 } // namespace net 63 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_ack_notifier.cc ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698