src/net/nqe/network_congestion_analyzer_unittest.cc
TEST_F(NetworkCongestionAnalyzerTest, TestStartingNewMeasurementPeriod) {
  TestNetworkQualityEstimator network_quality_estimator;
  base::SimpleTestTickClock tick_clock;

  network_quality_estimator.set_effective_connection_type(
      EFFECTIVE_CONNECTION_TYPE_2G);
  NetworkCongestionAnalyzer analyzer(&network_quality_estimator, &tick_clock);
  base::TimeDelta low_queueing_delay_sample =
      kLowQueueingDelayThresholds[EFFECTIVE_CONNECTION_TYPE_2G];

  // Checks that a new measurement period starts immediately if the queueing
  // delay is low and the number of in-flight requests are equal or less than 1.
  EXPECT_FALSE(
      analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 2));
  EXPECT_TRUE(analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 1));
  EXPECT_TRUE(analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 0));

  // Checks that a new measurement period starts after waiting for a sufficient
  // time interval when the number of in-flight requests is 2.
  EXPECT_FALSE(
      analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 2));
  tick_clock.Advance(
      base::TimeDelta::FromMilliseconds(kMinEmptyQueueObservingTimeMsec / 2));
  EXPECT_FALSE(
      analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 2));
  tick_clock.Advance(
      base::TimeDelta::FromMilliseconds(kMinEmptyQueueObservingTimeMsec / 2));
  EXPECT_TRUE(analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 2));
}
// Verifies that a measurement period starts correctly when an empty queue
// observation shows up. An empty queue observation is made when the queueing
// delay is low and the number of in-flight requests is also low.
Verifies that a measurement period starts correctly when an empty queue
observation shows up. An empty queue observation is made when the queueing
delay is low and the number of in-flight requests is also low.
Verifies that a measurement period starts correctly when an empty queue observation shows up . An empty queue observation is made when the queueing delay is low and the number of in - flight requests is also low .
TEST_F(NetworkCongestionAnalyzerTest, TestStartingNewMeasurementPeriod) {
  TestNetworkQualityEstimator network_quality_estimator;
  base::SimpleTestTickClock tick_clock;
  network_quality_estimator.set_effective_connection_type(
      EFFECTIVE_CONNECTION_TYPE_2G);
  NetworkCongestionAnalyzer analyzer(&network_quality_estimator, &tick_clock);
  base::TimeDelta low_queueing_delay_sample =
      kLowQueueingDelayThresholds[EFFECTIVE_CONNECTION_TYPE_2G];
  EXPECT_FALSE(
      analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 2));
  EXPECT_TRUE(analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 1));
  EXPECT_TRUE(analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 0));
  EXPECT_FALSE(
      analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 2));
  tick_clock.Advance(
      base::TimeDelta::FromMilliseconds(kMinEmptyQueueObservingTimeMsec / 2));
  EXPECT_FALSE(
      analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 2));
  tick_clock.Advance(
      base::TimeDelta::FromMilliseconds(kMinEmptyQueueObservingTimeMsec / 2));
  EXPECT_TRUE(analyzer.ShouldStartNewMeasurement(low_queueing_delay_sample, 2));
}
TEST_F ( NetworkCongestionAnalyzerTest , TestStartingNewMeasurementPeriod ) { TestNetworkQualityEstimator network_quality_estimator ; base :: SimpleTestTickClock tick_clock ; network_quality_estimator . set_effective_connection_type ( EFFECTIVE_CONNECTION_TYPE_2G ) ; NetworkCongestionAnalyzer analyzer ( & network_quality_estimator , & tick_clock ) ; base :: TimeDelta low_queueing_delay_sample = kLowQueueingDelayThresholds [ EFFECTIVE_CONNECTION_TYPE_2G ] ; EXPECT_FALSE ( analyzer . ShouldStartNewMeasurement ( low_queueing_delay_sample , 2 ) ) ; EXPECT_TRUE ( analyzer . ShouldStartNewMeasurement ( low_queueing_delay_sample , 1 ) ) ; EXPECT_TRUE ( analyzer . ShouldStartNewMeasurement ( low_queueing_delay_sample , 0 ) ) ; EXPECT_FALSE ( analyzer . ShouldStartNewMeasurement ( low_queueing_delay_sample , 2 ) ) ; tick_clock . Advance ( base :: TimeDelta :: FromMilliseconds ( kMinEmptyQueueObservingTimeMsec / 2 ) ) ; EXPECT_FALSE ( analyzer . ShouldStartNewMeasurement ( low_queueing_delay_sample , 2 ) ) ; tick_clock . Advance ( base :: TimeDelta :: FromMilliseconds ( kMinEmptyQueueObservingTimeMsec / 2 ) ) ; EXPECT_TRUE ( analyzer . ShouldStartNewMeasurement ( low_queueing_delay_sample , 2 ) ) ; }
Verifies that a measurement period starts correctly when an empty queue
observation shows up.
Verifies that a measurement period starts correctly when an empty queue observation shows up .
// Checks that a new measurement period starts immediately if the queueing // delay is low and the number of in-flight requests are equal or less than 1. // Checks that a new measurement period starts after waiting for a sufficient // time interval when the number of in-flight requests is 2.