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/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "mojo/public/cpp/bindings/callback.h" | 8 #include "mojo/public/cpp/bindings/callback.h" |
9 #include "mojo/services/public/interfaces/network/network_service.mojom.h" | 9 #include "mojo/services/public/interfaces/network/network_service.mojom.h" |
10 #include "mojo/services/public/interfaces/network/udp_socket.mojom.h" | 10 #include "mojo/services/public/interfaces/network/udp_socket.mojom.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 }; | 201 }; |
202 | 202 |
203 uint32_t result_; | 203 uint32_t result_; |
204 }; | 204 }; |
205 | 205 |
206 class UDPSocketTest : public testing::Test { | 206 class UDPSocketTest : public testing::Test { |
207 public: | 207 public: |
208 UDPSocketTest() {} | 208 UDPSocketTest() {} |
209 virtual ~UDPSocketTest() {} | 209 virtual ~UDPSocketTest() {} |
210 | 210 |
211 virtual void SetUp() OVERRIDE { | 211 virtual void SetUp() override { |
212 test_helper_.Init(); | 212 test_helper_.Init(); |
213 | 213 |
214 test_helper_.application_manager()->ConnectToService( | 214 test_helper_.application_manager()->ConnectToService( |
215 GURL("mojo:mojo_network_service"), &network_service_); | 215 GURL("mojo:mojo_network_service"), &network_service_); |
216 | 216 |
217 network_service_->CreateUDPSocket(GetProxy(&udp_socket_)); | 217 network_service_->CreateUDPSocket(GetProxy(&udp_socket_)); |
218 udp_socket_.set_client(&udp_socket_client_); | 218 udp_socket_.set_client(&udp_socket_client_); |
219 } | 219 } |
220 | 220 |
221 protected: | 221 protected: |
(...skipping 10 matching lines...) Expand all Loading... |
232 | 232 |
233 virtual ~UDPSocketClientImpl() { | 233 virtual ~UDPSocketClientImpl() { |
234 while (!results_.empty()) { | 234 while (!results_.empty()) { |
235 delete results_.front(); | 235 delete results_.front(); |
236 results_.pop(); | 236 results_.pop(); |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 virtual void OnReceived(NetworkErrorPtr result, | 240 virtual void OnReceived(NetworkErrorPtr result, |
241 NetAddressPtr src_addr, | 241 NetAddressPtr src_addr, |
242 Array<uint8_t> data) OVERRIDE { | 242 Array<uint8_t> data) override { |
243 ReceiveResult* entry = new ReceiveResult(); | 243 ReceiveResult* entry = new ReceiveResult(); |
244 entry->result = result.Pass(); | 244 entry->result = result.Pass(); |
245 entry->addr = src_addr.Pass(); | 245 entry->addr = src_addr.Pass(); |
246 entry->data = data.Pass(); | 246 entry->data = data.Pass(); |
247 | 247 |
248 results_.push(entry); | 248 results_.push(entry); |
249 | 249 |
250 if (results_.size() == expected_receive_count_ && run_loop_) { | 250 if (results_.size() == expected_receive_count_ && run_loop_) { |
251 expected_receive_count_ = 0; | 251 expected_receive_count_ = 0; |
252 run_loop_->Quit(); | 252 run_loop_->Quit(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 377 |
378 EXPECT_EQ(static_cast<int>(kDatagramSize), result->result->code); | 378 EXPECT_EQ(static_cast<int>(kDatagramSize), result->result->code); |
379 EXPECT_TRUE(AreEqualArrays( | 379 EXPECT_TRUE(AreEqualArrays( |
380 CreateTestMessage(static_cast<uint8_t>(i), kDatagramSize), | 380 CreateTestMessage(static_cast<uint8_t>(i), kDatagramSize), |
381 result->data)); | 381 result->data)); |
382 } | 382 } |
383 } | 383 } |
384 | 384 |
385 } // namespace service | 385 } // namespace service |
386 } // namespace mojo | 386 } // namespace mojo |
OLD | NEW |