| Index: services/http_server/http_server_apptest.cc
|
| diff --git a/services/http_server/http_server_apptest.cc b/services/http_server/http_server_apptest.cc
|
| index ba7ade5b1f3d8291f96dbfcbb627be6fbb38c93f..ca049553694a8172716f2e137c4eb6267d95c69b 100644
|
| --- a/services/http_server/http_server_apptest.cc
|
| +++ b/services/http_server/http_server_apptest.cc
|
| @@ -9,6 +9,7 @@
|
| #include "mojo/public/cpp/application/application_impl.h"
|
| #include "mojo/public/cpp/application/application_test_base.h"
|
| #include "mojo/public/cpp/system/macros.h"
|
| +#include "mojo/services/network/public/interfaces/net_address.mojom.h"
|
| #include "mojo/services/network/public/interfaces/network_service.mojom.h"
|
| #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
|
| #include "services/http_server/public/http_server.mojom.h"
|
| @@ -110,6 +111,8 @@ class HttpServerApplicationTest : public mojo::test::ApplicationTestBase {
|
| &network_service_);
|
| }
|
|
|
| + http_server::HttpServerPtr CreateHttpServer();
|
| +
|
| http_server::HttpServerFactoryPtr http_server_factory_;
|
| mojo::NetworkServicePtr network_service_;
|
|
|
| @@ -117,6 +120,22 @@ class HttpServerApplicationTest : public mojo::test::ApplicationTestBase {
|
| MOJO_DISALLOW_COPY_AND_ASSIGN(HttpServerApplicationTest);
|
| };
|
|
|
| +http_server::HttpServerPtr HttpServerApplicationTest::CreateHttpServer() {
|
| + http_server::HttpServerPtr http_server;
|
| + mojo::NetAddressPtr local_address(mojo::NetAddress::New());
|
| + local_address->family = mojo::NET_ADDRESS_FAMILY_IPV4;
|
| + local_address->ipv4 = mojo::NetAddressIPv4::New();
|
| + local_address->ipv4->addr.resize(4);
|
| + local_address->ipv4->addr[0] = 0;
|
| + local_address->ipv4->addr[1] = 0;
|
| + local_address->ipv4->addr[2] = 0;
|
| + local_address->ipv4->addr[3] = 0;
|
| + local_address->ipv4->port = 0;
|
| + http_server_factory_->CreateHttpServer(GetProxy(&http_server).Pass(),
|
| + local_address.Pass());
|
| + return http_server.Pass();
|
| +}
|
| +
|
| void CheckServerResponse(mojo::URLResponsePtr response) {
|
| EXPECT_EQ(200u, response->status_code);
|
| std::string response_body;
|
| @@ -128,9 +147,7 @@ void CheckServerResponse(mojo::URLResponsePtr response) {
|
| // Verifies that the server responds to http GET requests using example
|
| // GetHandler.
|
| TEST_F(HttpServerApplicationTest, ServerResponse) {
|
| - http_server::HttpServerPtr http_server;
|
| - http_server_factory_->CreateHttpServer(GetProxy(&http_server).Pass(), 0u);
|
| -
|
| + http_server::HttpServerPtr http_server(CreateHttpServer());
|
| uint16_t assigned_port;
|
| http_server->GetPort([&assigned_port](uint16_t p) { assigned_port = p; });
|
| http_server.WaitForIncomingMethodCall();
|
| @@ -157,9 +174,7 @@ TEST_F(HttpServerApplicationTest, ServerResponse) {
|
| // Verifies that the server correctly passes the POST request payload using
|
| // example PostHandler.
|
| TEST_F(HttpServerApplicationTest, PostData) {
|
| - http_server::HttpServerPtr http_server;
|
| - http_server_factory_->CreateHttpServer(GetProxy(&http_server).Pass(), 0u);
|
| -
|
| + http_server::HttpServerPtr http_server = CreateHttpServer();
|
| uint16_t assigned_port;
|
| http_server->GetPort([&assigned_port](uint16_t p) { assigned_port = p; });
|
| http_server.WaitForIncomingMethodCall();
|
|
|