src/net/nqe/network_quality_estimator_util_unittest.cc
// Verify that IsPrivateHostForTesting() returns false for a hostname whose DNS
// resolution is not cached. Further, once the resolution is cached, verify that
// the cached entry is used.
Verify that IsPrivateHostForTesting() returns false for a hostname whose DNS
resolution is not cached. Further, once the resolution is cached, verify that
the cached entry is used.
Verify that IsPrivateHostForTesting () returns false for a hostname whose DNS resolution is not cached . Further once the resolution is cached verify that the cached entry is used .
TEST(NetworkQualityEstimatorUtilTest, ReservedHostUncached) {
  base::test::TaskEnvironment task_environment;
  MockCachingHostResolver mock_host_resolver;
  scoped_refptr<net::RuleBasedHostResolverProc> rules(
      new net::RuleBasedHostResolverProc(nullptr));
  rules->AddRule("example3.com", "127.0.0.3");
  mock_host_resolver.set_rules(rules.get());
  EXPECT_FALSE(IsPrivateHostForTesting(&mock_host_resolver,
                                       HostPortPair("example3.com", 443),
                                       NetworkIsolationKey()));
  EXPECT_EQ(0u, mock_host_resolver.num_non_local_resolves());
  int rv = mock_host_resolver.LoadIntoCache(
      HostPortPair("example3.com", 443), NetworkIsolationKey(), base::nullopt);
  EXPECT_EQ(OK, rv);
  EXPECT_EQ(1u, mock_host_resolver.num_non_local_resolves());
  EXPECT_TRUE(IsPrivateHostForTesting(&mock_host_resolver,
                                      HostPortPair("example3.com", 443),
                                      NetworkIsolationKey()));
  EXPECT_EQ(1u, mock_host_resolver.num_non_local_resolves());
}
TEST ( NetworkQualityEstimatorUtilTest , ReservedHostUncached ) { base :: test :: TaskEnvironment task_environment ; MockCachingHostResolver mock_host_resolver ; scoped_refptr < net :: RuleBasedHostResolverProc > rules ( new net :: RuleBasedHostResolverProc ( nullptr ) ) ; rules -> AddRule ( " " , " " ) ; mock_host_resolver . set_rules ( rules . get ( ) ) ; EXPECT_FALSE ( IsPrivateHostForTesting ( & mock_host_resolver , HostPortPair ( " " , 443 ) , NetworkIsolationKey ( ) ) ) ; EXPECT_EQ ( 0u , mock_host_resolver . num_non_local_resolves ( ) ) ; int rv = mock_host_resolver . LoadIntoCache ( HostPortPair ( " " , 443 ) , NetworkIsolationKey ( ) , base :: nullopt ) ; EXPECT_EQ ( OK , rv ) ; EXPECT_EQ ( 1u , mock_host_resolver . num_non_local_resolves ( ) ) ; EXPECT_TRUE ( IsPrivateHostForTesting ( & mock_host_resolver , HostPortPair ( " " , 443 ) , NetworkIsolationKey ( ) ) ) ; EXPECT_EQ ( 1u , mock_host_resolver . num_non_local_resolves ( ) ) ; }
Verify that IsPrivateHostForTesting() returns false for a hostname whose DNS
resolution is not cached.
Verify that IsPrivateHostForTesting () returns false for a hostname whose DNS resolution is not cached .
// Add example3.com resolution to the DNS cache. // Not in DNS host cache, so should not be marked as private. // IsPrivateHostForTesting() should have queried only the resolver's cache.