src/net/base/network_change_notifier_unittest.cc
TEST(NetworkChangeNotifierTest, NetMaxBandwidthRange) {
  NetworkChangeNotifier::ConnectionType connection_type =
      NetworkChangeNotifier::CONNECTION_NONE;
  double max_bandwidth = 0.0;
  NetworkChangeNotifier::GetMaxBandwidthAndConnectionType(&max_bandwidth,
                                                          &connection_type);

  // Always accept infinity as it's the default value if the bandwidth is
  // unknown.
  if (max_bandwidth == std::numeric_limits<double>::infinity()) {
    EXPECT_NE(NetworkChangeNotifier::CONNECTION_NONE, connection_type);
    return;
  }

  switch (connection_type) {
    case NetworkChangeNotifier::CONNECTION_UNKNOWN:
      EXPECT_EQ(std::numeric_limits<double>::infinity(), max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_ETHERNET:
      EXPECT_GE(10.0, max_bandwidth);
      EXPECT_LE(10000.0, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_WIFI:
      EXPECT_GE(1.0, max_bandwidth);
      EXPECT_LE(7000.0, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_2G:
      EXPECT_GE(0.01, max_bandwidth);
      EXPECT_LE(0.384, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_3G:
      EXPECT_GE(2.0, max_bandwidth);
      EXPECT_LE(42.0, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_4G:
      EXPECT_GE(100.0, max_bandwidth);
      EXPECT_LE(100.0, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_5G:
      // TODO(crbug.com/1127134): Expect proper bounds once we have introduced
      // subtypes for 5G connections.
      EXPECT_EQ(std::numeric_limits<double>::infinity(), max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_NONE:
      EXPECT_EQ(0.0, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_BLUETOOTH:
      EXPECT_GE(1.0, max_bandwidth);
      EXPECT_LE(24.0, max_bandwidth);
      break;
  }
}
// Note: This test is subject to the host's OS and network connection. This test
// is not future-proof. New standards will come about necessitating the need to
// alter the ranges of these tests.
This test is subject to the host's OS and network connection. This test
is not future-proof. New standards will come about necessitating the need to
alter the ranges of these tests.
This test is subject to the host ' s OS and network connection . This test is not future - proof . New standards will come about necessitating the need to alter the ranges of these tests .
TEST(NetworkChangeNotifierTest, NetMaxBandwidthRange) {
  NetworkChangeNotifier::ConnectionType connection_type =
      NetworkChangeNotifier::CONNECTION_NONE;
  double max_bandwidth = 0.0;
  NetworkChangeNotifier::GetMaxBandwidthAndConnectionType(&max_bandwidth,
                                                          &connection_type);
  if (max_bandwidth == std::numeric_limits<double>::infinity()) {
    EXPECT_NE(NetworkChangeNotifier::CONNECTION_NONE, connection_type);
    return;
  }
  switch (connection_type) {
    case NetworkChangeNotifier::CONNECTION_UNKNOWN:
      EXPECT_EQ(std::numeric_limits<double>::infinity(), max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_ETHERNET:
      EXPECT_GE(10.0, max_bandwidth);
      EXPECT_LE(10000.0, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_WIFI:
      EXPECT_GE(1.0, max_bandwidth);
      EXPECT_LE(7000.0, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_2G:
      EXPECT_GE(0.01, max_bandwidth);
      EXPECT_LE(0.384, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_3G:
      EXPECT_GE(2.0, max_bandwidth);
      EXPECT_LE(42.0, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_4G:
      EXPECT_GE(100.0, max_bandwidth);
      EXPECT_LE(100.0, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_5G:
      EXPECT_EQ(std::numeric_limits<double>::infinity(), max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_NONE:
      EXPECT_EQ(0.0, max_bandwidth);
      break;
    case NetworkChangeNotifier::CONNECTION_BLUETOOTH:
      EXPECT_GE(1.0, max_bandwidth);
      EXPECT_LE(24.0, max_bandwidth);
      break;
  }
}
TEST ( NetworkChangeNotifierTest , NetMaxBandwidthRange ) { NetworkChangeNotifier :: ConnectionType connection_type = NetworkChangeNotifier :: CONNECTION_NONE ; double max_bandwidth = 0.0 ; NetworkChangeNotifier :: GetMaxBandwidthAndConnectionType ( & max_bandwidth , & connection_type ) ; if ( max_bandwidth == std :: numeric_limits < double > :: infinity ( ) ) { EXPECT_NE ( NetworkChangeNotifier :: CONNECTION_NONE , connection_type ) ; return ; } switch ( connection_type ) { case NetworkChangeNotifier :: CONNECTION_UNKNOWN : EXPECT_EQ ( std :: numeric_limits < double > :: infinity ( ) , max_bandwidth ) ; break ; case NetworkChangeNotifier :: CONNECTION_ETHERNET : EXPECT_GE ( 10.0 , max_bandwidth ) ; EXPECT_LE ( 10000.0 , max_bandwidth ) ; break ; case NetworkChangeNotifier :: CONNECTION_WIFI : EXPECT_GE ( 1.0 , max_bandwidth ) ; EXPECT_LE ( 7000.0 , max_bandwidth ) ; break ; case NetworkChangeNotifier :: CONNECTION_2G : EXPECT_GE ( 0.01 , max_bandwidth ) ; EXPECT_LE ( 0.384 , max_bandwidth ) ; break ; case NetworkChangeNotifier :: CONNECTION_3G : EXPECT_GE ( 2.0 , max_bandwidth ) ; EXPECT_LE ( 42.0 , max_bandwidth ) ; break ; case NetworkChangeNotifier :: CONNECTION_4G : EXPECT_GE ( 100.0 , max_bandwidth ) ; EXPECT_LE ( 100.0 , max_bandwidth ) ; break ; case NetworkChangeNotifier :: CONNECTION_5G : EXPECT_EQ ( std :: numeric_limits < double > :: infinity ( ) , max_bandwidth ) ; break ; case NetworkChangeNotifier :: CONNECTION_NONE : EXPECT_EQ ( 0.0 , max_bandwidth ) ; break ; case NetworkChangeNotifier :: CONNECTION_BLUETOOTH : EXPECT_GE ( 1.0 , max_bandwidth ) ; EXPECT_LE ( 24.0 , max_bandwidth ) ; break ; } }
Note: This test is subject to the host's OS and network connection.
Note : This test is subject to the host ' s OS and network connection .
// Always accept infinity as it's the default value if the bandwidth is // unknown. // TODO(crbug.com/1127134): Expect proper bounds once we have introduced // subtypes for 5G connections.