diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 16:22:26 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 16:22:26 +0000 |
commit | 5e05717cbf0ff0fe8d3396522b07e8e23de21604 (patch) | |
tree | 50f714711c6a4e404730e75f4bf46d5a1d6282d9 /chrome/browser/net | |
parent | 80847f3446c37f784fbd724fc11f099d40ebe14c (diff) | |
download | chromium_src-5e05717cbf0ff0fe8d3396522b07e8e23de21604.zip chromium_src-5e05717cbf0ff0fe8d3396522b07e8e23de21604.tar.gz chromium_src-5e05717cbf0ff0fe8d3396522b07e8e23de21604.tar.bz2 |
Prevent making real DNS lookups by chrome tests.
- by default a test which makes external DNS lookup directly or indirectly will fail
- added a quite simple way to allow a test to make external queries
- added a way to make external queries fail (for tests which don't need them to succeed but it's hard to not make the query)
- made neccessary adjustments to existing tests so that they still pass
http://crbug.com/9109
Review URL: http://codereview.chromium.org/45026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12653 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/dns_master_unittest.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/chrome/browser/net/dns_master_unittest.cc b/chrome/browser/net/dns_master_unittest.cc index b57a2f0..a997b18 100644 --- a/chrome/browser/net/dns_master_unittest.cc +++ b/chrome/browser/net/dns_master_unittest.cc @@ -82,9 +82,10 @@ class DnsMasterTest : public testing::Test { MessageLoop::current()->Run(); } + scoped_refptr<net::RuleBasedHostMapper> mapper_; + private: MessageLoop loop; - scoped_refptr<net::RuleBasedHostMapper> mapper_; net::ScopedHostMapper scoped_mapper_; }; @@ -121,6 +122,8 @@ TimeDelta BlockingDnsLookup(const std::string& hostname) { // First test to be sure the OS is caching lookups, which is the whole premise // of DNS prefetching. TEST_F(DnsMasterTest, OsCachesLookupsTest) { + mapper_->AllowDirectLookup("*.google.com"); + const Time start = Time::Now(); int all_lookups = 0; int lookups_with_improvement = 0; @@ -273,14 +276,16 @@ TEST_F(DnsMasterTest, SingleLookupTest) { } TEST_F(DnsMasterTest, ConcurrentLookupTest) { + mapper_->AddSimulatedFailure("*.notfound"); + DnsMaster testing_master; std::string goog("www.google.com"), goog2("gmail.google.com.com"), goog3("mail.google.com"), goog4("gmail.com"); - std::string bad1(GetNonexistantDomain()), - bad2(GetNonexistantDomain()); + std::string bad1("bad1.notfound"), + bad2("bad2.notfound"); NameList names; names.insert(names.end(), goog); @@ -324,11 +329,13 @@ TEST_F(DnsMasterTest, ConcurrentLookupTest) { } TEST_F(DnsMasterTest, MassiveConcurrentLookupTest) { + mapper_->AddSimulatedFailure("*.notfound"); + DnsMaster testing_master; NameList names; for (int i = 0; i < 100; i++) - names.push_back(GetNonexistantDomain()); + names.push_back("host" + IntToString(i) + ".notfound"); // Try to flood the master with many concurrent requests. for (int i = 0; i < 10; i++) |