OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/quic/congestion_control/rtt_stats.h" | 5 #include "net/quic/congestion_control/rtt_stats.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/test/mock_log.h" | 10 #include "base/test/mock_log.h" |
| 11 #include "net/quic/test_tools/rtt_stats_peer.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
13 using logging::LOG_WARNING; | 14 using logging::LOG_WARNING; |
14 using std::vector; | 15 using std::vector; |
15 using testing::HasSubstr; | 16 using testing::HasSubstr; |
16 using testing::Message; | 17 using testing::Message; |
17 using testing::_; | 18 using testing::_; |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 namespace test { | 21 namespace test { |
21 | 22 |
22 class RttStatsPeer { | |
23 public: | |
24 static QuicTime::Delta GetHalfWindowRtt(const RttStats* rtt_stats) { | |
25 return rtt_stats->half_window_rtt_.rtt; | |
26 } | |
27 | |
28 static QuicTime::Delta GetQuarterWindowRtt(const RttStats* rtt_stats) { | |
29 return rtt_stats->quarter_window_rtt_.rtt; | |
30 } | |
31 }; | |
32 | |
33 class RttStatsTest : public ::testing::Test { | 23 class RttStatsTest : public ::testing::Test { |
34 protected: | 24 protected: |
35 RttStats rtt_stats_; | 25 RttStats rtt_stats_; |
36 }; | 26 }; |
37 | 27 |
38 TEST_F(RttStatsTest, DefaultsBeforeUpdate) { | 28 TEST_F(RttStatsTest, DefaultsBeforeUpdate) { |
39 EXPECT_LT(0u, rtt_stats_.initial_rtt_us()); | 29 EXPECT_LT(0u, rtt_stats_.initial_rtt_us()); |
40 EXPECT_EQ(QuicTime::Delta::Zero(), rtt_stats_.min_rtt()); | 30 EXPECT_EQ(QuicTime::Delta::Zero(), rtt_stats_.min_rtt()); |
41 EXPECT_EQ(QuicTime::Delta::Zero(), rtt_stats_.smoothed_rtt()); | 31 EXPECT_EQ(QuicTime::Delta::Zero(), rtt_stats_.smoothed_rtt()); |
42 } | 32 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 QuicTime::Delta::Zero(), | 238 QuicTime::Delta::Zero(), |
249 QuicTime::Zero()); | 239 QuicTime::Zero()); |
250 EXPECT_EQ(initial_rtt, rtt_stats_.min_rtt()); | 240 EXPECT_EQ(initial_rtt, rtt_stats_.min_rtt()); |
251 EXPECT_EQ(initial_rtt, rtt_stats_.recent_min_rtt()); | 241 EXPECT_EQ(initial_rtt, rtt_stats_.recent_min_rtt()); |
252 EXPECT_EQ(initial_rtt, rtt_stats_.smoothed_rtt()); | 242 EXPECT_EQ(initial_rtt, rtt_stats_.smoothed_rtt()); |
253 } | 243 } |
254 } | 244 } |
255 | 245 |
256 } // namespace test | 246 } // namespace test |
257 } // namespace net | 247 } // namespace net |
OLD | NEW |