OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ppapi/shared_impl/test_harness_utils.h" | 5 #include "content/public/test/ppapi_test_utils.h" |
6 | 6 |
7 #include <string> | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" |
8 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" |
| 11 #include "content/public/common/content_switches.h" |
9 | 12 |
10 namespace ppapi { | 13 namespace ppapi { |
11 | 14 |
12 std::string StripTestPrefixes(const std::string& test_name) { | 15 std::string StripTestPrefixes(const std::string& test_name) { |
13 const char* const kTestPrefixes[] = { | 16 if (test_name.find("DISABLED_") == 0) |
14 "FAILS_", "FLAKY_", "DISABLED_", "SLOW_" }; | 17 return test_name.substr(strlen("DISABLED_")); |
15 for (size_t i = 0; i < arraysize(kTestPrefixes); ++i) | |
16 if (test_name.find(kTestPrefixes[i]) == 0) | |
17 return test_name.substr(strlen(kTestPrefixes[i])); | |
18 return test_name; | 18 return test_name; |
19 } | 19 } |
20 | 20 |
21 base::FilePath::StringType GetTestLibraryName() { | 21 bool RegisterTestPlugin(base::CommandLine* command_line) { |
| 22 return RegisterTestPluginWithExtraParameters(command_line, |
| 23 FILE_PATH_LITERAL("")); |
| 24 } |
| 25 |
| 26 bool RegisterTestPluginWithExtraParameters( |
| 27 base::CommandLine* command_line, |
| 28 const base::FilePath::StringType& extra_registration_parameters) { |
| 29 base::FilePath plugin_dir; |
| 30 if (!PathService::Get(base::DIR_MODULE, &plugin_dir)) |
| 31 return false; |
| 32 |
22 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
23 return L"ppapi_tests.dll"; | 34 base::FilePath plugin_path = plugin_dir.Append(L"ppapi_tests.dll"); |
24 #elif defined(OS_MACOSX) | 35 #elif defined(OS_MACOSX) |
25 return "ppapi_tests.plugin"; | 36 base::FilePath plugin_path = plugin_dir.Append("ppapi_tests.plugin"); |
26 #elif defined(OS_POSIX) | 37 #elif defined(OS_POSIX) |
27 return "libppapi_tests.so"; | 38 base::FilePath plugin_path = plugin_dir.Append("libppapi_tests.so"); |
28 #endif | 39 #endif |
| 40 |
| 41 // Append the switch to register the pepper plugin. |
| 42 if (!base::PathExists(plugin_path)) |
| 43 return false; |
| 44 base::FilePath::StringType pepper_plugin = plugin_path.value(); |
| 45 pepper_plugin.append(extra_registration_parameters); |
| 46 pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests")); |
| 47 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
| 48 pepper_plugin); |
| 49 return true; |
29 } | 50 } |
30 | 51 |
31 } // namespace ppapi | 52 } // namespace ppapi |
OLD | NEW |