| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "mojo/services/network/interfaces/network_service.mojom.h" | 8 #include "mojo/services/network/interfaces/network_service.mojom.h" |
| 9 #include "mojo/services/network/interfaces/udp_socket.mojom.h" | 9 #include "mojo/services/network/interfaces/udp_socket.mojom.h" |
| 10 #include "mojo/services/network/udp_socket_wrapper.h" | 10 #include "mojo/services/network/udp_socket_wrapper.h" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio
n.h" | |
| 14 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h" | 13 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h" |
| 15 #include "third_party/mojo/src/mojo/public/cpp/application/application_test_base
.h" | 14 #include "third_party/mojo/src/mojo/public/cpp/application/application_test_base
.h" |
| 15 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h" |
| 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/callback.h" | 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/callback.h" |
| 17 | 17 |
| 18 namespace mojo { | 18 namespace mojo { |
| 19 namespace service { | 19 namespace service { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 NetAddressPtr GetLocalHostWithAnyPort() { | 22 NetAddressPtr GetLocalHostWithAnyPort() { |
| 23 NetAddressPtr addr(NetAddress::New()); | 23 NetAddressPtr addr(NetAddress::New()); |
| 24 addr->family = NetAddressFamily::IPV4; | 24 addr->family = NetAddressFamily::IPV4; |
| 25 addr->ipv4 = NetAddressIPv4::New(); | 25 addr->ipv4 = NetAddressIPv4::New(); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 }; | 315 }; |
| 316 | 316 |
| 317 class UDPSocketAppTest : public test::ApplicationTestBase { | 317 class UDPSocketAppTest : public test::ApplicationTestBase { |
| 318 public: | 318 public: |
| 319 UDPSocketAppTest() : receiver_binding_(&receiver_) {} | 319 UDPSocketAppTest() : receiver_binding_(&receiver_) {} |
| 320 ~UDPSocketAppTest() override {} | 320 ~UDPSocketAppTest() override {} |
| 321 | 321 |
| 322 void SetUp() override { | 322 void SetUp() override { |
| 323 ApplicationTestBase::SetUp(); | 323 ApplicationTestBase::SetUp(); |
| 324 | 324 |
| 325 ApplicationConnection* connection = | 325 ConnectToService(application_impl()->shell(), "mojo:network_service", |
| 326 application_impl()->ConnectToApplication("mojo:network_service"); | 326 GetProxy(&network_service_)); |
| 327 connection->ConnectToService(&network_service_); | |
| 328 | 327 |
| 329 network_service_->CreateUDPSocket(GetProxy(&socket_)); | 328 network_service_->CreateUDPSocket(GetProxy(&socket_)); |
| 330 } | 329 } |
| 331 | 330 |
| 332 protected: | 331 protected: |
| 333 NetworkServicePtr network_service_; | 332 NetworkServicePtr network_service_; |
| 334 UDPSocketPtr socket_; | 333 UDPSocketPtr socket_; |
| 335 UDPSocketReceiverImpl receiver_; | 334 UDPSocketReceiverImpl receiver_; |
| 336 Binding<UDPSocketReceiver> receiver_binding_; | 335 Binding<UDPSocketReceiver> receiver_binding_; |
| 337 | 336 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 receive_callbacks[j].result()->code); | 642 receive_callbacks[j].result()->code); |
| 644 EXPECT_FALSE(receive_callbacks[j].src_addr()); | 643 EXPECT_FALSE(receive_callbacks[j].src_addr()); |
| 645 EXPECT_TRUE(receive_callbacks[j].data().Equals( | 644 EXPECT_TRUE(receive_callbacks[j].data().Equals( |
| 646 CreateTestMessage(static_cast<uint8_t>(j), kDatagramSize))); | 645 CreateTestMessage(static_cast<uint8_t>(j), kDatagramSize))); |
| 647 } | 646 } |
| 648 } | 647 } |
| 649 } | 648 } |
| 650 | 649 |
| 651 } // namespace service | 650 } // namespace service |
| 652 } // namespace mojo | 651 } // namespace mojo |
| OLD | NEW |