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" | 29 #include "mojo/shell/public/cpp/application_connection.h" |
30 #include "mojo/shell/public/cpp/application_impl.h" | |
31 #include "mojo/shell/public/cpp/application_test_base.h" | 30 #include "mojo/shell/public/cpp/application_test_base.h" |
32 #include "net/base/io_buffer.h" | 31 #include "net/base/io_buffer.h" |
33 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
34 #include "net/base/test_completion_callback.h" | 33 #include "net/base/test_completion_callback.h" |
35 #include "net/http/http_response_headers.h" | 34 #include "net/http/http_response_headers.h" |
36 #include "net/http/http_util.h" | 35 #include "net/http/http_util.h" |
37 #include "net/socket/tcp_client_socket.h" | 36 #include "net/socket/tcp_client_socket.h" |
38 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
39 | 38 |
40 namespace mojo { | 39 namespace mojo { |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 HttpServerAppTest() : message_loop_(base::MessageLoop::TYPE_IO) {} | 551 HttpServerAppTest() : message_loop_(base::MessageLoop::TYPE_IO) {} |
553 ~HttpServerAppTest() override {} | 552 ~HttpServerAppTest() override {} |
554 | 553 |
555 protected: | 554 protected: |
556 bool ShouldCreateDefaultRunLoop() override { return false; } | 555 bool ShouldCreateDefaultRunLoop() override { return false; } |
557 | 556 |
558 void SetUp() override { | 557 void SetUp() override { |
559 ApplicationTestBase::SetUp(); | 558 ApplicationTestBase::SetUp(); |
560 | 559 |
561 scoped_ptr<ApplicationConnection> connection = | 560 scoped_ptr<ApplicationConnection> connection = |
562 application_impl()->ConnectToApplication("mojo:network_service"); | 561 shell()->ConnectToApplication("mojo:network_service"); |
563 connection->ConnectToService(&network_service_); | 562 connection->ConnectToService(&network_service_); |
564 connection->ConnectToService(&web_socket_factory_); | 563 connection->ConnectToService(&web_socket_factory_); |
565 } | 564 } |
566 | 565 |
567 void CreateHttpServer(HttpServerDelegatePtr delegate, | 566 void CreateHttpServer(HttpServerDelegatePtr delegate, |
568 NetAddressPtr* out_bound_to) { | 567 NetAddressPtr* out_bound_to) { |
569 network_service_->CreateHttpServer( | 568 network_service_->CreateHttpServer( |
570 GetLocalHostWithAnyPort(), std::move(delegate), | 569 GetLocalHostWithAnyPort(), std::move(delegate), |
571 [out_bound_to](NetworkErrorPtr result, NetAddressPtr bound_to) { | 570 [out_bound_to](NetworkErrorPtr result, NetAddressPtr bound_to) { |
572 ASSERT_EQ(net::OK, result->code); | 571 ASSERT_EQ(net::OK, result->code); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 | 690 |
692 socket_1.Send("How do"); | 691 socket_1.Send("How do"); |
693 socket_1.Send("you do?"); | 692 socket_1.Send("you do?"); |
694 | 693 |
695 socket_0.WaitForMessage(2); | 694 socket_0.WaitForMessage(2); |
696 EXPECT_EQ("How do", socket_0.received_messages()[0]); | 695 EXPECT_EQ("How do", socket_0.received_messages()[0]); |
697 EXPECT_EQ("you do?", socket_0.received_messages()[1]); | 696 EXPECT_EQ("you do?", socket_0.received_messages()[1]); |
698 } | 697 } |
699 | 698 |
700 } // namespace mojo | 699 } // namespace mojo |
OLD | NEW |