summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-25 00:39:39 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-25 00:39:39 +0000
commit7fc63941088e21d780990e5bb43fc3d8ff0db7b7 (patch)
tree3132a4fef59baa50f8c40488c103b323f93adbab /chrome_frame
parent04499fbfa24e52ef1848ed52365db4df91a8f224 (diff)
downloadchromium_src-7fc63941088e21d780990e5bb43fc3d8ff0db7b7.zip
chromium_src-7fc63941088e21d780990e5bb43fc3d8ff0db7b7.tar.gz
chromium_src-7fc63941088e21d780990e5bb43fc3d8ff0db7b7.tar.bz2
Attempt to fix flake in FullTabModeIE_TestPostReissue by avoiding loopback address.
This change makes all remaining tests in the suite use an address on a NIC rather than the loopback address. I don't know whether it'll resolve the flake or not. BUG=143699 TEST=none Review URL: https://chromiumcodereview.appspot.com/10868027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/test/mock_ie_event_sink_test.cc5
-rw-r--r--chrome_frame/test/net/fake_external_tab.cc5
-rw-r--r--chrome_frame/test/test_server.cc21
-rw-r--r--chrome_frame/test/test_server.h18
-rw-r--r--chrome_frame/test/test_server_test.cc29
-rw-r--r--chrome_frame/test/test_with_web_server.cc13
-rw-r--r--chrome_frame/test/test_with_web_server.h7
-rw-r--r--chrome_frame/test/url_request_test.cc17
8 files changed, 82 insertions, 33 deletions
diff --git a/chrome_frame/test/mock_ie_event_sink_test.cc b/chrome_frame/test/mock_ie_event_sink_test.cc
index 49d6840..60aa195 100644
--- a/chrome_frame/test/mock_ie_event_sink_test.cc
+++ b/chrome_frame/test/mock_ie_event_sink_test.cc
@@ -178,8 +178,9 @@ void MockIEEventSink::ExpectDocumentReadystate(int ready_state) {
}
// MockIEEventSinkTest methods
-MockIEEventSinkTest::MockIEEventSinkTest() : server_mock_(1337, L"127.0.0.1",
- GetTestDataFolder()) {
+MockIEEventSinkTest::MockIEEventSinkTest()
+ : server_mock_(1337, ASCIIToWide(chrome_frame_test::GetLocalIPv4Address()),
+ GetTestDataFolder()) {
loop_.set_snapshot_on_timeout(true);
EXPECT_CALL(server_mock_, Get(_, StrCaseEq(L"/favicon.ico"), _))
.WillRepeatedly(SendFast("HTTP/1.1 404 Not Found", ""));
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc
index d333c13..11aa8b8 100644
--- a/chrome_frame/test/net/fake_external_tab.cc
+++ b/chrome_frame/test/net/fake_external_tab.cc
@@ -528,10 +528,11 @@ void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() {
ie_configurator_->ApplySettings();
}
- test_http_server_.reset(new test_server::SimpleWebServer(kTestServerPort));
+ test_http_server_.reset(new test_server::SimpleWebServer("127.0.0.1",
+ kTestServerPort));
test_http_server_->AddResponse(&chrome_frame_html_);
std::wstring url(base::StringPrintf(L"http://localhost:%i/chrome_frame",
- kTestServerPort).c_str());
+ kTestServerPort));
// Launch IE. This launches IE correctly on Vista too.
base::win::ScopedHandle ie_process(chrome_frame_test::LaunchIE(url));
diff --git a/chrome_frame/test/test_server.cc b/chrome_frame/test/test_server.cc
index 5eaf06f..83946c6 100644
--- a/chrome_frame/test/test_server.cc
+++ b/chrome_frame/test/test_server.cc
@@ -13,6 +13,7 @@
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
+#include "chrome_frame/test/chrome_frame_test_utils.h"
#include "chrome_frame/test/test_server.h"
#include "net/base/tcp_listen_socket.h"
#include "net/base/winsock_init.h"
@@ -136,11 +137,11 @@ bool RedirectResponse::GetCustomHeaders(std::string* headers) const {
}
SimpleWebServer::SimpleWebServer(int port) {
- CHECK(MessageLoop::current()) << "SimpleWebServer requires a message loop";
- net::EnsureWinsockInit();
- AddResponse(&quit_);
- server_ = net::TCPListenSocket::CreateAndListen("127.0.0.1", port, this);
- DCHECK(server_.get() != NULL);
+ Construct(chrome_frame_test::GetLocalIPv4Address(), port);
+}
+
+SimpleWebServer::SimpleWebServer(const std::string& address, int port) {
+ Construct(address, port);
}
SimpleWebServer::~SimpleWebServer() {
@@ -150,6 +151,16 @@ SimpleWebServer::~SimpleWebServer() {
connections_.clear();
}
+void SimpleWebServer::Construct(const std::string& address, int port) {
+ CHECK(MessageLoop::current()) << "SimpleWebServer requires a message loop";
+ net::EnsureWinsockInit();
+ AddResponse(&quit_);
+ host_ = address;
+ server_ = net::TCPListenSocket::CreateAndListen(address, port, this);
+ LOG_IF(DFATAL, !server_.get())
+ << "Failed to create listener socket at " << address << ":" << port;
+}
+
void SimpleWebServer::AddResponse(Response* response) {
responses_.push_back(response);
}
diff --git a/chrome_frame/test/test_server.h b/chrome_frame/test/test_server.h
index 01ce4bb..04da126 100644
--- a/chrome_frame/test/test_server.h
+++ b/chrome_frame/test/test_server.h
@@ -15,7 +15,7 @@
// all derived from the Response interface.
//
// Here's a simple example that starts a web server that can serve up
-// a single document (http://localhost:1337/foo).
+// a single document (http://<server.host()>:1337/foo).
// All other requests will get a 404.
//
// MessageLoopForUI loop;
@@ -24,7 +24,7 @@
// test_server.AddResponse(&document);
// loop.MessageLoop::Run();
//
-// To close the web server, just go to http://localhost:1337/quit.
+// To close the web server, just go to http://<server.host()>:1337/quit.
//
// All Response classes count how many times they have been accessed. Just
// call Response::accessed().
@@ -282,7 +282,12 @@ typedef std::list<Connection*> ConnectionList;
// has a message loop.
class SimpleWebServer : public net::StreamListenSocket::Delegate {
public:
+ // Constructs a server listening at the given port on a local IPv4 address.
+ // An address on a NIC is preferred over the loopback address.
explicit SimpleWebServer(int port);
+
+ // Constructs a server listening at the given address:port.
+ SimpleWebServer(const std::string& address, int port);
virtual ~SimpleWebServer();
void AddResponse(Response* response);
@@ -303,6 +308,12 @@ class SimpleWebServer : public net::StreamListenSocket::Delegate {
int len);
virtual void DidClose(net::StreamListenSocket* sock);
+ // Returns the host on which the server is listening. This is suitable for
+ // use in URLs for resources served by this instance.
+ const std::string& host() const {
+ return host_;
+ }
+
const ConnectionList& connections() const {
return connections_;
}
@@ -323,13 +334,14 @@ class SimpleWebServer : public net::StreamListenSocket::Delegate {
Response* FindResponse(const Request& request) const;
Connection* FindConnection(const net::StreamListenSocket* socket) const;
- protected:
+ std::string host_;
scoped_refptr<net::StreamListenSocket> server_;
ConnectionList connections_;
std::list<Response*> responses_;
QuitResponse quit_;
private:
+ void Construct(const std::string& address, int port);
DISALLOW_COPY_AND_ASSIGN(SimpleWebServer);
};
diff --git a/chrome_frame/test/test_server_test.cc b/chrome_frame/test/test_server_test.cc
index f520eba..f3d7899 100644
--- a/chrome_frame/test/test_server_test.cc
+++ b/chrome_frame/test/test_server_test.cc
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/path_service.h"
+#include "base/stringprintf.h"
#include "base/win/scoped_handle.h"
#include "chrome_frame/test/test_server.h"
#include "net/base/host_resolver_proc.h"
@@ -71,7 +72,7 @@ class TestURLRequest : public net::URLRequest {
class UrlTaskChain {
public:
- UrlTaskChain(const char* url, UrlTaskChain* next)
+ UrlTaskChain(const std::string& url, UrlTaskChain* next)
: url_(url), next_(next) {
}
@@ -137,15 +138,18 @@ TEST_F(TestServerTest, TestServer) {
MessageLoopForUI loop;
test_server::SimpleWebServer server(1337);
+ test_server::SimpleWebServer redirected_server(server.host(), 1338);
test_server::SimpleResponse person("/person", "Guthrie Govan!");
server.AddResponse(&person);
test_server::FileResponse file("/file", source_path().Append(
FILE_PATH_LITERAL("CFInstance.js")));
server.AddResponse(&file);
- test_server::RedirectResponse redir("/redir", "http://localhost:1338/dest");
+ test_server::RedirectResponse redir(
+ "/redir",
+ base::StringPrintf("http://%s:1338/dest",
+ redirected_server.host().c_str()));
server.AddResponse(&redir);
- test_server::SimpleWebServer redirected_server(1338);
test_server::SimpleResponse dest("/dest", "Destination");
redirected_server.AddResponse(&dest);
@@ -155,11 +159,20 @@ TEST_F(TestServerTest, TestServer) {
loop.PostDelayedTask(FROM_HERE, base::Bind(QuitMessageLoop, &quit_msg),
base::TimeDelta::FromSeconds(10));
- UrlTaskChain quit_task("http://localhost:1337/quit", NULL);
- UrlTaskChain fnf_task("http://localhost:1337/404", &quit_task);
- UrlTaskChain person_task("http://localhost:1337/person", &fnf_task);
- UrlTaskChain file_task("http://localhost:1337/file", &person_task);
- UrlTaskChain redir_task("http://localhost:1337/redir", &file_task);
+ UrlTaskChain quit_task(
+ base::StringPrintf("http://%s:1337/quit", server.host().c_str()), NULL);
+ UrlTaskChain fnf_task(
+ base::StringPrintf("http://%s:1337/404", server.host().c_str()),
+ &quit_task);
+ UrlTaskChain person_task(
+ base::StringPrintf("http://%s:1337/person", server.host().c_str()),
+ &fnf_task);
+ UrlTaskChain file_task(
+ base::StringPrintf("http://%s:1337/file", server.host().c_str()),
+ &person_task);
+ UrlTaskChain redir_task(
+ base::StringPrintf("http://%s:1337/redir", server.host().c_str()),
+ &file_task);
DWORD tid = 0;
base::win::ScopedHandle worker(::CreateThread(
diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc
index a6118e6..baf4c6b 100644
--- a/chrome_frame/test/test_with_web_server.cc
+++ b/chrome_frame/test/test_with_web_server.cc
@@ -78,6 +78,7 @@ FilePath ChromeFrameTestWithWebServer::CFInstance_path_;
ScopedTempDir ChromeFrameTestWithWebServer::temp_dir_;
FilePath ChromeFrameTestWithWebServer::chrome_user_data_dir_;
chrome_frame_test::TimedMsgLoop* ChromeFrameTestWithWebServer::loop_;
+std::string ChromeFrameTestWithWebServer::local_address_;
testing::StrictMock<MockWebServerListener>*
ChromeFrameTestWithWebServer::listener_mock_;
testing::StrictMock<MockWebServer>* ChromeFrameTestWithWebServer::server_mock_;
@@ -115,9 +116,10 @@ void ChromeFrameTestWithWebServer::SetUpTestCase() {
loop_ = new chrome_frame_test::TimedMsgLoop();
loop_->set_snapshot_on_timeout(true);
+ local_address_ = chrome_frame_test::GetLocalIPv4Address();
listener_mock_ = new testing::StrictMock<MockWebServerListener>();
server_mock_ = new testing::StrictMock<MockWebServer>(
- 1337, ASCIIToWide(chrome_frame_test::GetLocalIPv4Address()),
+ 1337, ASCIIToWide(local_address_),
chrome_frame_test::GetTestDataFolder());
server_mock_->set_listener(listener_mock_);
}
@@ -128,6 +130,7 @@ void ChromeFrameTestWithWebServer::TearDownTestCase() {
server_mock_ = NULL;
delete listener_mock_;
listener_mock_ = NULL;
+ local_address_.clear();
delete loop_;
loop_ = NULL;
file_util::Delete(CFInstall_path_, false);
@@ -759,7 +762,7 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_TestPostReissue) {
L"chrome_frame_tester_helpers.js",
};
- SimpleWebServerTest server(46664);
+ SimpleWebServerTest server(local_address_, 46664);
server.PopulateStaticFileListT<test_server::FileResponse>(kPages,
arraysize(kPages), GetCFTestFilePath());
@@ -790,7 +793,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestMultipleGet) {
L"chrome_frame_tester_helpers.js",
};
- SimpleWebServerTest server(46664);
+ SimpleWebServerTest server(local_address_, 46664);
server.PopulateStaticFileListT<test_server::FileResponse>(kPages,
arraysize(kPages), GetCFTestFilePath());
@@ -908,7 +911,7 @@ TEST_F(ChromeFrameTestWithWebServer, FAILS_FullTabModeIE_RefreshMshtmlTest) {
L"mshtml_refresh_test_popup.html",
};
- SimpleWebServerTest server(46664);
+ SimpleWebServerTest server(local_address_, 46664);
server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages,
arraysize(kPages), GetCFTestFilePath());
@@ -1048,7 +1051,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestDownloadFromForm) {
.Times(testing::AtMost(1))
.WillOnce(QUIT_LOOP(loop()));
- SimpleWebServerTest server(46664);
+ SimpleWebServerTest server(local_address_, 46664);
CustomResponse* response = new CustomResponse("/form.html");
server.web_server()->AddResponse(response);
diff --git a/chrome_frame/test/test_with_web_server.h b/chrome_frame/test/test_with_web_server.h
index 4c74220..821afe9 100644
--- a/chrome_frame/test/test_with_web_server.h
+++ b/chrome_frame/test/test_with_web_server.h
@@ -242,6 +242,7 @@ class ChromeFrameTestWithWebServer : public testing::Test {
// The web server from which we serve the web!
static chrome_frame_test::TimedMsgLoop* loop_;
+ static std::string local_address_;
static testing::StrictMock<MockWebServerListener>* listener_mock_;
static testing::StrictMock<MockWebServer>* server_mock_;
@@ -253,7 +254,8 @@ class ChromeFrameTestWithWebServer : public testing::Test {
// SimpleWebServer class.
class SimpleWebServerTest {
public:
- explicit SimpleWebServerTest(int port) : server_(port), port_(port) {
+ SimpleWebServerTest(const std::string& address, int port)
+ : server_(address, port), port_(port) {
}
~SimpleWebServerTest() {
@@ -271,7 +273,8 @@ class SimpleWebServerTest {
}
std::wstring FormatHttpPath(const wchar_t* document_path) {
- return base::StringPrintf(L"http://localhost:%i/%ls", port_,
+ return base::StringPrintf(L"http://%ls:%i/%ls",
+ ASCIIToWide(server_.host()).c_str(), port_,
document_path);
}
diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc
index 6952595..b1fb6b2 100644
--- a/chrome_frame/test/url_request_test.cc
+++ b/chrome_frame/test/url_request_test.cc
@@ -67,7 +67,8 @@ TEST(UrlmonUrlRequestTest, Simple1) {
MockUrlDelegate mock;
chrome_frame_test::TimedMsgLoop loop;
- testing::StrictMock<MockWebServer> mock_server(1337, L"127.0.0.1",
+ testing::StrictMock<MockWebServer> mock_server(1337,
+ ASCIIToWide(chrome_frame_test::GetLocalIPv4Address()),
chrome_frame_test::GetTestDataFolder());
mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
@@ -125,7 +126,7 @@ TEST(UrlmonUrlRequestTest, Head) {
request.AddRef();
request.Initialize(&mock, 1, // request_id
- "http://localhost:13337/head",
+ base::StringPrintf("http://%s:13337/head", server.host().c_str()),
"head",
"", // referrer
"", // extra request
@@ -160,7 +161,8 @@ TEST(UrlmonUrlRequestTest, UnreachableUrl) {
base::win::ScopedCOMInitializer init_com;
CComObjectStackEx<UrlmonUrlRequest> request;
- testing::StrictMock<MockWebServer> mock_server(1337, L"127.0.0.1",
+ testing::StrictMock<MockWebServer> mock_server(1337,
+ ASCIIToWide(chrome_frame_test::GetLocalIPv4Address()),
chrome_frame_test::GetTestDataFolder());
mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
@@ -199,7 +201,8 @@ TEST(UrlmonUrlRequestTest, ZeroLengthResponse) {
MockUrlDelegate mock;
chrome_frame_test::TimedMsgLoop loop;
- testing::StrictMock<MockWebServer> mock_server(1337, L"127.0.0.1",
+ testing::StrictMock<MockWebServer> mock_server(1337,
+ ASCIIToWide(chrome_frame_test::GetLocalIPv4Address()),
chrome_frame_test::GetTestDataFolder());
mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
@@ -255,7 +258,8 @@ TEST(UrlmonUrlRequestManagerTest, Simple1) {
MockUrlDelegate mock;
chrome_frame_test::TimedMsgLoop loop;
- testing::StrictMock<MockWebServer> mock_server(1337, L"127.0.0.1",
+ testing::StrictMock<MockWebServer> mock_server(1337,
+ ASCIIToWide(chrome_frame_test::GetLocalIPv4Address()),
chrome_frame_test::GetTestDataFolder());
mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
@@ -290,7 +294,8 @@ TEST(UrlmonUrlRequestManagerTest, Abort1) {
MockUrlDelegate mock;
chrome_frame_test::TimedMsgLoop loop;
- testing::StrictMock<MockWebServer> mock_server(1337, L"127.0.0.1",
+ testing::StrictMock<MockWebServer> mock_server(1337,
+ ASCIIToWide(chrome_frame_test::GetLocalIPv4Address()),
chrome_frame_test::GetTestDataFolder());
mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));