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

Unified Diff: services/http_server/http_server_apptest.cc

Issue 953513002: http_server: accept full NetAddress in CreateHttpServer. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
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();

Powered by Google App Engine
This is Rietveld 408576698