Index: content/public/test/ppapi_test_utils.cc |
diff --git a/ppapi/shared_impl/test_harness_utils.cc b/content/public/test/ppapi_test_utils.cc |
similarity index 22% |
rename from ppapi/shared_impl/test_harness_utils.cc |
rename to content/public/test/ppapi_test_utils.cc |
index 93ba755c958d6af6a0b47d12b58c5f0e9e3ff5b8..5717edabf76175c1872b99e9af68bd1111ed7be6 100644 |
--- a/ppapi/shared_impl/test_harness_utils.cc |
+++ b/content/public/test/ppapi_test_utils.cc |
@@ -2,30 +2,51 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "ppapi/shared_impl/test_harness_utils.h" |
+#include "content/public/test/ppapi_test_utils.h" |
-#include <string> |
+#include "base/command_line.h" |
+#include "base/files/file_util.h" |
#include "base/macros.h" |
+#include "base/path_service.h" |
+#include "content/public/common/content_switches.h" |
namespace ppapi { |
std::string StripTestPrefixes(const std::string& test_name) { |
- const char* const kTestPrefixes[] = { |
- "FAILS_", "FLAKY_", "DISABLED_", "SLOW_" }; |
- for (size_t i = 0; i < arraysize(kTestPrefixes); ++i) |
- if (test_name.find(kTestPrefixes[i]) == 0) |
- return test_name.substr(strlen(kTestPrefixes[i])); |
+ if (test_name.find("DISABLED_") == 0) |
+ return test_name.substr(strlen("DISABLED_")); |
return test_name; |
} |
-base::FilePath::StringType GetTestLibraryName() { |
+bool RegisterTestPlugin(base::CommandLine* command_line) { |
+ return RegisterTestPluginWithExtraParameters(command_line, |
+ FILE_PATH_LITERAL("")); |
+} |
+ |
+bool RegisterTestPluginWithExtraParameters( |
+ base::CommandLine* command_line, |
+ const base::FilePath::StringType& extra_registration_parameters) { |
+ base::FilePath plugin_dir; |
+ if (!PathService::Get(base::DIR_MODULE, &plugin_dir)) |
+ return false; |
+ |
#if defined(OS_WIN) |
- return L"ppapi_tests.dll"; |
+ base::FilePath plugin_path = plugin_dir.Append(L"ppapi_tests.dll"); |
#elif defined(OS_MACOSX) |
- return "ppapi_tests.plugin"; |
+ base::FilePath plugin_path = plugin_dir.Append("ppapi_tests.plugin"); |
#elif defined(OS_POSIX) |
- return "libppapi_tests.so"; |
+ base::FilePath plugin_path = plugin_dir.Append("libppapi_tests.so"); |
#endif |
+ |
+ // Append the switch to register the pepper plugin. |
+ if (!base::PathExists(plugin_path)) |
+ return false; |
+ base::FilePath::StringType pepper_plugin = plugin_path.value(); |
+ pepper_plugin.append(extra_registration_parameters); |
+ pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests")); |
+ command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
+ pepper_plugin); |
+ return true; |
} |
} // namespace ppapi |