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

Side by Side Diff: chrome/test/ppapi/ppapi_test.cc

Issue 12033057: Make PPAPI test servers start in parallel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make RemoteTestServer compile Created 7 years, 10 months 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 "chrome/test/ppapi/ppapi_test.h" 5 #include "chrome/test/ppapi/ppapi_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 16 matching lines...) Expand all
27 #include "content/public/browser/dom_operation_notification_details.h" 27 #include "content/public/browser/dom_operation_notification_details.h"
28 #include "content/public/test/test_renderer_host.h" 28 #include "content/public/test/test_renderer_host.h"
29 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/notification_types.h" 30 #include "content/public/browser/notification_types.h"
31 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
32 #include "content/public/common/content_paths.h" 32 #include "content/public/common/content_paths.h"
33 #include "content/public/common/content_switches.h" 33 #include "content/public/common/content_switches.h"
34 #include "content/public/test/browser_test_utils.h" 34 #include "content/public/test/browser_test_utils.h"
35 #include "net/base/net_util.h" 35 #include "net/base/net_util.h"
36 #include "net/base/test_data_directory.h" 36 #include "net/base/test_data_directory.h"
37 #include "net/test/test_server.h"
38 #include "ppapi/shared_impl/ppapi_switches.h" 37 #include "ppapi/shared_impl/ppapi_switches.h"
39 #include "ui/gl/gl_switches.h" 38 #include "ui/gl/gl_switches.h"
40 #include "webkit/plugins/plugin_switches.h" 39 #include "webkit/plugins/plugin_switches.h"
41 40
42 using content::DomOperationNotificationDetails; 41 using content::DomOperationNotificationDetails;
43 using content::RenderViewHost; 42 using content::RenderViewHost;
44 43
45 namespace { 44 namespace {
46 45
47 // Platform-specific filename relative to the chrome executable. 46 // Platform-specific filename relative to the chrome executable.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void PPAPITestBase::RunTestAndReload(const std::string& test_case) { 165 void PPAPITestBase::RunTestAndReload(const std::string& test_case) {
167 GURL url = GetTestFileUrl(test_case); 166 GURL url = GetTestFileUrl(test_case);
168 RunTestURL(url); 167 RunTestURL(url);
169 // If that passed, we simply run the test again, which navigates again. 168 // If that passed, we simply run the test again, which navigates again.
170 RunTestURL(url); 169 RunTestURL(url);
171 } 170 }
172 171
173 void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) { 172 void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) {
174 FilePath document_root; 173 FilePath document_root;
175 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root)); 174 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root));
176 RunHTTPTestServer(document_root, test_case, ""); 175 FilePath http_document_root;
176 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root));
177 net::TestServer http_server(net::TestServer::TYPE_HTTP,
178 net::TestServer::kLocalhost,
179 document_root);
180 ASSERT_TRUE(http_server.Start());
181 RunTestURL(GetTestURL(http_server, test_case, ""));
177 } 182 }
178 183
179 void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) { 184 void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) {
180 FilePath document_root; 185 FilePath http_document_root;
181 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root)); 186 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root));
182 net::TestServer test_server(net::TestServer::TYPE_HTTPS, 187 net::TestServer http_server(net::TestServer::TYPE_HTTP,
183 net::BaseTestServer::SSLOptions(), 188 net::TestServer::kLocalhost,
184 document_root); 189 http_document_root);
185 ASSERT_TRUE(test_server.Start()); 190 net::TestServer ssl_server(net::TestServer::TYPE_HTTPS,
186 uint16_t port = test_server.host_port_pair().port(); 191 net::BaseTestServer::SSLOptions(),
187 RunHTTPTestServer(document_root, test_case, 192 http_document_root);
188 StringPrintf("ssl_server_port=%d", port)); 193 // Start the servers in parallel.
194 ASSERT_TRUE(http_server.StartInBackground());
195 ASSERT_TRUE(ssl_server.StartInBackground());
196 // Wait until they are both finished before continuing.
197 ASSERT_TRUE(http_server.BlockUntilStarted());
198 ASSERT_TRUE(ssl_server.BlockUntilStarted());
199
200 uint16_t port = ssl_server.host_port_pair().port();
201 RunTestURL(GetTestURL(http_server,
202 test_case,
203 StringPrintf("ssl_server_port=%d", port)));
189 } 204 }
190 205
191 void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) { 206 void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) {
192 net::TestServer server(net::TestServer::TYPE_WS,
193 net::TestServer::kLocalhost,
194 net::GetWebSocketTestDataDirectory());
195 ASSERT_TRUE(server.Start());
196 uint16_t port = server.host_port_pair().port();
197 FilePath http_document_root; 207 FilePath http_document_root;
198 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root)); 208 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root));
199 RunHTTPTestServer(http_document_root, test_case, 209 net::TestServer http_server(net::TestServer::TYPE_HTTP,
200 StringPrintf("websocket_port=%d", port)); 210 net::TestServer::kLocalhost,
211 http_document_root);
212 net::TestServer ws_server(net::TestServer::TYPE_WS,
213 net::TestServer::kLocalhost,
214 net::GetWebSocketTestDataDirectory());
215 // Start the servers in parallel.
216 ASSERT_TRUE(http_server.StartInBackground());
217 ASSERT_TRUE(ws_server.StartInBackground());
218 // Wait until they are both finished before continuing.
219 ASSERT_TRUE(http_server.BlockUntilStarted());
220 ASSERT_TRUE(ws_server.BlockUntilStarted());
221
222 uint16_t port = ws_server.host_port_pair().port();
223 RunTestURL(GetTestURL(http_server,
224 test_case,
225 StringPrintf("websocket_port=%d", port)));
201 } 226 }
202 227
203 void PPAPITestBase::RunTestIfAudioOutputAvailable( 228 void PPAPITestBase::RunTestIfAudioOutputAvailable(
204 const std::string& test_case) { 229 const std::string& test_case) {
205 RunTest(test_case); 230 RunTest(test_case);
206 } 231 }
207 232
208 void PPAPITestBase::RunTestViaHTTPIfAudioOutputAvailable( 233 void PPAPITestBase::RunTestViaHTTPIfAudioOutputAvailable(
209 const std::string& test_case) { 234 const std::string& test_case) {
210 RunTestViaHTTP(test_case); 235 RunTestViaHTTP(test_case);
(...skipping 18 matching lines...) Expand all
229 JavascriptTestObserver observer( 254 JavascriptTestObserver observer(
230 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), 255 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(),
231 &handler); 256 &handler);
232 257
233 ui_test_utils::NavigateToURL(browser(), test_url); 258 ui_test_utils::NavigateToURL(browser(), test_url);
234 259
235 ASSERT_TRUE(observer.Run()) << handler.error_message(); 260 ASSERT_TRUE(observer.Run()) << handler.error_message();
236 EXPECT_STREQ("PASS", handler.message().c_str()); 261 EXPECT_STREQ("PASS", handler.message().c_str());
237 } 262 }
238 263
239 void PPAPITestBase::RunHTTPTestServer( 264 GURL PPAPITestBase::GetTestURL(
240 const FilePath& document_root, 265 const net::TestServer& http_server,
241 const std::string& test_case, 266 const std::string& test_case,
242 const std::string& extra_params) { 267 const std::string& extra_params) {
243 net::TestServer test_server(net::TestServer::TYPE_HTTP,
244 net::TestServer::kLocalhost,
245 document_root);
246 ASSERT_TRUE(test_server.Start());
247 std::string query = BuildQuery("files/test_case.html?", test_case); 268 std::string query = BuildQuery("files/test_case.html?", test_case);
248 if (!extra_params.empty()) 269 if (!extra_params.empty())
249 query = StringPrintf("%s&%s", query.c_str(), extra_params.c_str()); 270 query = StringPrintf("%s&%s", query.c_str(), extra_params.c_str());
250 271
251 GURL url = test_server.GetURL(query); 272 return http_server.GetURL(query);
252 RunTestURL(url);
253 } 273 }
254 274
255 PPAPITest::PPAPITest() { 275 PPAPITest::PPAPITest() {
256 } 276 }
257 277
258 void PPAPITest::SetUpCommandLine(CommandLine* command_line) { 278 void PPAPITest::SetUpCommandLine(CommandLine* command_line) {
259 PPAPITestBase::SetUpCommandLine(command_line); 279 PPAPITestBase::SetUpCommandLine(command_line);
260 280
261 // Append the switch to register the pepper plugin. 281 // Append the switch to register the pepper plugin.
262 // library name = <out dir>/<test_name>.<library_extension> 282 // library name = <out dir>/<test_name>.<library_extension>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 const std::string& base, 351 const std::string& base,
332 const std::string& test_case) { 352 const std::string& test_case) {
333 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), 353 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(),
334 test_case.c_str()); 354 test_case.c_str());
335 } 355 }
336 356
337 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() { 357 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() {
338 // The default content setting for the PPAPI broker is ASK. We purposefully 358 // The default content setting for the PPAPI broker is ASK. We purposefully
339 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way. 359 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way.
340 } 360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698