Index: net/nqe/network_quality_estimator_unittest.cc |
diff --git a/net/nqe/network_quality_estimator_unittest.cc b/net/nqe/network_quality_estimator_unittest.cc |
index bda59f09c1a716b02115d3206a8e583d4c0bcc53..2d8700a11a8d8848cba542c8c71cc20b8c195069 100644 |
--- a/net/nqe/network_quality_estimator_unittest.cc |
+++ b/net/nqe/network_quality_estimator_unittest.cc |
@@ -351,8 +351,9 @@ TEST(NetworkQualityEstimatorTest, Caching) { |
base::RunLoop().RunUntilIdle(); |
// Verify that the cached network quality was read, and observers were |
- // notified. |
- EXPECT_EQ(1U, observer.effective_connection_types().size()); |
+ // notified. |observer| must be notified once right after it was added, and |
+ // once again after the cached network quality was read. |
+ EXPECT_EQ(2U, observer.effective_connection_types().size()); |
EXPECT_EQ(1U, rtt_observer.observations().size()); |
EXPECT_EQ(1U, throughput_observer.observations().size()); |
} |
@@ -1434,6 +1435,13 @@ TEST(NetworkQualityEstimatorTest, TestEffectiveConnectionTypeObserver) { |
estimator.set_start_time_null_http_rtt( |
base::TimeDelta::FromMilliseconds(100)); |
EXPECT_EQ(2U, observer.effective_connection_types().size()); |
+ |
+ TestEffectiveConnectionTypeObserver observer_2; |
+ estimator.AddEffectiveConnectionTypeObserver(&observer_2); |
+ EXPECT_EQ(0U, observer_2.effective_connection_types().size()); |
+ base::RunLoop().RunUntilIdle(); |
+ // |observer_2| must be notified as soon as it is added. |
+ EXPECT_EQ(1U, observer_2.effective_connection_types().size()); |
} |
// Tests that the network quality is computed at the specified interval, and |
@@ -1507,6 +1515,18 @@ TEST(NetworkQualityEstimatorTest, TestRTTAndThroughputEstimatesObserver) { |
base::TimeDelta::FromMilliseconds(10000)); |
estimator.set_start_time_null_http_rtt(base::TimeDelta::FromMilliseconds(1)); |
EXPECT_EQ(0, observer.notifications_received() - notifications_received); |
+ |
+ TestRTTAndThroughputEstimatesObserver observer_2; |
+ estimator.AddRTTAndThroughputEstimatesObserver(&observer_2); |
+ EXPECT_EQ(nqe::internal::InvalidRTT(), observer_2.http_rtt()); |
+ EXPECT_EQ(nqe::internal::InvalidRTT(), observer_2.transport_rtt()); |
+ EXPECT_EQ(nqe::internal::kInvalidThroughput, |
+ observer_2.downstream_throughput_kbps()); |
+ base::RunLoop().RunUntilIdle(); |
+ EXPECT_NE(nqe::internal::InvalidRTT(), observer_2.http_rtt()); |
+ EXPECT_NE(nqe::internal::InvalidRTT(), observer_2.transport_rtt()); |
+ EXPECT_NE(nqe::internal::kInvalidThroughput, |
+ observer_2.downstream_throughput_kbps()); |
} |
// Tests that the effective connection type is computed on every RTT |