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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_epoll_connection_helper_test.cc
diff --git a/net/tools/quic/quic_epoll_connection_helper_test.cc b/net/tools/quic/quic_epoll_connection_helper_test.cc
index 0f977f4fb305f5d620e089a4d0a283ecc60a7c5a..708bdd4b6b0672e0a858257e97a994e4ba4619be 100644
--- a/net/tools/quic/quic_epoll_connection_helper_test.cc
+++ b/net/tools/quic/quic_epoll_connection_helper_test.cc
@@ -103,6 +103,42 @@ TEST_F(QuicEpollConnectionHelperTest, CreateAlarmAndReset) {
EXPECT_TRUE(delegate->fired());
}
+TEST_F(QuicEpollConnectionHelperTest, CreateAlarmAndUpdate) {
+ TestDelegate* delegate = new TestDelegate();
+ scoped_ptr<QuicAlarm> alarm(helper_.CreateAlarm(delegate));
+
+ const QuicClock* clock = helper_.GetClock();
+ QuicTime start = clock->Now();
+ QuicTime::Delta delta = QuicTime::Delta::FromMicroseconds(1);
+ alarm->Set(clock->Now().Add(delta));
+ QuicTime::Delta new_delta = QuicTime::Delta::FromMicroseconds(3);
+ alarm->Update(clock->Now().Add(new_delta),
+ QuicTime::Delta::FromMicroseconds(1));
+
+ epoll_server_.AdvanceByExactlyAndCallCallbacks(delta.ToMicroseconds());
+ EXPECT_EQ(start.Add(delta), clock->Now());
+ EXPECT_FALSE(delegate->fired());
+
+ // Move the alarm forward 1us and ensure it doesn't move forward.
+ alarm->Update(clock->Now().Add(new_delta),
+ QuicTime::Delta::FromMicroseconds(2));
+
+ epoll_server_.AdvanceByExactlyAndCallCallbacks(
+ new_delta.Subtract(delta).ToMicroseconds());
+ EXPECT_EQ(start.Add(new_delta), clock->Now());
+ EXPECT_TRUE(delegate->fired());
+
+ // Set the alarm via an update call.
+ new_delta = QuicTime::Delta::FromMicroseconds(5);
+ alarm->Update(clock->Now().Add(new_delta),
+ QuicTime::Delta::FromMicroseconds(1));
+ EXPECT_TRUE(alarm->IsSet());
+
+ // Update it with an uninitialized time and ensure it's cancelled.
+ alarm->Update(QuicTime::Zero(), QuicTime::Delta::FromMicroseconds(1));
+ EXPECT_FALSE(alarm->IsSet());
+}
+
} // namespace
} // namespace test
} // namespace tools
« 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