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 "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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // Start the servers in parallel. | 193 // Start the servers in parallel. |
194 ASSERT_TRUE(http_server.StartInBackground()); | 194 ASSERT_TRUE(http_server.StartInBackground()); |
195 ASSERT_TRUE(ssl_server.StartInBackground()); | 195 ASSERT_TRUE(ssl_server.StartInBackground()); |
196 // Wait until they are both finished before continuing. | 196 // Wait until they are both finished before continuing. |
197 ASSERT_TRUE(http_server.BlockUntilStarted()); | 197 ASSERT_TRUE(http_server.BlockUntilStarted()); |
198 ASSERT_TRUE(ssl_server.BlockUntilStarted()); | 198 ASSERT_TRUE(ssl_server.BlockUntilStarted()); |
199 | 199 |
200 uint16_t port = ssl_server.host_port_pair().port(); | 200 uint16_t port = ssl_server.host_port_pair().port(); |
201 RunTestURL(GetTestURL(http_server, | 201 RunTestURL(GetTestURL(http_server, |
202 test_case, | 202 test_case, |
203 StringPrintf("ssl_server_port=%d", port))); | 203 base::StringPrintf("ssl_server_port=%d", port))); |
204 } | 204 } |
205 | 205 |
206 void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) { | 206 void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) { |
207 base::FilePath http_document_root; | 207 base::FilePath http_document_root; |
208 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root)); | 208 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root)); |
209 net::TestServer http_server(net::TestServer::TYPE_HTTP, | 209 net::TestServer http_server(net::TestServer::TYPE_HTTP, |
210 net::TestServer::kLocalhost, | 210 net::TestServer::kLocalhost, |
211 http_document_root); | 211 http_document_root); |
212 net::TestServer ws_server(net::TestServer::TYPE_WS, | 212 net::TestServer ws_server(net::TestServer::TYPE_WS, |
213 net::TestServer::kLocalhost, | 213 net::TestServer::kLocalhost, |
214 net::GetWebSocketTestDataDirectory()); | 214 net::GetWebSocketTestDataDirectory()); |
215 // Start the servers in parallel. | 215 // Start the servers in parallel. |
216 ASSERT_TRUE(http_server.StartInBackground()); | 216 ASSERT_TRUE(http_server.StartInBackground()); |
217 ASSERT_TRUE(ws_server.StartInBackground()); | 217 ASSERT_TRUE(ws_server.StartInBackground()); |
218 // Wait until they are both finished before continuing. | 218 // Wait until they are both finished before continuing. |
219 ASSERT_TRUE(http_server.BlockUntilStarted()); | 219 ASSERT_TRUE(http_server.BlockUntilStarted()); |
220 ASSERT_TRUE(ws_server.BlockUntilStarted()); | 220 ASSERT_TRUE(ws_server.BlockUntilStarted()); |
221 | 221 |
222 std::string host = ws_server.host_port_pair().HostForURL(); | 222 std::string host = ws_server.host_port_pair().HostForURL(); |
223 uint16_t port = ws_server.host_port_pair().port(); | 223 uint16_t port = ws_server.host_port_pair().port(); |
224 RunTestURL(GetTestURL(http_server, | 224 RunTestURL(GetTestURL(http_server, |
225 test_case, | 225 test_case, |
226 StringPrintf("websocket_host=%s&websocket_port=%d", | 226 base::StringPrintf( |
227 host.c_str(), | 227 "websocket_host=%s&websocket_port=%d", |
228 port))); | 228 host.c_str(), |
| 229 port))); |
229 } | 230 } |
230 | 231 |
231 void PPAPITestBase::RunTestIfAudioOutputAvailable( | 232 void PPAPITestBase::RunTestIfAudioOutputAvailable( |
232 const std::string& test_case) { | 233 const std::string& test_case) { |
233 RunTest(test_case); | 234 RunTest(test_case); |
234 } | 235 } |
235 | 236 |
236 void PPAPITestBase::RunTestViaHTTPIfAudioOutputAvailable( | 237 void PPAPITestBase::RunTestViaHTTPIfAudioOutputAvailable( |
237 const std::string& test_case) { | 238 const std::string& test_case) { |
238 RunTestViaHTTP(test_case); | 239 RunTestViaHTTP(test_case); |
(...skipping 24 matching lines...) Expand all Loading... |
263 ASSERT_TRUE(observer.Run()) << handler.error_message(); | 264 ASSERT_TRUE(observer.Run()) << handler.error_message(); |
264 EXPECT_STREQ("PASS", handler.message().c_str()); | 265 EXPECT_STREQ("PASS", handler.message().c_str()); |
265 } | 266 } |
266 | 267 |
267 GURL PPAPITestBase::GetTestURL( | 268 GURL PPAPITestBase::GetTestURL( |
268 const net::TestServer& http_server, | 269 const net::TestServer& http_server, |
269 const std::string& test_case, | 270 const std::string& test_case, |
270 const std::string& extra_params) { | 271 const std::string& extra_params) { |
271 std::string query = BuildQuery("files/test_case.html?", test_case); | 272 std::string query = BuildQuery("files/test_case.html?", test_case); |
272 if (!extra_params.empty()) | 273 if (!extra_params.empty()) |
273 query = StringPrintf("%s&%s", query.c_str(), extra_params.c_str()); | 274 query = base::StringPrintf("%s&%s", query.c_str(), extra_params.c_str()); |
274 | 275 |
275 return http_server.GetURL(query); | 276 return http_server.GetURL(query); |
276 } | 277 } |
277 | 278 |
278 PPAPITest::PPAPITest() : in_process_(true) { | 279 PPAPITest::PPAPITest() : in_process_(true) { |
279 } | 280 } |
280 | 281 |
281 void PPAPITest::SetUpCommandLine(CommandLine* command_line) { | 282 void PPAPITest::SetUpCommandLine(CommandLine* command_line) { |
282 PPAPITestBase::SetUpCommandLine(command_line); | 283 PPAPITestBase::SetUpCommandLine(command_line); |
283 | 284 |
(...skipping 10 matching lines...) Expand all Loading... |
294 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | 295 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
295 pepper_plugin); | 296 pepper_plugin); |
296 command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1"); | 297 command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1"); |
297 | 298 |
298 if (in_process_) | 299 if (in_process_) |
299 command_line->AppendSwitch(switches::kPpapiInProcess); | 300 command_line->AppendSwitch(switches::kPpapiInProcess); |
300 } | 301 } |
301 | 302 |
302 std::string PPAPITest::BuildQuery(const std::string& base, | 303 std::string PPAPITest::BuildQuery(const std::string& base, |
303 const std::string& test_case){ | 304 const std::string& test_case){ |
304 return StringPrintf("%stestcase=%s", base.c_str(), test_case.c_str()); | 305 return base::StringPrintf("%stestcase=%s", base.c_str(), test_case.c_str()); |
305 } | 306 } |
306 | 307 |
307 OutOfProcessPPAPITest::OutOfProcessPPAPITest() { | 308 OutOfProcessPPAPITest::OutOfProcessPPAPITest() { |
308 in_process_ = false; | 309 in_process_ = false; |
309 } | 310 } |
310 | 311 |
311 void OutOfProcessPPAPITest::SetUpCommandLine(CommandLine* command_line) { | 312 void OutOfProcessPPAPITest::SetUpCommandLine(CommandLine* command_line) { |
312 PPAPITest::SetUpCommandLine(command_line); | 313 PPAPITest::SetUpCommandLine(command_line); |
313 } | 314 } |
314 | 315 |
315 void PPAPINaClTest::SetUpCommandLine(CommandLine* command_line) { | 316 void PPAPINaClTest::SetUpCommandLine(CommandLine* command_line) { |
316 PPAPITestBase::SetUpCommandLine(command_line); | 317 PPAPITestBase::SetUpCommandLine(command_line); |
317 | 318 |
318 base::FilePath plugin_lib; | 319 base::FilePath plugin_lib; |
319 EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib)); | 320 EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib)); |
320 EXPECT_TRUE(file_util::PathExists(plugin_lib)); | 321 EXPECT_TRUE(file_util::PathExists(plugin_lib)); |
321 | 322 |
322 // Enable running NaCl outside of the store. | 323 // Enable running NaCl outside of the store. |
323 command_line->AppendSwitch(switches::kEnableNaCl); | 324 command_line->AppendSwitch(switches::kEnableNaCl); |
324 command_line->AppendSwitch(switches::kEnablePnacl); | 325 command_line->AppendSwitch(switches::kEnablePnacl); |
325 command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1"); | 326 command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1"); |
326 } | 327 } |
327 | 328 |
328 // Append the correct mode and testcase string | 329 // Append the correct mode and testcase string |
329 std::string PPAPINaClNewlibTest::BuildQuery(const std::string& base, | 330 std::string PPAPINaClNewlibTest::BuildQuery(const std::string& base, |
330 const std::string& test_case) { | 331 const std::string& test_case) { |
331 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), | 332 return base::StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), |
332 test_case.c_str()); | 333 test_case.c_str()); |
333 } | 334 } |
334 | 335 |
335 // Append the correct mode and testcase string | 336 // Append the correct mode and testcase string |
336 std::string PPAPINaClGLibcTest::BuildQuery(const std::string& base, | 337 std::string PPAPINaClGLibcTest::BuildQuery(const std::string& base, |
337 const std::string& test_case) { | 338 const std::string& test_case) { |
338 return StringPrintf("%smode=nacl_glibc&testcase=%s", base.c_str(), | 339 return base::StringPrintf("%smode=nacl_glibc&testcase=%s", base.c_str(), |
339 test_case.c_str()); | 340 test_case.c_str()); |
340 } | 341 } |
341 | 342 |
342 // Append the correct mode and testcase string | 343 // Append the correct mode and testcase string |
343 std::string PPAPINaClPNaClTest::BuildQuery(const std::string& base, | 344 std::string PPAPINaClPNaClTest::BuildQuery(const std::string& base, |
344 const std::string& test_case) { | 345 const std::string& test_case) { |
345 return StringPrintf("%smode=nacl_pnacl&testcase=%s", base.c_str(), | 346 return base::StringPrintf("%smode=nacl_pnacl&testcase=%s", base.c_str(), |
346 test_case.c_str()); | 347 test_case.c_str()); |
347 } | 348 } |
348 | 349 |
349 void PPAPINaClTestDisallowedSockets::SetUpCommandLine( | 350 void PPAPINaClTestDisallowedSockets::SetUpCommandLine( |
350 CommandLine* command_line) { | 351 CommandLine* command_line) { |
351 PPAPITestBase::SetUpCommandLine(command_line); | 352 PPAPITestBase::SetUpCommandLine(command_line); |
352 | 353 |
353 base::FilePath plugin_lib; | 354 base::FilePath plugin_lib; |
354 EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib)); | 355 EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib)); |
355 EXPECT_TRUE(file_util::PathExists(plugin_lib)); | 356 EXPECT_TRUE(file_util::PathExists(plugin_lib)); |
356 | 357 |
357 // Enable running NaCl outside of the store. | 358 // Enable running NaCl outside of the store. |
358 command_line->AppendSwitch(switches::kEnableNaCl); | 359 command_line->AppendSwitch(switches::kEnableNaCl); |
359 command_line->AppendSwitch(switches::kEnablePnacl); | 360 command_line->AppendSwitch(switches::kEnablePnacl); |
360 } | 361 } |
361 | 362 |
362 // Append the correct mode and testcase string | 363 // Append the correct mode and testcase string |
363 std::string PPAPINaClTestDisallowedSockets::BuildQuery( | 364 std::string PPAPINaClTestDisallowedSockets::BuildQuery( |
364 const std::string& base, | 365 const std::string& base, |
365 const std::string& test_case) { | 366 const std::string& test_case) { |
366 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), | 367 return base::StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), |
367 test_case.c_str()); | 368 test_case.c_str()); |
368 } | 369 } |
369 | 370 |
370 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() { | 371 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() { |
371 // The default content setting for the PPAPI broker is ASK. We purposefully | 372 // The default content setting for the PPAPI broker is ASK. We purposefully |
372 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way. | 373 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way. |
373 } | 374 } |
OLD | NEW |