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

Side by Side Diff: webrtc/p2p/quic/quicconnectionhelper_unittest.cc

Issue 1834233002: Update QuicTransportChannel to latest version of libquic (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 | « webrtc/p2p/quic/quicconnectionhelper.cc ('k') | webrtc/p2p/quic/quicsession.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/p2p/quic/quicconnectionhelper.h" 11 #include "webrtc/p2p/quic/quicconnectionhelper.h"
12 12
13 #include "net/quic/quic_time.h" 13 #include "net/quic/quic_time.h"
14 #include "webrtc/base/gunit.h" 14 #include "webrtc/base/gunit.h"
15 #include "webrtc/base/scoped_ptr.h"
15 16
16 using cricket::QuicAlarm; 17 using cricket::QuicAlarm;
17 using cricket::QuicConnectionHelper; 18 using cricket::QuicConnectionHelper;
18 19
19 using net::QuicClock; 20 using net::QuicClock;
20 using net::QuicTime; 21 using net::QuicTime;
21 using net::QuicWallTime; 22 using net::QuicWallTime;
22 23
23 // Clock that can be set to arbitrary times. 24 // Clock that can be set to arbitrary times.
24 class MockClock : public QuicClock { 25 class MockClock : public QuicClock {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void Clear() { fired_ = false; } 61 void Clear() { fired_ = false; }
61 62
62 private: 63 private:
63 bool fired_; 64 bool fired_;
64 }; 65 };
65 66
66 class QuicAlarmTest : public ::testing::Test { 67 class QuicAlarmTest : public ::testing::Test {
67 public: 68 public:
68 QuicAlarmTest() 69 QuicAlarmTest()
69 : delegate_(new MockAlarmDelegate()), 70 : delegate_(new MockAlarmDelegate()),
70 alarm_(new QuicAlarm(&clock_, rtc::Thread::Current(), delegate_)) {} 71 alarm_(new QuicAlarm(
72 &clock_,
73 rtc::Thread::Current(),
74 net::QuicArenaScopedPtr<net::QuicAlarm::Delegate>(delegate_))) {}
71 75
72 // Make the alarm fire after the given microseconds (us). Negative values 76 // Make the alarm fire after the given microseconds (us). Negative values
73 // imply the alarm should fire immediately. 77 // imply the alarm should fire immediately.
74 void SetTime(int us) { 78 void SetTime(int us) {
75 QuicTime::Delta delta = QuicTime::Delta::FromMicroseconds(us); 79 QuicTime::Delta delta = QuicTime::Delta::FromMicroseconds(us);
76 alarm_->Set(clock_.Now().Add(delta)); 80 alarm_->Set(clock_.Now().Add(delta));
77 } 81 }
78 82
79 // Make rtc::Thread::Current() process the next message. 83 // Make rtc::Thread::Current() process the next message.
80 void ProcessNextMessage() { rtc::Thread::Current()->ProcessMessages(0); } 84 void ProcessNextMessage() { rtc::Thread::Current()->ProcessMessages(0); }
81 85
82 protected: 86 protected:
83 // Handles event that alarm fires. 87 // Handles event that alarm fires.
84 MockAlarmDelegate* delegate_; 88 MockAlarmDelegate* delegate_;
85 // Used for setting clock time relative to alarm. 89 // Used for setting clock time relative to alarm.
86 MockClock clock_; 90 MockClock clock_;
87 91
88 scoped_ptr<QuicAlarm> alarm_; 92 rtc::scoped_ptr<QuicAlarm> alarm_;
89 }; 93 };
90 94
91 // Test that the alarm is fired. 95 // Test that the alarm is fired.
92 TEST_F(QuicAlarmTest, FireAlarm) { 96 TEST_F(QuicAlarmTest, FireAlarm) {
93 SetTime(-1); 97 SetTime(-1);
94 ProcessNextMessage(); 98 ProcessNextMessage();
95 ASSERT_TRUE(delegate_->fired()); 99 ASSERT_TRUE(delegate_->fired());
96 ASSERT_EQ(QuicTime::Zero(), alarm_->deadline()); 100 ASSERT_EQ(QuicTime::Zero(), alarm_->deadline());
97 } 101 }
98 102
(...skipping 15 matching lines...) Expand all
114 ASSERT_FALSE(delegate_->fired()); 118 ASSERT_FALSE(delegate_->fired());
115 } 119 }
116 120
117 // Test that timing for posting task is accurate. 121 // Test that timing for posting task is accurate.
118 TEST_F(QuicAlarmTest, AlarmGetDelay) { 122 TEST_F(QuicAlarmTest, AlarmGetDelay) {
119 SetTime(1000000); 123 SetTime(1000000);
120 EXPECT_EQ(1000, alarm_->GetDelay()); 124 EXPECT_EQ(1000, alarm_->GetDelay());
121 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(300000)); 125 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(300000));
122 EXPECT_EQ(700, alarm_->GetDelay()); 126 EXPECT_EQ(700, alarm_->GetDelay());
123 } 127 }
OLDNEW
« no previous file with comments | « webrtc/p2p/quic/quicconnectionhelper.cc ('k') | webrtc/p2p/quic/quicsession.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698