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
3 // found in the LICENSE file.
5 #include "content/public/test/ppapi_test_utils.h"
7 #include "base/command_line.h"
8 #include "base/files/file_util.h"
9 #include "base/macros.h"
10 #include "base/path_service.h"
11 #include "content/public/common/content_switches.h"
15 std::string
StripTestPrefixes(const std::string
& test_name
) {
16 if (test_name
.find("DISABLED_") == 0)
17 return test_name
.substr(strlen("DISABLED_"));
21 bool RegisterTestPlugin(base::CommandLine
* command_line
) {
22 return RegisterTestPluginWithExtraParameters(command_line
,
23 FILE_PATH_LITERAL(""));
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
))
34 base::FilePath plugin_path
= plugin_dir
.Append(L
"ppapi_tests.dll");
35 #elif defined(OS_MACOSX)
36 base::FilePath plugin_path
= plugin_dir
.Append("ppapi_tests.plugin");
37 #elif defined(OS_POSIX)
38 base::FilePath plugin_path
= plugin_dir
.Append("libppapi_tests.so");
41 // Append the switch to register the pepper plugin.
42 if (!base::PathExists(plugin_path
))
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
,