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

Unified Diff: chrome_frame/test/chrome_frame_test_utils.cc

Issue 10007043: Attempt to fix ChromeFrameTestWithWebServer tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move snapshot fn into ui_test_utils_win.cc Created 8 years, 8 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/chrome_frame_test_utils.h ('k') | chrome_frame/test/mock_ie_event_sink_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/test/chrome_frame_test_utils.cc
diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc
index fa504b84f1536ecd77a5b1d23cfbf408da3b5d39..1348b1af6d34ed23970f971d47051d1559fd8c4d 100644
--- a/chrome_frame/test/chrome_frame_test_utils.cc
+++ b/chrome_frame/test/chrome_frame_test_utils.cc
@@ -9,6 +9,7 @@
#include <iepmapi.h>
#include <sddl.h>
#include <shlobj.h>
+#include <winsock2.h>
#include "base/command_line.h"
#include "base/file_path.h"
@@ -28,6 +29,7 @@
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
#include "chrome_frame/utils.h"
+#include "net/base/net_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
@@ -677,4 +679,38 @@ void ClearIESessionHistory() {
file_util::Delete(session_history_path, true);
}
+std::string GetLocalIPv4Address() {
+ std::string address;
+ 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.";
+ } else {
+ // 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) {
+ LOG(INFO) << "HTTP tests will run over " << address_string << ".";
+ address.assign(address_string);
+ break;
+ }
+ }
+ }
+
+ if (address.empty()) {
+ LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be "
+ << "run over the loopback adapter, which may result in hangs.";
+ address.assign("127.0.0.1");
+ }
+
+ return address;
+}
+
} // namespace chrome_frame_test
« no previous file with comments | « chrome_frame/test/chrome_frame_test_utils.h ('k') | chrome_frame/test/mock_ie_event_sink_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698