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