| 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/core/congestion_control/rtt_stats.h" | 5 #include "net/quic/core/congestion_control/rtt_stats.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | |
| 10 #include "base/test/mock_log.h" | 9 #include "base/test/mock_log.h" |
| 11 #include "net/quic/test_tools/rtt_stats_peer.h" | 10 #include "net/quic/test_tools/rtt_stats_peer.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 12 |
| 14 using logging::LOG_WARNING; | 13 using logging::LOG_WARNING; |
| 15 using testing::HasSubstr; | 14 using testing::HasSubstr; |
| 16 using testing::Message; | 15 using testing::Message; |
| 17 using testing::_; | 16 using testing::_; |
| 18 | 17 |
| 19 namespace net { | 18 namespace net { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 146 |
| 148 std::vector<QuicTime::Delta> bad_send_deltas; | 147 std::vector<QuicTime::Delta> bad_send_deltas; |
| 149 bad_send_deltas.push_back(QuicTime::Delta::Zero()); | 148 bad_send_deltas.push_back(QuicTime::Delta::Zero()); |
| 150 bad_send_deltas.push_back(QuicTime::Delta::Infinite()); | 149 bad_send_deltas.push_back(QuicTime::Delta::Infinite()); |
| 151 bad_send_deltas.push_back(QuicTime::Delta::FromMicroseconds(-1000)); | 150 bad_send_deltas.push_back(QuicTime::Delta::FromMicroseconds(-1000)); |
| 152 log.StartCapturingLogs(); | 151 log.StartCapturingLogs(); |
| 153 | 152 |
| 154 for (QuicTime::Delta bad_send_delta : bad_send_deltas) { | 153 for (QuicTime::Delta bad_send_delta : bad_send_deltas) { |
| 155 SCOPED_TRACE(Message() << "bad_send_delta = " | 154 SCOPED_TRACE(Message() << "bad_send_delta = " |
| 156 << bad_send_delta.ToMicroseconds()); | 155 << bad_send_delta.ToMicroseconds()); |
| 156 #ifndef NDEBUG |
| 157 EXPECT_CALL(log, Log(LOG_WARNING, _, _, _, HasSubstr("Ignoring"))); | 157 EXPECT_CALL(log, Log(LOG_WARNING, _, _, _, HasSubstr("Ignoring"))); |
| 158 #endif |
| 158 rtt_stats_.UpdateRtt(bad_send_delta, QuicTime::Delta::Zero(), | 159 rtt_stats_.UpdateRtt(bad_send_delta, QuicTime::Delta::Zero(), |
| 159 QuicTime::Zero()); | 160 QuicTime::Zero()); |
| 160 EXPECT_EQ(initial_rtt, rtt_stats_.min_rtt()); | 161 EXPECT_EQ(initial_rtt, rtt_stats_.min_rtt()); |
| 161 EXPECT_EQ(initial_rtt, rtt_stats_.smoothed_rtt()); | 162 EXPECT_EQ(initial_rtt, rtt_stats_.smoothed_rtt()); |
| 162 } | 163 } |
| 163 } | 164 } |
| 164 | 165 |
| 165 TEST_F(RttStatsTest, ResetAfterConnectionMigrations) { | 166 TEST_F(RttStatsTest, ResetAfterConnectionMigrations) { |
| 166 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(300), | 167 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(300), |
| 167 QuicTime::Delta::FromMilliseconds(100), | 168 QuicTime::Delta::FromMilliseconds(100), |
| 168 QuicTime::Zero()); | 169 QuicTime::Zero()); |
| 169 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(200), rtt_stats_.latest_rtt()); | 170 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(200), rtt_stats_.latest_rtt()); |
| 170 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(200), rtt_stats_.smoothed_rtt()); | 171 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(200), rtt_stats_.smoothed_rtt()); |
| 171 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(300), rtt_stats_.min_rtt()); | 172 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(300), rtt_stats_.min_rtt()); |
| 172 | 173 |
| 173 // Reset rtt stats on connection migrations. | 174 // Reset rtt stats on connection migrations. |
| 174 rtt_stats_.OnConnectionMigration(); | 175 rtt_stats_.OnConnectionMigration(); |
| 175 EXPECT_EQ(QuicTime::Delta::Zero(), rtt_stats_.latest_rtt()); | 176 EXPECT_EQ(QuicTime::Delta::Zero(), rtt_stats_.latest_rtt()); |
| 176 EXPECT_EQ(QuicTime::Delta::Zero(), rtt_stats_.smoothed_rtt()); | 177 EXPECT_EQ(QuicTime::Delta::Zero(), rtt_stats_.smoothed_rtt()); |
| 177 EXPECT_EQ(QuicTime::Delta::Zero(), rtt_stats_.min_rtt()); | 178 EXPECT_EQ(QuicTime::Delta::Zero(), rtt_stats_.min_rtt()); |
| 178 } | 179 } |
| 179 | 180 |
| 180 } // namespace test | 181 } // namespace test |
| 181 } // namespace net | 182 } // namespace net |
| OLD | NEW |