| 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" | 7 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" |
| 8 #include "chrome/browser/extensions/api/dns/mock_host_resolver_creator.h" | 8 #include "chrome/browser/extensions/api/dns/mock_host_resolver_creator.h" |
| 9 #include "chrome/browser/extensions/api/socket/socket_api.h" | 9 #include "chrome/browser/extensions/api/socket/socket_api.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // If we're invoking socket tests, all we can confirm is that we have at | 117 // If we're invoking socket tests, all we can confirm is that we have at |
| 118 // least one address, but not what it is. | 118 // least one address, but not what it is. |
| 119 ListValue *value = static_cast<ListValue*>(result.get()); | 119 ListValue *value = static_cast<ListValue*>(result.get()); |
| 120 ASSERT_TRUE(value->GetSize() > 0); | 120 ASSERT_TRUE(value->GetSize() > 0); |
| 121 } | 121 } |
| 122 | 122 |
| 123 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPExtension) { | 123 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPExtension) { |
| 124 scoped_ptr<net::TestServer> test_server( | 124 scoped_ptr<net::TestServer> test_server( |
| 125 new net::TestServer(net::TestServer::TYPE_UDP_ECHO, | 125 new net::TestServer(net::TestServer::TYPE_UDP_ECHO, |
| 126 net::TestServer::kLocalhost, | 126 net::TestServer::kLocalhost, |
| 127 base::FilePath(FILE_PATH_LITERAL("net/data")))); | 127 net::TestServer::GetSourceRelativePath( |
| 128 base::FilePath(FILE_PATH_LITERAL("net/data"))))); |
| 128 EXPECT_TRUE(test_server->Start()); | 129 EXPECT_TRUE(test_server->Start()); |
| 129 | 130 |
| 130 net::HostPortPair host_port_pair = test_server->host_port_pair(); | 131 net::HostPortPair host_port_pair = test_server->host_port_pair(); |
| 131 int port = host_port_pair.port(); | 132 int port = host_port_pair.port(); |
| 132 ASSERT_TRUE(port > 0); | 133 ASSERT_TRUE(port > 0); |
| 133 | 134 |
| 134 // Test that sendTo() is properly resolving hostnames. | 135 // Test that sendTo() is properly resolving hostnames. |
| 135 host_port_pair.set_host("LOCALhost"); | 136 host_port_pair.set_host("LOCALhost"); |
| 136 | 137 |
| 137 ResultCatcher catcher; | 138 ResultCatcher catcher; |
| 138 catcher.RestrictToProfile(browser()->profile()); | 139 catcher.RestrictToProfile(browser()->profile()); |
| 139 | 140 |
| 140 ExtensionTestMessageListener listener("info_please", true); | 141 ExtensionTestMessageListener listener("info_please", true); |
| 141 | 142 |
| 142 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); | 143 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); |
| 143 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 144 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 144 listener.Reply( | 145 listener.Reply( |
| 145 base::StringPrintf("udp:%s:%d", host_port_pair.host().c_str(), port)); | 146 base::StringPrintf("udp:%s:%d", host_port_pair.host().c_str(), port)); |
| 146 | 147 |
| 147 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 148 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPExtension) { | 151 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPExtension) { |
| 151 scoped_ptr<net::TestServer> test_server( | 152 scoped_ptr<net::TestServer> test_server( |
| 152 new net::TestServer(net::TestServer::TYPE_TCP_ECHO, | 153 new net::TestServer(net::TestServer::TYPE_TCP_ECHO, |
| 153 net::TestServer::kLocalhost, | 154 net::TestServer::kLocalhost, |
| 154 base::FilePath(FILE_PATH_LITERAL("net/data")))); | 155 net::TestServer::GetSourceRelativePath( |
| 156 base::FilePath(FILE_PATH_LITERAL("net/data"))))); |
| 155 EXPECT_TRUE(test_server->Start()); | 157 EXPECT_TRUE(test_server->Start()); |
| 156 | 158 |
| 157 net::HostPortPair host_port_pair = test_server->host_port_pair(); | 159 net::HostPortPair host_port_pair = test_server->host_port_pair(); |
| 158 int port = host_port_pair.port(); | 160 int port = host_port_pair.port(); |
| 159 ASSERT_TRUE(port > 0); | 161 ASSERT_TRUE(port > 0); |
| 160 | 162 |
| 161 // Test that connect() is properly resolving hostnames. | 163 // Test that connect() is properly resolving hostnames. |
| 162 host_port_pair.set_host("lOcAlHoSt"); | 164 host_port_pair.set_host("lOcAlHoSt"); |
| 163 | 165 |
| 164 ResultCatcher catcher; | 166 ResultCatcher catcher; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 192 LoadExtension(test_data_dir_.AppendASCII("socket/unload")); | 194 LoadExtension(test_data_dir_.AppendASCII("socket/unload")); |
| 193 ASSERT_TRUE(extension); | 195 ASSERT_TRUE(extension); |
| 194 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 196 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 195 | 197 |
| 196 UnloadExtension(extension->id()); | 198 UnloadExtension(extension->id()); |
| 197 | 199 |
| 198 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/unload"))) | 200 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/unload"))) |
| 199 << message_; | 201 << message_; |
| 200 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 202 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 201 } | 203 } |
| OLD | NEW |