diff options
author | groby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-22 23:49:48 +0000 |
---|---|---|
committer | groby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-22 23:49:48 +0000 |
commit | 47a1f70b7eb09d7fc11f00beab94532544044ed1 (patch) | |
tree | 544b72447fc92faf056b3840d4beaba2ac15bd3c /chrome_frame | |
parent | 0818155fae74cd6828d66d0101153c6bb4b3ceab (diff) | |
download | chromium_src-47a1f70b7eb09d7fc11f00beab94532544044ed1.zip chromium_src-47a1f70b7eb09d7fc11f00beab94532544044ed1.tar.gz chromium_src-47a1f70b7eb09d7fc11f00beab94532544044ed1.tar.bz2 |
Revert 123135 - Revert 123118 - Don't run chrome_frame_net_tests URLRequestTestHTTP over loopback, due to mysterious failures.
Revert the revert - too fast on the trigger
Depends on:
http://codereview.chromium.org/9419053/ (make GetNetworkList filter-out 'down' adapters)
http://codereview.chromium.org/9368031/ (make HTTP tests parameterizable)
http://codereview.chromium.org/9369029/ (make TestServer parameterizable)
BUG=114369
TEST=chrome_frame_net_tests pass on the try bots.
Review URL: http://codereview.chromium.org/9401013
TBR=erikwright@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9444001
TBR=groby@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9438002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.cc | 37 | ||||
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.h | 8 |
2 files changed, 44 insertions, 1 deletions
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc index 2283527..b42a78f 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" @@ -520,7 +522,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_); @@ -536,6 +538,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() { @@ -610,6 +616,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(); diff --git a/chrome_frame/test/net/fake_external_tab.h b/chrome_frame/test/net/fake_external_tab.h index d7e726c7..aa807b4 100644 --- a/chrome_frame/test/net/fake_external_tab.h +++ b/chrome_frame/test/net/fake_external_tab.h @@ -21,6 +21,7 @@ #include "content/public/browser/browser_main_parts.h" #include "content/public/browser/browser_thread.h" #include "net/base/net_test_suite.h" +#include "net/url_request/url_request_test_util.h" class FakeBrowserProcessImpl; class ProcessSingleton; @@ -124,6 +125,8 @@ class CFUrlRequestUnittestRunner base::ProcessHandle crash_service_; DWORD test_thread_id_; + scoped_ptr<ScopedCustomUrlRequestTestHttpHost> override_http_host_; + scoped_ptr<test_server::SimpleWebServer> test_http_server_; test_server::SimpleResponse chrome_frame_html_; @@ -133,6 +136,11 @@ class CFUrlRequestUnittestRunner ScopedChromeFrameRegistrar registrar_; int test_result_; + private: + // Causes HTTP tests to run over an external address rather than 127.0.0.1. + // See http://crbug.com/114369 . + void OverrideHttpHost(); + DISALLOW_COPY_AND_ASSIGN(CFUrlRequestUnittestRunner); }; |