| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/extensions/application_launch.h" | 12 #include "chrome/browser/ui/extensions/application_launch.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
| 17 #include "extensions/browser/api/dns/host_resolver_wrapper.h" | 17 #include "extensions/browser/api/dns/host_resolver_wrapper.h" |
| 18 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" | 18 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" |
| 19 #include "extensions/browser/api/sockets_udp/sockets_udp_api.h" | 19 #include "extensions/browser/api/sockets_udp/sockets_udp_api.h" |
| 20 #include "extensions/test/result_catcher.h" |
| 20 #include "net/dns/mock_host_resolver.h" | 21 #include "net/dns/mock_host_resolver.h" |
| 21 #include "net/test/spawned_test_server/spawned_test_server.h" | 22 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 22 | 23 |
| 23 using extensions::Extension; | 24 using extensions::Extension; |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 // TODO(jschuh): Hanging plugin tests. crbug.com/244653 | 28 // TODO(jschuh): Hanging plugin tests. crbug.com/244653 |
| 28 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) | 29 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) |
| 29 #define MAYBE(x) DISABLED_##x | 30 #define MAYBE(x) DISABLED_##x |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 base::FilePath(FILE_PATH_LITERAL("net/data")))); | 72 base::FilePath(FILE_PATH_LITERAL("net/data")))); |
| 72 EXPECT_TRUE(test_server->Start()); | 73 EXPECT_TRUE(test_server->Start()); |
| 73 | 74 |
| 74 net::HostPortPair host_port_pair = test_server->host_port_pair(); | 75 net::HostPortPair host_port_pair = test_server->host_port_pair(); |
| 75 int port = host_port_pair.port(); | 76 int port = host_port_pair.port(); |
| 76 ASSERT_TRUE(port > 0); | 77 ASSERT_TRUE(port > 0); |
| 77 | 78 |
| 78 // Test that sendTo() is properly resolving hostnames. | 79 // Test that sendTo() is properly resolving hostnames. |
| 79 host_port_pair.set_host("LOCALhost"); | 80 host_port_pair.set_host("LOCALhost"); |
| 80 | 81 |
| 81 ResultCatcher catcher; | 82 extensions::ResultCatcher catcher; |
| 82 catcher.RestrictToProfile(browser()->profile()); | 83 catcher.RestrictToBrowserContext(browser()->profile()); |
| 83 | 84 |
| 84 ExtensionTestMessageListener listener("info_please", true); | 85 ExtensionTestMessageListener listener("info_please", true); |
| 85 | 86 |
| 86 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_udp/api"))); | 87 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_udp/api"))); |
| 87 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 88 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 88 listener.Reply( | 89 listener.Reply( |
| 89 base::StringPrintf("udp:%s:%d", host_port_pair.host().c_str(), port)); | 90 base::StringPrintf("udp:%s:%d", host_port_pair.host().c_str(), port)); |
| 90 | 91 |
| 91 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 92 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 92 } | 93 } |
| 93 | 94 |
| 94 IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, DISABLED_SocketsUdpMulticast) { | 95 IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, DISABLED_SocketsUdpMulticast) { |
| 95 ResultCatcher catcher; | 96 extensions::ResultCatcher catcher; |
| 96 catcher.RestrictToProfile(browser()->profile()); | 97 catcher.RestrictToBrowserContext(browser()->profile()); |
| 97 ExtensionTestMessageListener listener("info_please", true); | 98 ExtensionTestMessageListener listener("info_please", true); |
| 98 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_udp/api"))); | 99 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_udp/api"))); |
| 99 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 100 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 100 listener.Reply( | 101 listener.Reply( |
| 101 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); | 102 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); |
| 102 | 103 |
| 103 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 104 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 104 } | 105 } |
| OLD | NEW |