| 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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "extensions/browser/api/dns/host_resolver_wrapper.h" | 7 #include "extensions/browser/api/dns/host_resolver_wrapper.h" |
| 8 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" | 8 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" |
| 9 #include "extensions/browser/api/sockets_udp/sockets_udp_api.h" | 9 #include "extensions/browser/api/sockets_udp/sockets_udp_api.h" |
| 10 #include "extensions/browser/api_test_utils.h" | 10 #include "extensions/browser/api_test_utils.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpCreateGood) { | 54 IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpCreateGood) { |
| 55 scoped_refptr<api::SocketsUdpCreateFunction> socket_create_function( | 55 scoped_refptr<api::SocketsUdpCreateFunction> socket_create_function( |
| 56 new api::SocketsUdpCreateFunction()); | 56 new api::SocketsUdpCreateFunction()); |
| 57 scoped_refptr<Extension> empty_extension = test_util::CreateEmptyExtension(); | 57 scoped_refptr<Extension> empty_extension = test_util::CreateEmptyExtension(); |
| 58 | 58 |
| 59 socket_create_function->set_extension(empty_extension.get()); | 59 socket_create_function->set_extension(empty_extension.get()); |
| 60 socket_create_function->set_has_callback(true); | 60 socket_create_function->set_has_callback(true); |
| 61 | 61 |
| 62 scoped_ptr<base::Value> result( | 62 std::unique_ptr<base::Value> result( |
| 63 api_test_utils::RunFunctionAndReturnSingleResult( | 63 api_test_utils::RunFunctionAndReturnSingleResult( |
| 64 socket_create_function.get(), "[]", browser_context())); | 64 socket_create_function.get(), "[]", browser_context())); |
| 65 | 65 |
| 66 base::DictionaryValue* value = NULL; | 66 base::DictionaryValue* value = NULL; |
| 67 ASSERT_TRUE(result->GetAsDictionary(&value)); | 67 ASSERT_TRUE(result->GetAsDictionary(&value)); |
| 68 int socketId = -1; | 68 int socketId = -1; |
| 69 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); | 69 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); |
| 70 ASSERT_TRUE(socketId > 0); | 70 ASSERT_TRUE(socketId > 0); |
| 71 } | 71 } |
| 72 | 72 |
| 73 IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpExtension) { | 73 IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpExtension) { |
| 74 scoped_ptr<net::SpawnedTestServer> test_server(new net::SpawnedTestServer( | 74 std::unique_ptr<net::SpawnedTestServer> test_server( |
| 75 net::SpawnedTestServer::TYPE_UDP_ECHO, net::SpawnedTestServer::kLocalhost, | 75 new net::SpawnedTestServer( |
| 76 base::FilePath(FILE_PATH_LITERAL("net/data")))); | 76 net::SpawnedTestServer::TYPE_UDP_ECHO, |
| 77 net::SpawnedTestServer::kLocalhost, |
| 78 base::FilePath(FILE_PATH_LITERAL("net/data")))); |
| 77 EXPECT_TRUE(test_server->Start()); | 79 EXPECT_TRUE(test_server->Start()); |
| 78 | 80 |
| 79 net::HostPortPair host_port_pair = test_server->host_port_pair(); | 81 net::HostPortPair host_port_pair = test_server->host_port_pair(); |
| 80 int port = host_port_pair.port(); | 82 int port = host_port_pair.port(); |
| 81 ASSERT_TRUE(port > 0); | 83 ASSERT_TRUE(port > 0); |
| 82 | 84 |
| 83 // Test that sendTo() is properly resolving hostnames. | 85 // Test that sendTo() is properly resolving hostnames. |
| 84 host_port_pair.set_host("LOCALhost"); | 86 host_port_pair.set_host("LOCALhost"); |
| 85 | 87 |
| 86 ResultCatcher catcher; | 88 ResultCatcher catcher; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 103 ExtensionTestMessageListener listener("info_please", true); | 105 ExtensionTestMessageListener listener("info_please", true); |
| 104 ASSERT_TRUE(LoadApp("sockets_udp/api")); | 106 ASSERT_TRUE(LoadApp("sockets_udp/api")); |
| 105 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 107 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 106 listener.Reply( | 108 listener.Reply( |
| 107 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); | 109 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); |
| 108 | 110 |
| 109 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 111 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 110 } | 112 } |
| 111 | 113 |
| 112 } // namespace extensions | 114 } // namespace extensions |
| OLD | NEW |