| Index: chrome_frame/test/net/fake_external_tab.cc
|
| diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc
|
| index 785397b59dd24a2e956839855dd2249c8b0c21bf..f5ff55c35bc78641ea85625242d0ae90a3a867a8 100644
|
| --- a/chrome_frame/test/net/fake_external_tab.cc
|
| +++ b/chrome_frame/test/net/fake_external_tab.cc
|
| @@ -7,6 +7,7 @@
|
| #include <atlbase.h>
|
| #include <atlcom.h>
|
| #include <exdisp.h>
|
| +#include <Winsock2.h>
|
|
|
| #include "base/bind.h"
|
| #include "base/command_line.h"
|
| @@ -56,6 +57,7 @@
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/common/content_client.h"
|
| #include "content/public/common/content_paths.h"
|
| +#include "net/base/net_util.h"
|
| #include "sandbox/src/sandbox_types.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| @@ -523,7 +525,7 @@ void CFUrlRequestUnittestRunner::ShutDownHostBrowser() {
|
| }
|
| }
|
|
|
| -// Override virtual void Initialize to not call icu initialize
|
| +// Override virtual void Initialize to not call icu initialize.
|
| void CFUrlRequestUnittestRunner::Initialize() {
|
| DCHECK(::GetCurrentThreadId() == test_thread_id_);
|
|
|
| @@ -541,6 +543,10 @@ void CFUrlRequestUnittestRunner::Initialize() {
|
|
|
| // Next, do some initialization for NetTestSuite.
|
| NetTestSuite::InitializeTestThreadNoNetworkChangeNotifier();
|
| +
|
| + // Finally, override the host used by the HTTP tests. See
|
| + // http://crbug.com/114369 .
|
| + OverrideHttpHost();
|
| }
|
|
|
| void CFUrlRequestUnittestRunner::Shutdown() {
|
| @@ -615,6 +621,35 @@ void CFUrlRequestUnittestRunner::InitializeLogging() {
|
| logging::SetLogItems(true, true, true, true);
|
| }
|
|
|
| +void CFUrlRequestUnittestRunner::OverrideHttpHost() {
|
| + net::NetworkInterfaceList nic_list;
|
| + if (!net::GetNetworkList(&nic_list)) {
|
| + LOG(ERROR) << "GetNetworkList failed to look up non-loopback adapters. "
|
| + << "Tests will be run over the loopback adapter, which may "
|
| + << "result in hangs.";
|
| + return;
|
| + }
|
| +
|
| + // GetNetworkList only returns 'Up' non-loopback adapters. Select the first
|
| + // IPV4 address found - we should be able to bind/connect over it.
|
| + for (size_t i = 0; i < nic_list.size(); ++i) {
|
| + if (nic_list[i].address.size() != net::kIPv4AddressSize)
|
| + continue;
|
| + char* address_string =
|
| + inet_ntoa(*reinterpret_cast<in_addr*>(&nic_list[i].address[0]));
|
| + DCHECK(address_string != NULL);
|
| + if (address_string == NULL)
|
| + continue;
|
| + LOG(INFO) << "HTTP tests will run over " << address_string << ".";
|
| + override_http_host_.reset(
|
| + new ScopedCustomUrlRequestTestHttpHost(address_string));
|
| + return;
|
| + }
|
| +
|
| + LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be "
|
| + << "run over the loopback adapter, which may result in hangs.";
|
| +}
|
| +
|
| void CFUrlRequestUnittestRunner::PreEarlyInitialization() {
|
| testing::InitGoogleTest(&g_argc, g_argv);
|
| FilterDisabledTests();
|
|
|