OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "mojo/data_pipe_utils/data_pipe_utils.h" | 8 #include "mojo/data_pipe_utils/data_pipe_utils.h" |
9 #include "mojo/public/cpp/application/application_impl.h" | |
10 #include "mojo/public/cpp/application/application_test_base.h" | 9 #include "mojo/public/cpp/application/application_test_base.h" |
11 #include "mojo/public/cpp/application/connect.h" | 10 #include "mojo/public/cpp/application/connect.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" |
12 #include "mojo/public/cpp/bindings/synchronous_interface_ptr.h" | 12 #include "mojo/public/cpp/bindings/synchronous_interface_ptr.h" |
13 #include "mojo/public/cpp/system/macros.h" | 13 #include "mojo/public/cpp/system/macros.h" |
14 #include "mojo/services/http_server/cpp/http_server_util.h" | 14 #include "mojo/services/http_server/cpp/http_server_util.h" |
15 #include "mojo/services/http_server/interfaces/http_server.mojom-sync.h" | 15 #include "mojo/services/http_server/interfaces/http_server.mojom-sync.h" |
16 #include "mojo/services/http_server/interfaces/http_server_factory.mojom.h" | 16 #include "mojo/services/http_server/interfaces/http_server_factory.mojom.h" |
17 #include "mojo/services/network/interfaces/net_address.mojom.h" | 17 #include "mojo/services/network/interfaces/net_address.mojom.h" |
18 #include "mojo/services/network/interfaces/network_service.mojom.h" | 18 #include "mojo/services/network/interfaces/network_service.mojom.h" |
19 #include "mojo/services/network/interfaces/url_loader.mojom.h" | 19 #include "mojo/services/network/interfaces/url_loader.mojom.h" |
20 | 20 |
21 namespace http_server { | 21 namespace http_server { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 class HttpServerApplicationTest : public mojo::test::ApplicationTestBase { | 94 class HttpServerApplicationTest : public mojo::test::ApplicationTestBase { |
95 public: | 95 public: |
96 HttpServerApplicationTest() : ApplicationTestBase() {} | 96 HttpServerApplicationTest() : ApplicationTestBase() {} |
97 ~HttpServerApplicationTest() override {} | 97 ~HttpServerApplicationTest() override {} |
98 | 98 |
99 protected: | 99 protected: |
100 // ApplicationTestBase: | 100 // ApplicationTestBase: |
101 void SetUp() override { | 101 void SetUp() override { |
102 ApplicationTestBase::SetUp(); | 102 ApplicationTestBase::SetUp(); |
103 | 103 |
104 mojo::ConnectToService(application_impl()->shell(), "mojo:http_server", | 104 mojo::ConnectToService(shell(), "mojo:http_server", |
105 GetProxy(&http_server_factory_)); | 105 GetProxy(&http_server_factory_)); |
106 mojo::ConnectToService(application_impl()->shell(), "mojo:network_service", | 106 mojo::ConnectToService(shell(), "mojo:network_service", |
107 GetProxy(&network_service_)); | 107 GetProxy(&network_service_)); |
108 } | 108 } |
109 | 109 |
110 mojo::SynchronousInterfacePtr<http_server::HttpServer> CreateHttpServer(); | 110 mojo::SynchronousInterfacePtr<http_server::HttpServer> CreateHttpServer(); |
111 | 111 |
112 http_server::HttpServerFactoryPtr http_server_factory_; | 112 http_server::HttpServerFactoryPtr http_server_factory_; |
113 mojo::NetworkServicePtr network_service_; | 113 mojo::NetworkServicePtr network_service_; |
114 | 114 |
115 private: | 115 private: |
116 MOJO_DISALLOW_COPY_AND_ASSIGN(HttpServerApplicationTest); | 116 MOJO_DISALLOW_COPY_AND_ASSIGN(HttpServerApplicationTest); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 url_request->method = "POST"; | 195 url_request->method = "POST"; |
196 url_request->body.resize(1); | 196 url_request->body.resize(1); |
197 WriteMessageToDataPipe(kExampleMessage, &url_request->body[0]); | 197 WriteMessageToDataPipe(kExampleMessage, &url_request->body[0]); |
198 | 198 |
199 url_loader->Start(url_request.Pass(), base::Bind(&CheckServerResponse)); | 199 url_loader->Start(url_request.Pass(), base::Bind(&CheckServerResponse)); |
200 base::RunLoop run_loop; | 200 base::RunLoop run_loop; |
201 run_loop.Run(); | 201 run_loop.Run(); |
202 } | 202 } |
203 | 203 |
204 } // namespace http_server | 204 } // namespace http_server |
OLD | NEW |