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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « net/quic/quic_ack_notifier_manager.cc ('k') | net/quic/quic_address_mismatch.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 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 using testing::_;
12
13 namespace net {
14 namespace test {
15 namespace {
16
17 class QuicAckNotifierTest : public ::testing::Test {
18 protected:
19 QuicAckNotifierTest() : zero_(QuicTime::Delta::Zero()) {}
20
21 void SetUp() override {
22 delegate_ = new MockAckNotifierDelegate;
23 notifier_.reset(new QuicAckNotifier(delegate_));
24
25 notifier_->OnSerializedPacket();
26 notifier_->OnSerializedPacket();
27 notifier_->OnSerializedPacket();
28 }
29
30 MockAckNotifierDelegate* delegate_;
31 scoped_ptr<QuicAckNotifier> notifier_;
32 QuicTime::Delta zero_;
33 };
34
35 // Should trigger callback when we receive acks for all the registered seqnums.
36 TEST_F(QuicAckNotifierTest, TriggerCallback) {
37 EXPECT_CALL(*delegate_, OnAckNotification(0, 0, zero_)).Times(1);
38 EXPECT_FALSE(notifier_->OnAck(zero_));
39 EXPECT_FALSE(notifier_->OnAck(zero_));
40 EXPECT_TRUE(notifier_->OnAck(zero_));
41 }
42
43 // Should not trigger callback if we never provide all the seqnums.
44 TEST_F(QuicAckNotifierTest, DoesNotTrigger) {
45 // Should not trigger callback as not all packets have been seen.
46 EXPECT_CALL(*delegate_, OnAckNotification(_, _, _)).Times(0);
47 EXPECT_FALSE(notifier_->OnAck(zero_));
48 EXPECT_FALSE(notifier_->OnAck(zero_));
49 }
50
51 // Should not trigger callback if we abandon all three packets.
52 TEST_F(QuicAckNotifierTest, AbandonDoesNotTrigger) {
53 // Should not trigger callback as not all packets have been seen.
54 EXPECT_CALL(*delegate_, OnAckNotification(_, _, _)).Times(0);
55 EXPECT_FALSE(notifier_->OnPacketAbandoned());
56 EXPECT_FALSE(notifier_->OnPacketAbandoned());
57 EXPECT_TRUE(notifier_->OnPacketAbandoned());
58 }
59
60 // Should trigger even after updating sequence numbers and receiving ACKs for
61 // new sequeunce numbers.
62 TEST_F(QuicAckNotifierTest, UpdateSeqNums) {
63 // Update a couple of the sequence numbers (i.e. retransmitted packets)
64 notifier_->OnPacketRetransmitted(20);
65 notifier_->OnPacketRetransmitted(3);
66
67 EXPECT_CALL(*delegate_, OnAckNotification(2, 20 + 3, _)).Times(1);
68 EXPECT_FALSE(notifier_->OnAck(zero_)); // original
69 EXPECT_FALSE(notifier_->OnAck(zero_)); // updated
70 EXPECT_TRUE(notifier_->OnAck(zero_)); // updated
71 }
72
73 // Make sure the delegate is called with the delta time from the last ACK.
74 TEST_F(QuicAckNotifierTest, DeltaTime) {
75 const QuicTime::Delta first_delta = QuicTime::Delta::FromSeconds(5);
76 const QuicTime::Delta second_delta = QuicTime::Delta::FromSeconds(33);
77 const QuicTime::Delta third_delta = QuicTime::Delta::FromSeconds(10);
78
79 EXPECT_CALL(*delegate_, OnAckNotification(0, 0, third_delta)).Times(1);
80 EXPECT_FALSE(notifier_->OnAck(first_delta));
81 EXPECT_FALSE(notifier_->OnAck(second_delta));
82 EXPECT_TRUE(notifier_->OnAck(third_delta));
83 }
84
85 } // namespace
86 } // namespace test
87 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_ack_notifier_manager.cc ('k') | net/quic/quic_address_mismatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698