| 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/memory/linked_ptr.h" | 6 #include "base/memory/linked_ptr.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 public: | 374 public: |
| 375 HttpServerAppTest() : message_loop_(base::MessageLoop::TYPE_IO) {} | 375 HttpServerAppTest() : message_loop_(base::MessageLoop::TYPE_IO) {} |
| 376 ~HttpServerAppTest() override {} | 376 ~HttpServerAppTest() override {} |
| 377 | 377 |
| 378 protected: | 378 protected: |
| 379 bool ShouldCreateDefaultRunLoop() override { return false; } | 379 bool ShouldCreateDefaultRunLoop() override { return false; } |
| 380 | 380 |
| 381 void SetUp() override { | 381 void SetUp() override { |
| 382 ApplicationTestBase::SetUp(); | 382 ApplicationTestBase::SetUp(); |
| 383 | 383 |
| 384 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 385 request->url = mojo::String::From("mojo:network_service"); |
| 384 ApplicationConnection* connection = | 386 ApplicationConnection* connection = |
| 385 application_impl()->ConnectToApplication("mojo:network_service"); | 387 application_impl()->ConnectToApplication(request.Pass()); |
| 386 connection->ConnectToService(&network_service_); | 388 connection->ConnectToService(&network_service_); |
| 387 } | 389 } |
| 388 | 390 |
| 389 void CreateHttpServer(HttpServerDelegatePtr delegate, | 391 void CreateHttpServer(HttpServerDelegatePtr delegate, |
| 390 NetAddressPtr* out_bound_to) { | 392 NetAddressPtr* out_bound_to) { |
| 391 network_service_->CreateHttpServer( | 393 network_service_->CreateHttpServer( |
| 392 GetLocalHostWithAnyPort(), delegate.Pass(), | 394 GetLocalHostWithAnyPort(), delegate.Pass(), |
| 393 [out_bound_to](NetworkErrorPtr result, NetAddressPtr bound_to) { | 395 [out_bound_to](NetworkErrorPtr result, NetAddressPtr bound_to) { |
| 394 ASSERT_EQ(net::OK, result->code); | 396 ASSERT_EQ(net::OK, result->code); |
| 395 EXPECT_NE(0u, bound_to->ipv4->port); | 397 EXPECT_NE(0u, bound_to->ipv4->port); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 make_scoped_ptr(new std::string("This is a test response..."))}; | 474 make_scoped_ptr(new std::string("This is a test response..."))}; |
| 473 connection.SendResponse(MakeResponseStruct(response_data)); | 475 connection.SendResponse(MakeResponseStruct(response_data)); |
| 474 | 476 |
| 475 std::string response_message; | 477 std::string response_message; |
| 476 client.ReadResponse(&response_message); | 478 client.ReadResponse(&response_message); |
| 477 | 479 |
| 478 CheckResponse(response_data, response_message); | 480 CheckResponse(response_data, response_message); |
| 479 } | 481 } |
| 480 | 482 |
| 481 } // namespace mojo | 483 } // namespace mojo |
| OLD | NEW |