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

Side by Side Diff: net/tools/quic/quic_epoll_connection_helper_test.cc

Issue 476023002: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0814_2
Patch Set: Created 6 years, 4 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/test_tools/quic_test_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tools/quic/quic_epoll_connection_helper.h" 5 #include "net/tools/quic/quic_epoll_connection_helper.h"
6 6
7 #include "net/quic/crypto/quic_random.h" 7 #include "net/quic/crypto/quic_random.h"
8 #include "net/tools/quic/test_tools/mock_epoll_server.h" 8 #include "net/tools/quic/test_tools/mock_epoll_server.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 epoll_server_.AdvanceByExactlyAndCallCallbacks(delta.ToMicroseconds()); 96 epoll_server_.AdvanceByExactlyAndCallCallbacks(delta.ToMicroseconds());
97 EXPECT_EQ(start.Add(delta), clock->Now()); 97 EXPECT_EQ(start.Add(delta), clock->Now());
98 EXPECT_FALSE(delegate->fired()); 98 EXPECT_FALSE(delegate->fired());
99 99
100 epoll_server_.AdvanceByExactlyAndCallCallbacks( 100 epoll_server_.AdvanceByExactlyAndCallCallbacks(
101 new_delta.Subtract(delta).ToMicroseconds()); 101 new_delta.Subtract(delta).ToMicroseconds());
102 EXPECT_EQ(start.Add(new_delta), clock->Now()); 102 EXPECT_EQ(start.Add(new_delta), clock->Now());
103 EXPECT_TRUE(delegate->fired()); 103 EXPECT_TRUE(delegate->fired());
104 } 104 }
105 105
106 TEST_F(QuicEpollConnectionHelperTest, CreateAlarmAndUpdate) {
107 TestDelegate* delegate = new TestDelegate();
108 scoped_ptr<QuicAlarm> alarm(helper_.CreateAlarm(delegate));
109
110 const QuicClock* clock = helper_.GetClock();
111 QuicTime start = clock->Now();
112 QuicTime::Delta delta = QuicTime::Delta::FromMicroseconds(1);
113 alarm->Set(clock->Now().Add(delta));
114 QuicTime::Delta new_delta = QuicTime::Delta::FromMicroseconds(3);
115 alarm->Update(clock->Now().Add(new_delta),
116 QuicTime::Delta::FromMicroseconds(1));
117
118 epoll_server_.AdvanceByExactlyAndCallCallbacks(delta.ToMicroseconds());
119 EXPECT_EQ(start.Add(delta), clock->Now());
120 EXPECT_FALSE(delegate->fired());
121
122 // Move the alarm forward 1us and ensure it doesn't move forward.
123 alarm->Update(clock->Now().Add(new_delta),
124 QuicTime::Delta::FromMicroseconds(2));
125
126 epoll_server_.AdvanceByExactlyAndCallCallbacks(
127 new_delta.Subtract(delta).ToMicroseconds());
128 EXPECT_EQ(start.Add(new_delta), clock->Now());
129 EXPECT_TRUE(delegate->fired());
130
131 // Set the alarm via an update call.
132 new_delta = QuicTime::Delta::FromMicroseconds(5);
133 alarm->Update(clock->Now().Add(new_delta),
134 QuicTime::Delta::FromMicroseconds(1));
135 EXPECT_TRUE(alarm->IsSet());
136
137 // Update it with an uninitialized time and ensure it's cancelled.
138 alarm->Update(QuicTime::Zero(), QuicTime::Delta::FromMicroseconds(1));
139 EXPECT_FALSE(alarm->IsSet());
140 }
141
106 } // namespace 142 } // namespace
107 } // namespace test 143 } // namespace test
108 } // namespace tools 144 } // namespace tools
109 } // namespace net 145 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698