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" |
11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
12 #include "chrome/test/base/browser_with_test_window_test.h" | 12 #include "chrome/test/base/browser_with_test_window_test.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 // UDPSocketUnitTest exists solely to make it easier to pass a specific | 18 // UDPSocketUnitTest exists solely to make it easier to pass a specific |
19 // gtest_filter argument during development. | 19 // gtest_filter argument during development. |
20 class UDPSocketUnitTest : public BrowserWithTestWindowTest { | 20 class UDPSocketUnitTest : public BrowserWithTestWindowTest { |
21 }; | 21 }; |
22 | 22 |
23 static void OnConnected(int result) { | 23 static void OnConnected(int result) { |
24 EXPECT_EQ(0, result); | 24 EXPECT_EQ(0, result); |
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 uint16 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(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 |
(...skipping 88 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 |