Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/browser/extensions/api/socket/socket_apitest.cc

Issue 11299326: Revert 170660 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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();
149 } 148 }
150 149
151 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPExtension) { 150 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPExtension) {
152 scoped_ptr<net::TestServer> test_server( 151 scoped_ptr<net::TestServer> test_server(
153 new net::TestServer(net::TestServer::TYPE_TCP_ECHO, 152 new net::TestServer(net::TestServer::TYPE_TCP_ECHO,
154 net::TestServer::kLocalhost, 153 net::TestServer::kLocalhost,
155 FilePath(FILE_PATH_LITERAL("net/data")))); 154 FilePath(FILE_PATH_LITERAL("net/data"))));
156 EXPECT_TRUE(test_server->Start()); 155 EXPECT_TRUE(test_server->Start());
157 156
158 net::HostPortPair host_port_pair = test_server->host_port_pair(); 157 net::HostPortPair host_port_pair = test_server->host_port_pair();
159 int port = host_port_pair.port(); 158 int port = host_port_pair.port();
160 ASSERT_TRUE(port > 0); 159 ASSERT_TRUE(port > 0);
161 160
162 // Test that connect() is properly resolving hostnames. 161 // Test that connect() is properly resolving hostnames.
163 host_port_pair.set_host("lOcAlHoSt"); 162 host_port_pair.set_host("lOcAlHoSt");
164 163
165 ResultCatcher catcher; 164 ResultCatcher catcher;
166 catcher.RestrictToProfile(browser()->profile()); 165 catcher.RestrictToProfile(browser()->profile());
167 166
168 ExtensionTestMessageListener listener("info_please", true); 167 ExtensionTestMessageListener listener("info_please", true);
169 168
170 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); 169 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api")));
171 EXPECT_TRUE(listener.WaitUntilSatisfied()); 170 EXPECT_TRUE(listener.WaitUntilSatisfied());
172 listener.Reply( 171 listener.Reply(
173 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); 172 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port));
174 173
175 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 174 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
176 CloseShellWindowsAndWaitForAppToExit();
177 } 175 }
178 176
179 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerExtension) { 177 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerExtension) {
180 ResultCatcher catcher; 178 ResultCatcher catcher;
181 catcher.RestrictToProfile(browser()->profile()); 179 catcher.RestrictToProfile(browser()->profile());
182 ExtensionTestMessageListener listener("info_please", true); 180 ExtensionTestMessageListener listener("info_please", true);
183 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); 181 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api")));
184 EXPECT_TRUE(listener.WaitUntilSatisfied()); 182 EXPECT_TRUE(listener.WaitUntilSatisfied());
185 listener.Reply( 183 listener.Reply(
186 base::StringPrintf("tcp_server:%s:%d", kHostname.c_str(), kPort)); 184 base::StringPrintf("tcp_server:%s:%d", kHostname.c_str(), kPort));
187 185
188 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 186 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
189 CloseShellWindowsAndWaitForAppToExit();
190 } 187 }
191 188
192 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerUnbindOnUnload) { 189 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerUnbindOnUnload) {
193 ASSERT_TRUE(RunExtensionTest("socket/unload")) << message_; 190 ASSERT_TRUE(RunExtensionTest("socket/unload")) << message_;
194 CloseShellWindowsAndWaitForAppToExit();
195 ASSERT_TRUE(RunExtensionTest("socket/unload")) << message_; 191 ASSERT_TRUE(RunExtensionTest("socket/unload")) << message_;
196 CloseShellWindowsAndWaitForAppToExit();
197 } 192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698