Index: content/public/test/ppapi_test_utils.cc |
diff --git a/content/public/test/ppapi_test_utils.cc b/content/public/test/ppapi_test_utils.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..87165f5371caefdbc01636923630ffa9113aa967 |
--- /dev/null |
+++ b/content/public/test/ppapi_test_utils.cc |
@@ -0,0 +1,53 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/public/test/ppapi_test_utils.h" |
+ |
+#include <string> |
raymes
2015/04/15 06:44:18
nit: space below this line
tommycli
2015/04/15 18:23:18
Done.
|
+#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" |
+#include "testing/gtest/include/gtest/gtest.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])); |
+ return test_name; |
+} |
+ |
+void RegisterTestLibrary(base::CommandLine* command_line) { |
+ RegisterTestLibraryWithExtraParameters(command_line, FILE_PATH_LITERAL("")); |
+} |
+ |
+void RegisterTestLibraryWithExtraParameters( |
+ base::CommandLine* command_line, |
+ const base::FilePath::StringType& extra_registration_parameters) { |
+ base::FilePath plugin_dir; |
+ EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); |
+ |
+#if defined(OS_WIN) |
+ base::FilePath plugin_path = plugin_dir.Append(L"ppapi_tests.dll"); |
+#elif defined(OS_MACOSX) |
+ base::FilePath plugin_path = plugin_dir.Append("ppapi_tests.plugin"); |
+#elif defined(OS_POSIX) |
+ base::FilePath plugin_path = plugin_dir.Append("libppapi_tests.so"); |
+#endif |
+ |
+ // Append the switch to register the pepper plugin. |
+ EXPECT_TRUE(base::PathExists(plugin_path)); |
+ 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); |
+} |
+ |
+} // namespace ppapi |