| 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/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 // Platform-specific filename relative to the chrome executable. | 44 // Platform-specific filename relative to the chrome executable. |
| 45 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 46 const wchar_t library_name[] = L"ppapi_tests.dll"; | 46 const wchar_t library_name[] = L"ppapi_tests.dll"; |
| 47 #elif defined(OS_MACOSX) | 47 #elif defined(OS_MACOSX) |
| 48 const char library_name[] = "ppapi_tests.plugin"; | 48 const char library_name[] = "ppapi_tests.plugin"; |
| 49 #elif defined(OS_POSIX) | 49 #elif defined(OS_POSIX) |
| 50 const char library_name[] = "libppapi_tests.so"; | 50 const char library_name[] = "libppapi_tests.so"; |
| 51 #endif | 51 #endif |
| 52 | 52 |
| 53 void AddPrivateSwitches(CommandLine* command_line) { | 53 void AddPrivateSwitches(base::CommandLine* command_line) { |
| 54 // For TestRequestOSFileHandle. | 54 // For TestRequestOSFileHandle. |
| 55 command_line->AppendSwitch(switches::kUnlimitedStorage); | 55 command_line->AppendSwitch(switches::kUnlimitedStorage); |
| 56 command_line->AppendSwitchASCII(switches::kAllowNaClFileHandleAPI, | 56 command_line->AppendSwitchASCII(switches::kAllowNaClFileHandleAPI, |
| 57 "127.0.0.1"); | 57 "127.0.0.1"); |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| 62 PPAPITestMessageHandler::PPAPITestMessageHandler() { | 62 PPAPITestMessageHandler::PPAPITestMessageHandler() { |
| 63 } | 63 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 | 136 |
| 137 PPAPITestBase::PPAPITestBase() { | 137 PPAPITestBase::PPAPITestBase() { |
| 138 } | 138 } |
| 139 | 139 |
| 140 void PPAPITestBase::SetUp() { | 140 void PPAPITestBase::SetUp() { |
| 141 EnablePixelOutput(); | 141 EnablePixelOutput(); |
| 142 InProcessBrowserTest::SetUp(); | 142 InProcessBrowserTest::SetUp(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void PPAPITestBase::SetUpCommandLine(CommandLine* command_line) { | 145 void PPAPITestBase::SetUpCommandLine(base::CommandLine* command_line) { |
| 146 // The test sends us the result via a cookie. | 146 // The test sends us the result via a cookie. |
| 147 command_line->AppendSwitch(switches::kEnableFileCookies); | 147 command_line->AppendSwitch(switches::kEnableFileCookies); |
| 148 | 148 |
| 149 // Some stuff is hung off of the testing interface which is not enabled | 149 // Some stuff is hung off of the testing interface which is not enabled |
| 150 // by default. | 150 // by default. |
| 151 command_line->AppendSwitch(switches::kEnablePepperTesting); | 151 command_line->AppendSwitch(switches::kEnablePepperTesting); |
| 152 | 152 |
| 153 // Smooth scrolling confuses the scrollbar test. | 153 // Smooth scrolling confuses the scrollbar test. |
| 154 command_line->AppendSwitch(switches::kDisableSmoothScrolling); | 154 command_line->AppendSwitch(switches::kDisableSmoothScrolling); |
| 155 } | 155 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 "FAILS_", "FLAKY_", "DISABLED_", "SLOW_" }; | 265 "FAILS_", "FLAKY_", "DISABLED_", "SLOW_" }; |
| 266 for (size_t i = 0; i < sizeof(prefixes)/sizeof(prefixes[0]); ++i) | 266 for (size_t i = 0; i < sizeof(prefixes)/sizeof(prefixes[0]); ++i) |
| 267 if (test_name.find(prefixes[i]) == 0) | 267 if (test_name.find(prefixes[i]) == 0) |
| 268 return test_name.substr(strlen(prefixes[i])); | 268 return test_name.substr(strlen(prefixes[i])); |
| 269 return test_name; | 269 return test_name; |
| 270 } | 270 } |
| 271 | 271 |
| 272 void PPAPITestBase::RunTestURL(const GURL& test_url) { | 272 void PPAPITestBase::RunTestURL(const GURL& test_url) { |
| 273 #if defined(OS_WIN) && defined(USE_ASH) | 273 #if defined(OS_WIN) && defined(USE_ASH) |
| 274 // PPAPITests are broken in Ash browser tests (http://crbug.com/263548). | 274 // PPAPITests are broken in Ash browser tests (http://crbug.com/263548). |
| 275 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) { | 275 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 276 switches::kAshBrowserTests)) { |
| 276 LOG(WARNING) << "PPAPITests are disabled for Ash browser tests."; | 277 LOG(WARNING) << "PPAPITests are disabled for Ash browser tests."; |
| 277 return; | 278 return; |
| 278 } | 279 } |
| 279 #endif | 280 #endif |
| 280 | 281 |
| 281 // See comment above TestingInstance in ppapi/test/testing_instance.h. | 282 // See comment above TestingInstance in ppapi/test/testing_instance.h. |
| 282 // Basically it sends messages using the DOM automation controller. The | 283 // Basically it sends messages using the DOM automation controller. The |
| 283 // value of "..." means it's still working and we should continue to wait, | 284 // value of "..." means it's still working and we should continue to wait, |
| 284 // any other value indicates completion (in this case it will start with | 285 // any other value indicates completion (in this case it will start with |
| 285 // "PASS" or "FAIL"). This keeps us from timing out on waits for long tests. | 286 // "PASS" or "FAIL"). This keeps us from timing out on waits for long tests. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 301 std::string query = BuildQuery("files/test_case.html?", test_case); | 302 std::string query = BuildQuery("files/test_case.html?", test_case); |
| 302 if (!extra_params.empty()) | 303 if (!extra_params.empty()) |
| 303 query = base::StringPrintf("%s&%s", query.c_str(), extra_params.c_str()); | 304 query = base::StringPrintf("%s&%s", query.c_str(), extra_params.c_str()); |
| 304 | 305 |
| 305 return http_server.GetURL(query); | 306 return http_server.GetURL(query); |
| 306 } | 307 } |
| 307 | 308 |
| 308 PPAPITest::PPAPITest() : in_process_(true) { | 309 PPAPITest::PPAPITest() : in_process_(true) { |
| 309 } | 310 } |
| 310 | 311 |
| 311 void PPAPITest::SetUpCommandLine(CommandLine* command_line) { | 312 void PPAPITest::SetUpCommandLine(base::CommandLine* command_line) { |
| 312 PPAPITestBase::SetUpCommandLine(command_line); | 313 PPAPITestBase::SetUpCommandLine(command_line); |
| 313 | 314 |
| 314 // Append the switch to register the pepper plugin. | 315 // Append the switch to register the pepper plugin. |
| 315 // library name = <out dir>/<test_name>.<library_extension> | 316 // library name = <out dir>/<test_name>.<library_extension> |
| 316 // MIME type = application/x-ppapi-<test_name> | 317 // MIME type = application/x-ppapi-<test_name> |
| 317 base::FilePath plugin_dir; | 318 base::FilePath plugin_dir; |
| 318 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); | 319 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); |
| 319 | 320 |
| 320 base::FilePath plugin_lib = plugin_dir.Append(library_name); | 321 base::FilePath plugin_lib = plugin_dir.Append(library_name); |
| 321 EXPECT_TRUE(base::PathExists(plugin_lib)); | 322 EXPECT_TRUE(base::PathExists(plugin_lib)); |
| 322 base::FilePath::StringType pepper_plugin = plugin_lib.value(); | 323 base::FilePath::StringType pepper_plugin = plugin_lib.value(); |
| 323 pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests")); | 324 pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests")); |
| 324 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | 325 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
| 325 pepper_plugin); | 326 pepper_plugin); |
| 326 command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1"); | 327 command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1"); |
| 327 | 328 |
| 328 if (in_process_) | 329 if (in_process_) |
| 329 command_line->AppendSwitch(switches::kPpapiInProcess); | 330 command_line->AppendSwitch(switches::kPpapiInProcess); |
| 330 } | 331 } |
| 331 | 332 |
| 332 std::string PPAPITest::BuildQuery(const std::string& base, | 333 std::string PPAPITest::BuildQuery(const std::string& base, |
| 333 const std::string& test_case){ | 334 const std::string& test_case){ |
| 334 return base::StringPrintf("%stestcase=%s", base.c_str(), test_case.c_str()); | 335 return base::StringPrintf("%stestcase=%s", base.c_str(), test_case.c_str()); |
| 335 } | 336 } |
| 336 | 337 |
| 337 void PPAPIPrivateTest::SetUpCommandLine(CommandLine* command_line) { | 338 void PPAPIPrivateTest::SetUpCommandLine(base::CommandLine* command_line) { |
| 338 PPAPITest::SetUpCommandLine(command_line); | 339 PPAPITest::SetUpCommandLine(command_line); |
| 339 AddPrivateSwitches(command_line); | 340 AddPrivateSwitches(command_line); |
| 340 } | 341 } |
| 341 | 342 |
| 342 OutOfProcessPPAPITest::OutOfProcessPPAPITest() { | 343 OutOfProcessPPAPITest::OutOfProcessPPAPITest() { |
| 343 in_process_ = false; | 344 in_process_ = false; |
| 344 } | 345 } |
| 345 | 346 |
| 346 void OutOfProcessPPAPITest::SetUpCommandLine(CommandLine* command_line) { | 347 void OutOfProcessPPAPITest::SetUpCommandLine(base::CommandLine* command_line) { |
| 347 PPAPITest::SetUpCommandLine(command_line); | 348 PPAPITest::SetUpCommandLine(command_line); |
| 348 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 349 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
| 349 command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); | 350 command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); |
| 350 } | 351 } |
| 351 | 352 |
| 352 void OutOfProcessPPAPIPrivateTest::SetUpCommandLine(CommandLine* command_line) { | 353 void OutOfProcessPPAPIPrivateTest::SetUpCommandLine( |
| 354 base::CommandLine* command_line) { |
| 353 OutOfProcessPPAPITest::SetUpCommandLine(command_line); | 355 OutOfProcessPPAPITest::SetUpCommandLine(command_line); |
| 354 AddPrivateSwitches(command_line); | 356 AddPrivateSwitches(command_line); |
| 355 } | 357 } |
| 356 | 358 |
| 357 void PPAPINaClTest::SetUpCommandLine(CommandLine* command_line) { | 359 void PPAPINaClTest::SetUpCommandLine(base::CommandLine* command_line) { |
| 358 RETURN_IF_NO_NACL(); | 360 RETURN_IF_NO_NACL(); |
| 359 PPAPITestBase::SetUpCommandLine(command_line); | 361 PPAPITestBase::SetUpCommandLine(command_line); |
| 360 | 362 |
| 361 base::FilePath plugin_lib; | 363 base::FilePath plugin_lib; |
| 362 EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib)); | 364 EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib)); |
| 363 EXPECT_TRUE(base::PathExists(plugin_lib)); | 365 EXPECT_TRUE(base::PathExists(plugin_lib)); |
| 364 | 366 |
| 365 // Enable running (non-portable) NaCl outside of the Chrome web store. | 367 // Enable running (non-portable) NaCl outside of the Chrome web store. |
| 366 command_line->AppendSwitch(switches::kEnableNaCl); | 368 command_line->AppendSwitch(switches::kEnableNaCl); |
| 367 command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1"); | 369 command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1"); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 PPAPITestBase::RunTestViaHTTPIfAudioOutputAvailable(test_case); | 408 PPAPITestBase::RunTestViaHTTPIfAudioOutputAvailable(test_case); |
| 407 } | 409 } |
| 408 | 410 |
| 409 // Append the correct mode and testcase string | 411 // Append the correct mode and testcase string |
| 410 std::string PPAPINaClNewlibTest::BuildQuery(const std::string& base, | 412 std::string PPAPINaClNewlibTest::BuildQuery(const std::string& base, |
| 411 const std::string& test_case) { | 413 const std::string& test_case) { |
| 412 return base::StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), | 414 return base::StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), |
| 413 test_case.c_str()); | 415 test_case.c_str()); |
| 414 } | 416 } |
| 415 | 417 |
| 416 void PPAPIPrivateNaClNewlibTest::SetUpCommandLine(CommandLine* command_line) { | 418 void PPAPIPrivateNaClNewlibTest::SetUpCommandLine( |
| 419 base::CommandLine* command_line) { |
| 417 PPAPINaClNewlibTest::SetUpCommandLine(command_line); | 420 PPAPINaClNewlibTest::SetUpCommandLine(command_line); |
| 418 AddPrivateSwitches(command_line); | 421 AddPrivateSwitches(command_line); |
| 419 } | 422 } |
| 420 | 423 |
| 421 // Append the correct mode and testcase string | 424 // Append the correct mode and testcase string |
| 422 std::string PPAPINaClGLibcTest::BuildQuery(const std::string& base, | 425 std::string PPAPINaClGLibcTest::BuildQuery(const std::string& base, |
| 423 const std::string& test_case) { | 426 const std::string& test_case) { |
| 424 return base::StringPrintf("%smode=nacl_glibc&testcase=%s", base.c_str(), | 427 return base::StringPrintf("%smode=nacl_glibc&testcase=%s", base.c_str(), |
| 425 test_case.c_str()); | 428 test_case.c_str()); |
| 426 } | 429 } |
| 427 | 430 |
| 428 void PPAPIPrivateNaClGLibcTest::SetUpCommandLine(CommandLine* command_line) { | 431 void PPAPIPrivateNaClGLibcTest::SetUpCommandLine( |
| 432 base::CommandLine* command_line) { |
| 429 PPAPINaClGLibcTest::SetUpCommandLine(command_line); | 433 PPAPINaClGLibcTest::SetUpCommandLine(command_line); |
| 430 AddPrivateSwitches(command_line); | 434 AddPrivateSwitches(command_line); |
| 431 } | 435 } |
| 432 | 436 |
| 433 // Append the correct mode and testcase string | 437 // Append the correct mode and testcase string |
| 434 std::string PPAPINaClPNaClTest::BuildQuery(const std::string& base, | 438 std::string PPAPINaClPNaClTest::BuildQuery(const std::string& base, |
| 435 const std::string& test_case) { | 439 const std::string& test_case) { |
| 436 return base::StringPrintf("%smode=nacl_pnacl&testcase=%s", base.c_str(), | 440 return base::StringPrintf("%smode=nacl_pnacl&testcase=%s", base.c_str(), |
| 437 test_case.c_str()); | 441 test_case.c_str()); |
| 438 } | 442 } |
| 439 | 443 |
| 440 void PPAPIPrivateNaClPNaClTest::SetUpCommandLine(CommandLine* command_line) { | 444 void PPAPIPrivateNaClPNaClTest::SetUpCommandLine( |
| 445 base::CommandLine* command_line) { |
| 441 PPAPINaClPNaClTest::SetUpCommandLine(command_line); | 446 PPAPINaClPNaClTest::SetUpCommandLine(command_line); |
| 442 AddPrivateSwitches(command_line); | 447 AddPrivateSwitches(command_line); |
| 443 } | 448 } |
| 444 | 449 |
| 445 void PPAPINaClTestDisallowedSockets::SetUpCommandLine( | 450 void PPAPINaClTestDisallowedSockets::SetUpCommandLine( |
| 446 CommandLine* command_line) { | 451 base::CommandLine* command_line) { |
| 447 PPAPITestBase::SetUpCommandLine(command_line); | 452 PPAPITestBase::SetUpCommandLine(command_line); |
| 448 | 453 |
| 449 base::FilePath plugin_lib; | 454 base::FilePath plugin_lib; |
| 450 EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib)); | 455 EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib)); |
| 451 EXPECT_TRUE(base::PathExists(plugin_lib)); | 456 EXPECT_TRUE(base::PathExists(plugin_lib)); |
| 452 | 457 |
| 453 // Enable running (non-portable) NaCl outside of the Chrome web store. | 458 // Enable running (non-portable) NaCl outside of the Chrome web store. |
| 454 command_line->AppendSwitch(switches::kEnableNaCl); | 459 command_line->AppendSwitch(switches::kEnableNaCl); |
| 455 } | 460 } |
| 456 | 461 |
| 457 // Append the correct mode and testcase string | 462 // Append the correct mode and testcase string |
| 458 std::string PPAPINaClTestDisallowedSockets::BuildQuery( | 463 std::string PPAPINaClTestDisallowedSockets::BuildQuery( |
| 459 const std::string& base, | 464 const std::string& base, |
| 460 const std::string& test_case) { | 465 const std::string& test_case) { |
| 461 return base::StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), | 466 return base::StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), |
| 462 test_case.c_str()); | 467 test_case.c_str()); |
| 463 } | 468 } |
| 464 | 469 |
| 465 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() { | 470 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() { |
| 466 // The default content setting for the PPAPI broker is ASK. We purposefully | 471 // The default content setting for the PPAPI broker is ASK. We purposefully |
| 467 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way. | 472 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way. |
| 468 } | 473 } |
| OLD | NEW |