Add net::HttpServer::Delegate::OnConnect() function and set ChromeDriver buffer sizes to 100 MB
BUG= Review URL: https://codereview.chromium.org/594393002 Cr-Commit-Position: refs/heads/master@{#296881}
This commit is contained in:
chrome/test/chromedriver
net
server
test
cloud_print/gcp20/prototype
content/browser/devtools
mojo/spy
net/server
@ -70,6 +70,8 @@ class FetchUrlTest : public testing::Test,
|
||||
}
|
||||
|
||||
// Overridden from net::HttpServer::Delegate:
|
||||
virtual void OnConnect(int connection_id) OVERRIDE {}
|
||||
|
||||
virtual void OnHttpRequest(int connection_id,
|
||||
const net::HttpServerRequestInfo& info) OVERRIDE {
|
||||
switch (response_) {
|
||||
|
@ -75,9 +75,7 @@ GURL TestHttpServer::web_socket_url() const {
|
||||
return web_socket_url_;
|
||||
}
|
||||
|
||||
void TestHttpServer::OnHttpRequest(
|
||||
int connection_id,
|
||||
const net::HttpServerRequestInfo& info) {
|
||||
void TestHttpServer::OnConnect(int connection_id) {
|
||||
server_->SetSendBufferSize(connection_id, kBufferSize);
|
||||
server_->SetReceiveBufferSize(connection_id, kBufferSize);
|
||||
}
|
||||
@ -85,9 +83,6 @@ void TestHttpServer::OnHttpRequest(
|
||||
void TestHttpServer::OnWebSocketRequest(
|
||||
int connection_id,
|
||||
const net::HttpServerRequestInfo& info) {
|
||||
server_->SetSendBufferSize(connection_id, kBufferSize);
|
||||
server_->SetReceiveBufferSize(connection_id, kBufferSize);
|
||||
|
||||
WebSocketRequestAction action;
|
||||
{
|
||||
base::AutoLock lock(action_lock_);
|
||||
@ -111,8 +106,6 @@ void TestHttpServer::OnWebSocketRequest(
|
||||
|
||||
void TestHttpServer::OnWebSocketMessage(int connection_id,
|
||||
const std::string& data) {
|
||||
server_->SetSendBufferSize(connection_id, kBufferSize);
|
||||
server_->SetReceiveBufferSize(connection_id, kBufferSize);
|
||||
WebSocketMessageAction action;
|
||||
{
|
||||
base::AutoLock lock(action_lock_);
|
||||
|
@ -61,8 +61,9 @@ class TestHttpServer : public net::HttpServer::Delegate {
|
||||
GURL web_socket_url() const;
|
||||
|
||||
// Overridden from net::HttpServer::Delegate:
|
||||
virtual void OnConnect(int connection_id) OVERRIDE;
|
||||
virtual void OnHttpRequest(int connection_id,
|
||||
const net::HttpServerRequestInfo& info) OVERRIDE;
|
||||
const net::HttpServerRequestInfo& info) OVERRIDE {}
|
||||
virtual void OnWebSocketRequest(
|
||||
int connection_id,
|
||||
const net::HttpServerRequestInfo& info) OVERRIDE;
|
||||
|
@ -38,6 +38,7 @@
|
||||
namespace {
|
||||
|
||||
const char* kLocalHostAddress = "127.0.0.1";
|
||||
const int kBufferSize = 100 * 1024 * 1024; // 100 MB
|
||||
|
||||
typedef base::Callback<
|
||||
void(const net::HttpServerRequestInfo&, const HttpResponseSenderFunc&)>
|
||||
@ -64,6 +65,10 @@ class HttpServer : public net::HttpServer::Delegate {
|
||||
}
|
||||
|
||||
// Overridden from net::HttpServer::Delegate:
|
||||
virtual void OnConnect(int connection_id) OVERRIDE {
|
||||
server_->SetSendBufferSize(connection_id, kBufferSize);
|
||||
server_->SetReceiveBufferSize(connection_id, kBufferSize);
|
||||
}
|
||||
virtual void OnHttpRequest(int connection_id,
|
||||
const net::HttpServerRequestInfo& info) OVERRIDE {
|
||||
handle_request_func_.Run(
|
||||
|
@ -715,6 +715,16 @@ class ChromeDriverTest(ChromeDriverBaseTest):
|
||||
def testMobileEmulationDisabledByDefault(self):
|
||||
self.assertFalse(self._driver.capabilities['mobileEmulationEnabled'])
|
||||
|
||||
def testChromeDriverSendLargeData(self):
|
||||
script = 's = ""; for (i = 0; i < 10e6; i++) s += "0"; return s;'
|
||||
lots_of_data = self._driver.ExecuteScript(script)
|
||||
self.assertEquals('0'.zfill(int(10e6)), lots_of_data)
|
||||
|
||||
def testChromeDriverRecieveAndSendLargeData(self):
|
||||
lots_of_data = '1'.zfill(int(10e6))
|
||||
result = self._driver.ExecuteScript('return "%s"' % lots_of_data)
|
||||
self.assertEquals(lots_of_data, result)
|
||||
|
||||
|
||||
class ChromeDriverAndroidTest(ChromeDriverBaseTest):
|
||||
"""End to end tests for Android-specific tests."""
|
||||
|
@ -141,6 +141,7 @@ class PrivetHttpServer: public net::HttpServer::Delegate {
|
||||
|
||||
private:
|
||||
// net::HttpServer::Delegate methods:
|
||||
virtual void OnConnect(int connection_id) OVERRIDE {}
|
||||
virtual void OnHttpRequest(
|
||||
int connection_id,
|
||||
const net::HttpServerRequestInfo& info) OVERRIDE;
|
||||
|
@ -56,6 +56,7 @@ class DevToolsHttpHandlerImpl
|
||||
virtual GURL GetFrontendURL() OVERRIDE;
|
||||
|
||||
// net::HttpServer::Delegate implementation.
|
||||
virtual void OnConnect(int connection_id) OVERRIDE {}
|
||||
virtual void OnHttpRequest(int connection_id,
|
||||
const net::HttpServerRequestInfo& info) OVERRIDE;
|
||||
virtual void OnWebSocketRequest(
|
||||
|
@ -38,6 +38,7 @@ class WebSocketServer : public net::HttpServer::Delegate,
|
||||
|
||||
protected:
|
||||
// Overridden from net::HttpServer::Delegate.
|
||||
virtual void OnConnect(int connection_id) OVERRIDE {}
|
||||
virtual void OnHttpRequest(
|
||||
int connection_id,
|
||||
const net::HttpServerRequestInfo& info) OVERRIDE;
|
||||
|
@ -153,7 +153,9 @@ int HttpServer::HandleAcceptResult(int rv) {
|
||||
HttpConnection* connection =
|
||||
new HttpConnection(++last_id_, accepted_socket_.Pass());
|
||||
id_to_connection_[connection->id()] = connection;
|
||||
DoReadLoop(connection);
|
||||
delegate_->OnConnect(connection->id());
|
||||
if (!HasClosedConnection(connection))
|
||||
DoReadLoop(connection);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ class HttpServer {
|
||||
// destroy the HttpServer in any of these callbacks.
|
||||
class Delegate {
|
||||
public:
|
||||
virtual void OnConnect(int connection_id) = 0;
|
||||
virtual void OnHttpRequest(int connection_id,
|
||||
const HttpServerRequestInfo& info) = 0;
|
||||
virtual void OnWebSocketRequest(int connection_id,
|
||||
|
@ -189,6 +189,8 @@ class HttpServerTest : public testing::Test,
|
||||
ASSERT_EQ(OK, server_->GetLocalAddress(&server_address_));
|
||||
}
|
||||
|
||||
virtual void OnConnect(int connection_id) OVERRIDE {}
|
||||
|
||||
virtual void OnHttpRequest(int connection_id,
|
||||
const HttpServerRequestInfo& info) OVERRIDE {
|
||||
requests_.push_back(std::make_pair(info, connection_id));
|
||||
@ -243,6 +245,8 @@ class HttpServerTest : public testing::Test,
|
||||
size_t quit_after_request_count_;
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
class WebSocketTest : public HttpServerTest {
|
||||
virtual void OnHttpRequest(int connection_id,
|
||||
const HttpServerRequestInfo& info) OVERRIDE {
|
||||
@ -461,8 +465,6 @@ TEST_F(HttpServerTest, SendRaw) {
|
||||
ASSERT_EQ(expected_response, response);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class MockStreamSocket : public StreamSocket {
|
||||
public:
|
||||
MockStreamSocket()
|
||||
@ -557,8 +559,6 @@ class MockStreamSocket : public StreamSocket {
|
||||
DISALLOW_COPY_AND_ASSIGN(MockStreamSocket);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_F(HttpServerTest, RequestWithBodySplitAcrossPackets) {
|
||||
MockStreamSocket* socket = new MockStreamSocket();
|
||||
HandleAcceptResult(make_scoped_ptr<StreamSocket>(socket));
|
||||
@ -619,4 +619,26 @@ TEST_F(HttpServerTest, MultipleRequestsOnSameConnection) {
|
||||
ASSERT_TRUE(EndsWith(response3, "Content for /test3", true));
|
||||
}
|
||||
|
||||
class CloseOnConnectHttpServerTest : public HttpServerTest {
|
||||
public:
|
||||
virtual void OnConnect(int connection_id) OVERRIDE {
|
||||
connection_ids_.push_back(connection_id);
|
||||
server_->Close(connection_id);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<int> connection_ids_;
|
||||
};
|
||||
|
||||
TEST_F(CloseOnConnectHttpServerTest, ServerImmediatelyClosesConnection) {
|
||||
TestHttpClient client;
|
||||
ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
|
||||
client.Send("GET / HTTP/1.1\r\n\r\n");
|
||||
ASSERT_FALSE(RunUntilRequestsReceived(1));
|
||||
ASSERT_EQ(1ul, connection_ids_.size());
|
||||
ASSERT_EQ(0ul, requests_.size());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace net
|
||||
|
Reference in New Issue
Block a user