| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "mojo/common/data_pipe_utils.h" | 18 #include "mojo/common/data_pipe_utils.h" |
| 19 #include "mojo/services/network/net_address_type_converters.h" | 19 #include "mojo/services/network/net_address_type_converters.h" |
| 20 #include "mojo/services/network/public/cpp/web_socket_read_queue.h" | 20 #include "mojo/services/network/public/cpp/web_socket_read_queue.h" |
| 21 #include "mojo/services/network/public/cpp/web_socket_write_queue.h" | 21 #include "mojo/services/network/public/cpp/web_socket_write_queue.h" |
| 22 #include "mojo/services/network/public/interfaces/http_connection.mojom.h" | 22 #include "mojo/services/network/public/interfaces/http_connection.mojom.h" |
| 23 #include "mojo/services/network/public/interfaces/http_message.mojom.h" | 23 #include "mojo/services/network/public/interfaces/http_message.mojom.h" |
| 24 #include "mojo/services/network/public/interfaces/http_server.mojom.h" | 24 #include "mojo/services/network/public/interfaces/http_server.mojom.h" |
| 25 #include "mojo/services/network/public/interfaces/net_address.mojom.h" | 25 #include "mojo/services/network/public/interfaces/net_address.mojom.h" |
| 26 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 26 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 27 #include "mojo/services/network/public/interfaces/web_socket.mojom.h" | 27 #include "mojo/services/network/public/interfaces/web_socket.mojom.h" |
| 28 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" | 28 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" |
| 29 #include "mojo/shell/public/cpp/application_connection.h" | |
| 30 #include "mojo/shell/public/cpp/application_test_base.h" | 29 #include "mojo/shell/public/cpp/application_test_base.h" |
| 31 #include "net/base/io_buffer.h" | 30 #include "net/base/io_buffer.h" |
| 32 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| 33 #include "net/base/test_completion_callback.h" | 32 #include "net/base/test_completion_callback.h" |
| 34 #include "net/http/http_response_headers.h" | 33 #include "net/http/http_response_headers.h" |
| 35 #include "net/http/http_util.h" | 34 #include "net/http/http_util.h" |
| 36 #include "net/socket/tcp_client_socket.h" | 35 #include "net/socket/tcp_client_socket.h" |
| 37 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
| 38 | 37 |
| 39 namespace mojo { | 38 namespace mojo { |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 public: | 549 public: |
| 551 HttpServerAppTest() : message_loop_(base::MessageLoop::TYPE_IO) {} | 550 HttpServerAppTest() : message_loop_(base::MessageLoop::TYPE_IO) {} |
| 552 ~HttpServerAppTest() override {} | 551 ~HttpServerAppTest() override {} |
| 553 | 552 |
| 554 protected: | 553 protected: |
| 555 bool ShouldCreateDefaultRunLoop() override { return false; } | 554 bool ShouldCreateDefaultRunLoop() override { return false; } |
| 556 | 555 |
| 557 void SetUp() override { | 556 void SetUp() override { |
| 558 ApplicationTestBase::SetUp(); | 557 ApplicationTestBase::SetUp(); |
| 559 | 558 |
| 560 scoped_ptr<ApplicationConnection> connection = | 559 scoped_ptr<Connection> connection = |
| 561 shell()->ConnectToApplication("mojo:network_service"); | 560 shell()->ConnectToApplication("mojo:network_service"); |
| 562 connection->ConnectToService(&network_service_); | 561 connection->ConnectToService(&network_service_); |
| 563 connection->ConnectToService(&web_socket_factory_); | 562 connection->ConnectToService(&web_socket_factory_); |
| 564 } | 563 } |
| 565 | 564 |
| 566 void CreateHttpServer(HttpServerDelegatePtr delegate, | 565 void CreateHttpServer(HttpServerDelegatePtr delegate, |
| 567 NetAddressPtr* out_bound_to) { | 566 NetAddressPtr* out_bound_to) { |
| 568 network_service_->CreateHttpServer( | 567 network_service_->CreateHttpServer( |
| 569 GetLocalHostWithAnyPort(), std::move(delegate), | 568 GetLocalHostWithAnyPort(), std::move(delegate), |
| 570 [out_bound_to](NetworkErrorPtr result, NetAddressPtr bound_to) { | 569 [out_bound_to](NetworkErrorPtr result, NetAddressPtr bound_to) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 | 689 |
| 691 socket_1.Send("How do"); | 690 socket_1.Send("How do"); |
| 692 socket_1.Send("you do?"); | 691 socket_1.Send("you do?"); |
| 693 | 692 |
| 694 socket_0.WaitForMessage(2); | 693 socket_0.WaitForMessage(2); |
| 695 EXPECT_EQ("How do", socket_0.received_messages()[0]); | 694 EXPECT_EQ("How do", socket_0.received_messages()[0]); |
| 696 EXPECT_EQ("you do?", socket_0.received_messages()[1]); | 695 EXPECT_EQ("you do?", socket_0.received_messages()[1]); |
| 697 } | 696 } |
| 698 | 697 |
| 699 } // namespace mojo | 698 } // namespace mojo |
| OLD | NEW |