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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 catcher.RestrictToProfile(browser()->profile()); | 138 catcher.RestrictToProfile(browser()->profile()); |
139 | 139 |
140 ExtensionTestMessageListener listener("info_please", true); | 140 ExtensionTestMessageListener listener("info_please", true); |
141 | 141 |
142 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); | 142 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); |
143 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 143 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
144 listener.Reply( | 144 listener.Reply( |
145 base::StringPrintf("udp:%s:%d", host_port_pair.host().c_str(), port)); | 145 base::StringPrintf("udp:%s:%d", host_port_pair.host().c_str(), port)); |
146 | 146 |
147 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 147 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 148 CloseShellWindowsAndWaitForAppToExit(); |
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 FilePath(FILE_PATH_LITERAL("net/data")))); | 155 FilePath(FILE_PATH_LITERAL("net/data")))); |
155 EXPECT_TRUE(test_server->Start()); | 156 EXPECT_TRUE(test_server->Start()); |
156 | 157 |
157 net::HostPortPair host_port_pair = test_server->host_port_pair(); | 158 net::HostPortPair host_port_pair = test_server->host_port_pair(); |
158 int port = host_port_pair.port(); | 159 int port = host_port_pair.port(); |
159 ASSERT_TRUE(port > 0); | 160 ASSERT_TRUE(port > 0); |
160 | 161 |
161 // Test that connect() is properly resolving hostnames. | 162 // Test that connect() is properly resolving hostnames. |
162 host_port_pair.set_host("lOcAlHoSt"); | 163 host_port_pair.set_host("lOcAlHoSt"); |
163 | 164 |
164 ResultCatcher catcher; | 165 ResultCatcher catcher; |
165 catcher.RestrictToProfile(browser()->profile()); | 166 catcher.RestrictToProfile(browser()->profile()); |
166 | 167 |
167 ExtensionTestMessageListener listener("info_please", true); | 168 ExtensionTestMessageListener listener("info_please", true); |
168 | 169 |
169 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); | 170 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); |
170 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 171 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
171 listener.Reply( | 172 listener.Reply( |
172 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); | 173 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); |
173 | 174 |
174 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 175 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 176 CloseShellWindowsAndWaitForAppToExit(); |
175 } | 177 } |
176 | 178 |
177 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerExtension) { | 179 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerExtension) { |
178 ResultCatcher catcher; | 180 ResultCatcher catcher; |
179 catcher.RestrictToProfile(browser()->profile()); | 181 catcher.RestrictToProfile(browser()->profile()); |
180 ExtensionTestMessageListener listener("info_please", true); | 182 ExtensionTestMessageListener listener("info_please", true); |
181 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); | 183 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); |
182 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 184 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
183 listener.Reply( | 185 listener.Reply( |
184 base::StringPrintf("tcp_server:%s:%d", kHostname.c_str(), kPort)); | 186 base::StringPrintf("tcp_server:%s:%d", kHostname.c_str(), kPort)); |
185 | 187 |
186 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 188 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 189 CloseShellWindowsAndWaitForAppToExit(); |
187 } | 190 } |
188 | 191 |
189 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerUnbindOnUnload) { | 192 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerUnbindOnUnload) { |
190 ASSERT_TRUE(RunExtensionTest("socket/unload")) << message_; | 193 ASSERT_TRUE(RunExtensionTest("socket/unload")) << message_; |
| 194 CloseShellWindowsAndWaitForAppToExit(); |
191 ASSERT_TRUE(RunExtensionTest("socket/unload")) << message_; | 195 ASSERT_TRUE(RunExtensionTest("socket/unload")) << message_; |
| 196 CloseShellWindowsAndWaitForAppToExit(); |
192 } | 197 } |
OLD | NEW |