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

Unified Diff: net/tools/quic/quic_epoll_connection_helper_test.cc

Issue 1572353002: QuicAlarms are now allocated out of an arena in QuicConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge recent changes. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/quic_epoll_connection_helper.cc ('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 36ea8bd2983f790f4c713ffcf5f456ec47bdee1a..abb02d0eef948689c31f1f9d79c09294770df22a 100644
--- a/net/tools/quic/quic_epoll_connection_helper_test.cc
+++ b/net/tools/quic/quic_epoll_connection_helper_test.cc
@@ -53,9 +53,28 @@ TEST_F(QuicEpollConnectionHelperTest, GetRandomGenerator) {
EXPECT_EQ(QuicRandom::GetInstance(), random);
}
-TEST_F(QuicEpollConnectionHelperTest, CreateAlarm) {
- TestDelegate* delegate = new TestDelegate();
- scoped_ptr<QuicAlarm> alarm(helper_.CreateAlarm(delegate));
+// The boolean parameter denotes whether or not to use an arena.
+class QuicEpollConnectionHelperAlarmTest
+ : public QuicEpollConnectionHelperTest,
+ public ::testing::WithParamInterface<bool> {
+ protected:
+ QuicConnectionArena* GetArenaParam() {
+ return GetParam() ? &arena_ : nullptr;
+ }
+
+ private:
+ QuicConnectionArena arena_;
+};
+
+INSTANTIATE_TEST_CASE_P(QuicEpollConnectionHelperAlarmTest,
+ QuicEpollConnectionHelperAlarmTest,
+ ::testing::Bool());
+
+TEST_P(QuicEpollConnectionHelperAlarmTest, CreateAlarm) {
+ QuicArenaScopedPtr<TestDelegate> delegate =
+ QuicArenaScopedPtr<TestDelegate>(new TestDelegate());
+ QuicArenaScopedPtr<QuicAlarm> alarm(
+ helper_.CreateAlarm(std::move(delegate), GetArenaParam()));
const QuicClock* clock = helper_.GetClock();
QuicTime start = clock->Now();
@@ -67,9 +86,12 @@ TEST_F(QuicEpollConnectionHelperTest, CreateAlarm) {
EXPECT_EQ(start.Add(delta), clock->Now());
}
-TEST_F(QuicEpollConnectionHelperTest, CreateAlarmAndCancel) {
- TestDelegate* delegate = new TestDelegate();
- scoped_ptr<QuicAlarm> alarm(helper_.CreateAlarm(delegate));
+TEST_P(QuicEpollConnectionHelperAlarmTest, CreateAlarmAndCancel) {
+ QuicArenaScopedPtr<TestDelegate> delegate =
+ QuicArenaScopedPtr<TestDelegate>(new TestDelegate());
+ TestDelegate* unowned_delegate = delegate.get();
+ QuicArenaScopedPtr<QuicAlarm> alarm(
+ helper_.CreateAlarm(std::move(delegate), GetArenaParam()));
const QuicClock* clock = helper_.GetClock();
QuicTime start = clock->Now();
@@ -79,12 +101,15 @@ TEST_F(QuicEpollConnectionHelperTest, CreateAlarmAndCancel) {
epoll_server_.AdvanceByExactlyAndCallCallbacks(delta.ToMicroseconds());
EXPECT_EQ(start.Add(delta), clock->Now());
- EXPECT_FALSE(delegate->fired());
+ EXPECT_FALSE(unowned_delegate->fired());
}
-TEST_F(QuicEpollConnectionHelperTest, CreateAlarmAndReset) {
- TestDelegate* delegate = new TestDelegate();
- scoped_ptr<QuicAlarm> alarm(helper_.CreateAlarm(delegate));
+TEST_P(QuicEpollConnectionHelperAlarmTest, CreateAlarmAndReset) {
+ QuicArenaScopedPtr<TestDelegate> delegate =
+ QuicArenaScopedPtr<TestDelegate>(new TestDelegate());
+ TestDelegate* unowned_delegate = delegate.get();
+ QuicArenaScopedPtr<QuicAlarm> alarm(
+ helper_.CreateAlarm(std::move(delegate), GetArenaParam()));
const QuicClock* clock = helper_.GetClock();
QuicTime start = clock->Now();
@@ -96,17 +121,20 @@ TEST_F(QuicEpollConnectionHelperTest, CreateAlarmAndReset) {
epoll_server_.AdvanceByExactlyAndCallCallbacks(delta.ToMicroseconds());
EXPECT_EQ(start.Add(delta), clock->Now());
- EXPECT_FALSE(delegate->fired());
+ EXPECT_FALSE(unowned_delegate->fired());
epoll_server_.AdvanceByExactlyAndCallCallbacks(
new_delta.Subtract(delta).ToMicroseconds());
EXPECT_EQ(start.Add(new_delta), clock->Now());
- EXPECT_TRUE(delegate->fired());
+ EXPECT_TRUE(unowned_delegate->fired());
}
-TEST_F(QuicEpollConnectionHelperTest, CreateAlarmAndUpdate) {
- TestDelegate* delegate = new TestDelegate();
- scoped_ptr<QuicAlarm> alarm(helper_.CreateAlarm(delegate));
+TEST_P(QuicEpollConnectionHelperAlarmTest, CreateAlarmAndUpdate) {
+ QuicArenaScopedPtr<TestDelegate> delegate =
+ QuicArenaScopedPtr<TestDelegate>(new TestDelegate());
+ TestDelegate* unowned_delegate = delegate.get();
+ QuicArenaScopedPtr<QuicAlarm> alarm(
+ helper_.CreateAlarm(std::move(delegate), GetArenaParam()));
const QuicClock* clock = helper_.GetClock();
QuicTime start = clock->Now();
@@ -118,7 +146,7 @@ TEST_F(QuicEpollConnectionHelperTest, CreateAlarmAndUpdate) {
epoll_server_.AdvanceByExactlyAndCallCallbacks(delta.ToMicroseconds());
EXPECT_EQ(start.Add(delta), clock->Now());
- EXPECT_FALSE(delegate->fired());
+ EXPECT_FALSE(unowned_delegate->fired());
// Move the alarm forward 1us and ensure it doesn't move forward.
alarm->Update(clock->Now().Add(new_delta),
@@ -127,7 +155,7 @@ TEST_F(QuicEpollConnectionHelperTest, CreateAlarmAndUpdate) {
epoll_server_.AdvanceByExactlyAndCallCallbacks(
new_delta.Subtract(delta).ToMicroseconds());
EXPECT_EQ(start.Add(new_delta), clock->Now());
- EXPECT_TRUE(delegate->fired());
+ EXPECT_TRUE(unowned_delegate->fired());
// Set the alarm via an update call.
new_delta = QuicTime::Delta::FromMicroseconds(5);
« no previous file with comments | « net/tools/quic/quic_epoll_connection_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698