Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2285)

Unified Diff: chrome_frame/test/net/fake_external_tab.cc

Issue 9401013: Don't run chrome_frame_net_tests URLRequestTestHTTP over loopback, due to mysterious failures. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Log the chosen hostname. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_frame/test/net/fake_external_tab.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..288ceabff7f3b6b9419deb102a9a1b6ede773e25 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,32 @@ 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;
+ }
+
+ for (size_t i = 0; i < nic_list.size(); ++i) {
robertshield 2012/02/17 17:40:55 Consider adding a comment that we intentionally pi
+ 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 CustomUrlRequestTestHttpHost(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();
« no previous file with comments | « chrome_frame/test/net/fake_external_tab.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698