I recently checked in a change after which making external DNS lookup
(directly or indirectly) will make the test fail (so it's really hard to
ignore). By external I mean everything except 127.0.0.1 and localhost.

I added that check to chrome_test_suite.h, so unit_tests are affected, as
well as ui_tests, interactive_ui_tests etc. When a test executable launches
a chrome executable, only the test executable is covered by the check.

When you encounter a problem with that, you have three choices:

a) don't make that lookup (sometimes easy, sometimes not)
b) simulate a failed lookup
c) allow that lookup (it will be passed to the dns resolver, and the test
will pass)

For options b) and c), the general pattern is like this (real example):

#include "net/base/host_resolver_unittest.h"

// InProcessBrowserTest is not necessary; can be testing::Test just as well
class BrowserFocusTest : public InProcessBrowserTest {
 public:
  BrowserFocusTest() {
    host_mapper_ = new net::RuleBasedHostMapper();
    // TODO(phajdan.jr): Don't make a real dns lookup here.
    // page_with_focus.html has a reference to google.com.
    host_mapper_->AllowDirectLookup("*.google.com");  // To simulate a
failure use AddSimulatedFailure instead
    scoped_host_mapper_.Init(host_mapper_.get());
    ... snip ...
  }

private:
  scoped_refptr<net::RuleBasedHostMapper> host_mapper_;
  net::ScopedHostMapper scoped_host_mapper_;
};

--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to