src/net/nqe/network_quality_estimator_util_unittest.cc
// Verify that the cached network qualities from the prefs are not used if the
// reading of the network quality prefs is not enabled..
Verify that the cached network qualities from the prefs are not used if the
reading of the network quality prefs is not enabled
Verify that the cached network qualities from the prefs are not used if the reading of the network quality prefs is not enabled
TEST(NetworkQualityEstimatorUtilTest, ReservedHost) {
  base::test::TaskEnvironment task_environment;
  MockCachingHostResolver mock_host_resolver;
  scoped_refptr<net::RuleBasedHostResolverProc> rules(
      new net::RuleBasedHostResolverProc(nullptr));
  rules->AddRule("example1.com", "127.0.0.3");
  rules->AddRule("example2.com", "27.0.0.3");
  mock_host_resolver.set_rules(rules.get());
  EXPECT_EQ(0u, mock_host_resolver.num_resolve());
  int rv = mock_host_resolver.LoadIntoCache(
      HostPortPair("example1.com", 443), NetworkIsolationKey(), base::nullopt);
  EXPECT_EQ(OK, rv);
  rv = mock_host_resolver.LoadIntoCache(HostPortPair("example2.com", 443),
                                        NetworkIsolationKey(), base::nullopt);
  EXPECT_EQ(OK, rv);
  EXPECT_EQ(2u, mock_host_resolver.num_non_local_resolves());
  EXPECT_FALSE(IsPrivateHostForTesting(
      &mock_host_resolver, HostPortPair("2607:f8b0:4006:819::200e", 80),
      NetworkIsolationKey()));
  EXPECT_TRUE(IsPrivateHostForTesting(&mock_host_resolver,
                                      HostPortPair("192.168.0.1", 443),
                                      NetworkIsolationKey()));
  EXPECT_FALSE(IsPrivateHostForTesting(&mock_host_resolver,
                                       HostPortPair("92.168.0.1", 443),
                                       NetworkIsolationKey()));
  EXPECT_TRUE(IsPrivateHostForTesting(&mock_host_resolver,
                                      HostPortPair("example1.com", 443),
                                      NetworkIsolationKey()));
  EXPECT_FALSE(IsPrivateHostForTesting(&mock_host_resolver,
                                       HostPortPair("example2.com", 443),
                                       NetworkIsolationKey()));
  EXPECT_EQ(2u, mock_host_resolver.num_non_local_resolves());
}
TEST ( NetworkQualityEstimatorUtilTest , ReservedHost ) { base :: test :: TaskEnvironment task_environment ; MockCachingHostResolver mock_host_resolver ; scoped_refptr < net :: RuleBasedHostResolverProc > rules ( new net :: RuleBasedHostResolverProc ( nullptr ) ) ; rules -> AddRule ( " " , " " ) ; rules -> AddRule ( " " , " " ) ; mock_host_resolver . set_rules ( rules . get ( ) ) ; EXPECT_EQ ( 0u , mock_host_resolver . num_resolve ( ) ) ; int rv = mock_host_resolver . LoadIntoCache ( HostPortPair ( " " , 443 ) , NetworkIsolationKey ( ) , base :: nullopt ) ; EXPECT_EQ ( OK , rv ) ; rv = mock_host_resolver . LoadIntoCache ( HostPortPair ( " " , 443 ) , NetworkIsolationKey ( ) , base :: nullopt ) ; EXPECT_EQ ( OK , rv ) ; EXPECT_EQ ( 2u , mock_host_resolver . num_non_local_resolves ( ) ) ; EXPECT_FALSE ( IsPrivateHostForTesting ( & mock_host_resolver , HostPortPair ( " " , 80 ) , NetworkIsolationKey ( ) ) ) ; EXPECT_TRUE ( IsPrivateHostForTesting ( & mock_host_resolver , HostPortPair ( " " , 443 ) , NetworkIsolationKey ( ) ) ) ; EXPECT_FALSE ( IsPrivateHostForTesting ( & mock_host_resolver , HostPortPair ( " " , 443 ) , NetworkIsolationKey ( ) ) ) ; EXPECT_TRUE ( IsPrivateHostForTesting ( & mock_host_resolver , HostPortPair ( " " , 443 ) , NetworkIsolationKey ( ) ) ) ; EXPECT_FALSE ( IsPrivateHostForTesting ( & mock_host_resolver , HostPortPair ( " " , 443 ) , NetworkIsolationKey ( ) ) ) ; EXPECT_EQ ( 2u , mock_host_resolver . num_non_local_resolves ( ) ) ; }
Verify that the cached network qualities from the prefs are not used if the
reading of the network quality prefs is not enabled..
Verify that the cached network qualities from the prefs are not used if the reading of the network quality prefs is not enabled ..
// example1.com resolves to a private IP address. // example2.com resolves to a public IP address. // Load hostnames into HostResolver cache. // IsPrivateHostForTesting() should have queried only the resolver's cache.