summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 08:58:48 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 08:58:48 +0000
commit7844fc5edc61e4e90509f90bf0ee0cb110889ca9 (patch)
tree820820e9c61e6684fc8c6b63eaf80a50bc8c7ccb
parent4259f9cc708d8f67d7f935d267da9a7ffa852b65 (diff)
downloadchromium_src-7844fc5edc61e4e90509f90bf0ee0cb110889ca9.zip
chromium_src-7844fc5edc61e4e90509f90bf0ee0cb110889ca9.tar.gz
chromium_src-7844fc5edc61e4e90509f90bf0ee0cb110889ca9.tar.bz2
Adjustments in chrome_test_suite external dns lookups detection code:
- allow resolving local hostname - simulate a failing lookup of "wpad" in in_process_browser_test Review URL: http://codereview.chromium.org/63019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13239 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/test/in_process_browser_test.cc10
-rw-r--r--chrome/test/unit/chrome_test_suite.h16
2 files changed, 17 insertions, 9 deletions
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index e3c064d..a9fa5c4 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -112,13 +112,15 @@ void InProcessBrowserTest::SetUp() {
params.ui_task =
NewRunnableMethod(this, &InProcessBrowserTest::RunTestOnMainThreadLoop);
- // TODO(sky): Don't make a real dns lookup here or simulate a failing
- // lookup. But if it's really needed then remove the TODO.
scoped_refptr<net::RuleBasedHostMapper> host_mapper(
new net::RuleBasedHostMapper());
+ // TODO(sky): Don't make a real dns lookup here or simulate a failing
+ // lookup.
host_mapper->AllowDirectLookup("*.google.com");
- net::ScopedHostMapper scoped_host_mapper;
- scoped_host_mapper.Init(host_mapper.get());
+ // See http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol
+ // We don't want the test code to use it.
+ host_mapper->AddSimulatedFailure("wpad");
+ net::ScopedHostMapper scoped_host_mapper(host_mapper.get());
BrowserMain(params);
}
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index 1d7947f..527f6c4 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -23,6 +23,7 @@
#include "chrome/common/resource_bundle.h"
#include "chrome/test/testing_browser_process.h"
#include "net/base/host_resolver_unittest.h"
+#include "net/base/net_util.h"
// In many cases it may be not obvious that a test makes a real DNS lookup.
// We generally don't want to rely on external DNS servers for our tests,
@@ -32,11 +33,16 @@ class WarningHostMapper : public net::HostMapper {
virtual std::string Map(const std::string& host) {
const char* kLocalHostNames[] = {"localhost", "127.0.0.1"};
bool local = false;
- for (size_t i = 0; i < arraysize(kLocalHostNames); i++)
- if (host == kLocalHostNames[i]) {
- local = true;
- break;
- }
+
+ if (host == net::GetHostName()) {
+ local = true;
+ } else {
+ for (size_t i = 0; i < arraysize(kLocalHostNames); i++)
+ if (host == kLocalHostNames[i]) {
+ local = true;
+ break;
+ }
+ }
// Make the test fail so it's harder to ignore.
// If you really need to make real DNS query, use net::RuleBasedHostMapper