Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / public / test / ppapi_test_utils.cc
blob5717edabf76175c1872b99e9af68bd1111ed7be6
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"
13 namespace ppapi {
15 std::string StripTestPrefixes(const std::string& test_name) {
16 if (test_name.find("DISABLED_") == 0)
17 return test_name.substr(strlen("DISABLED_"));
18 return test_name;
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))
31 return false;
33 #if defined(OS_WIN)
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");
39 #endif
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;
52 } // namespace ppapi