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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 base::RunLoop run_loop; | 74 base::RunLoop run_loop; |
75 run_loop_ = &run_loop; | 75 run_loop_ = &run_loop; |
76 run_loop.Run(); | 76 run_loop.Run(); |
77 run_loop_ = nullptr; | 77 run_loop_ = nullptr; |
78 } | 78 } |
79 | 79 |
80 protected: | 80 protected: |
81 struct StateBase : public CallbackType::Runnable { | 81 struct StateBase : public CallbackType::Runnable { |
82 StateBase() : test_callback_(nullptr) {} | 82 StateBase() : test_callback_(nullptr) {} |
83 virtual ~StateBase() {} | 83 ~StateBase() override {} |
84 | 84 |
85 void set_test_callback(TestCallbackBase* test_callback) { | 85 void set_test_callback(TestCallbackBase* test_callback) { |
86 test_callback_ = test_callback; | 86 test_callback_ = test_callback; |
87 } | 87 } |
88 | 88 |
89 protected: | 89 protected: |
90 void NotifyRun() const { | 90 void NotifyRun() const { |
91 if (test_callback_) { | 91 if (test_callback_) { |
92 test_callback_->ran_ = true; | 92 test_callback_->ran_ = true; |
93 if (test_callback_->run_loop_) | 93 if (test_callback_->run_loop_) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 NotifyRun(); | 198 NotifyRun(); |
199 } | 199 } |
200 }; | 200 }; |
201 | 201 |
202 uint32_t result_; | 202 uint32_t result_; |
203 }; | 203 }; |
204 | 204 |
205 class UDPSocketTest : public testing::Test { | 205 class UDPSocketTest : public testing::Test { |
206 public: | 206 public: |
207 UDPSocketTest() {} | 207 UDPSocketTest() {} |
208 virtual ~UDPSocketTest() {} | 208 ~UDPSocketTest() override {} |
209 | 209 |
210 virtual void SetUp() override { | 210 void SetUp() override { |
211 test_helper_.Init(); | 211 test_helper_.Init(); |
212 | 212 |
213 test_helper_.application_manager()->ConnectToService( | 213 test_helper_.application_manager()->ConnectToService( |
214 GURL("mojo:network_service"), &network_service_); | 214 GURL("mojo:network_service"), &network_service_); |
215 | 215 |
216 network_service_->CreateUDPSocket(GetProxy(&udp_socket_)); | 216 network_service_->CreateUDPSocket(GetProxy(&udp_socket_)); |
217 udp_socket_.set_client(&udp_socket_client_); | 217 udp_socket_.set_client(&udp_socket_client_); |
218 } | 218 } |
219 | 219 |
220 protected: | 220 protected: |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 | 376 |
377 EXPECT_EQ(static_cast<int>(kDatagramSize), result->result->code); | 377 EXPECT_EQ(static_cast<int>(kDatagramSize), result->result->code); |
378 EXPECT_TRUE(AreEqualArrays( | 378 EXPECT_TRUE(AreEqualArrays( |
379 CreateTestMessage(static_cast<uint8_t>(i), kDatagramSize), | 379 CreateTestMessage(static_cast<uint8_t>(i), kDatagramSize), |
380 result->data)); | 380 result->data)); |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
384 } // namespace service | 384 } // namespace service |
385 } // namespace mojo | 385 } // namespace mojo |
OLD | NEW |