OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "extensions/browser/api/socket/udp_socket.h" | 5 #include "extensions/browser/api/socket/udp_socket.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 static void OnCompleted(int bytes_read, | 27 static void OnCompleted(int bytes_read, |
28 scoped_refptr<net::IOBuffer> io_buffer, | 28 scoped_refptr<net::IOBuffer> io_buffer, |
29 const std::string& address, | 29 const std::string& address, |
30 int port) { | 30 int port) { |
31 // Do nothing; don't care. | 31 // Do nothing; don't care. |
32 } | 32 } |
33 | 33 |
34 static const char test_message[] = "$$TESTMESSAGETESTMESSAGETESTMESSAGETEST$$"; | 34 static const char test_message[] = "$$TESTMESSAGETESTMESSAGETESTMESSAGETEST$$"; |
35 static const int test_message_length = ARRAYSIZE_UNSAFE(test_message); | 35 static const int test_message_length = arraysize(test_message); |
36 | 36 |
37 static void OnSendCompleted(int result) { | 37 static void OnSendCompleted(int result) { |
38 EXPECT_EQ(test_message_length, result); | 38 EXPECT_EQ(test_message_length, result); |
39 } | 39 } |
40 | 40 |
41 TEST(UDPSocketUnitTest, TestUDPSocketRecvFrom) { | 41 TEST(UDPSocketUnitTest, TestUDPSocketRecvFrom) { |
42 base::MessageLoopForIO io_loop; // For RecvFrom to do its threaded work. | 42 base::MessageLoopForIO io_loop; // For RecvFrom to do its threaded work. |
43 UDPSocket socket("abcdefghijklmnopqrst"); | 43 UDPSocket socket("abcdefghijklmnopqrst"); |
44 | 44 |
45 // Confirm that we can call two RecvFroms in quick succession without | 45 // Confirm that we can call two RecvFroms in quick succession without |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 io_loop.PostDelayedTask(FROM_HERE, | 129 io_loop.PostDelayedTask(FROM_HERE, |
130 base::Bind(&QuitMessageLoop), | 130 base::Bind(&QuitMessageLoop), |
131 TestTimeouts::action_timeout()); | 131 TestTimeouts::action_timeout()); |
132 | 132 |
133 io_loop.Run(); | 133 io_loop.Run(); |
134 | 134 |
135 EXPECT_TRUE(packet_received) << "Failed to receive from multicast address"; | 135 EXPECT_TRUE(packet_received) << "Failed to receive from multicast address"; |
136 } | 136 } |
137 | 137 |
138 } // namespace extensions | 138 } // namespace extensions |
OLD | NEW |