Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / public / test / ppapi_test_utils.cc
blob0c9e5455c26ebe65a8d84fe06b01dc17634e51c4
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"
12 #include "ppapi/shared_impl/ppapi_constants.h"
14 namespace ppapi {
16 namespace {
18 bool RegisterPlugin(
19 base::CommandLine* command_line,
20 const base::FilePath::StringType& library_name,
21 const base::FilePath::StringType& extra_registration_parameters) {
22 base::FilePath plugin_dir;
23 if (!PathService::Get(base::DIR_MODULE, &plugin_dir))
24 return false;
26 base::FilePath plugin_path = plugin_dir.Append(library_name);
28 // Append the switch to register the pepper plugin.
29 if (!base::PathExists(plugin_path))
30 return false;
31 base::FilePath::StringType pepper_plugin = plugin_path.value();
32 pepper_plugin.append(extra_registration_parameters);
33 pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests"));
34 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
35 pepper_plugin);
36 return true;
39 } // namespace
41 bool RegisterTestPlugin(base::CommandLine* command_line) {
42 return RegisterTestPluginWithExtraParameters(command_line,
43 FILE_PATH_LITERAL(""));
46 bool RegisterTestPluginWithExtraParameters(
47 base::CommandLine* command_line,
48 const base::FilePath::StringType& extra_registration_parameters) {
49 #if defined(OS_WIN)
50 base::FilePath::StringType plugin_library = L"ppapi_tests.dll";
51 #elif defined(OS_MACOSX)
52 base::FilePath::StringType plugin_library = "ppapi_tests.plugin";
53 #elif defined(OS_POSIX)
54 base::FilePath::StringType plugin_library = "libppapi_tests.so";
55 #endif
56 return RegisterPlugin(command_line, plugin_library,
57 extra_registration_parameters);
60 bool RegisterPowerSaverTestPlugin(base::CommandLine* command_line) {
61 base::FilePath::StringType library_name =
62 base::FilePath::FromUTF8Unsafe(ppapi::kPowerSaverTestPluginName).value();
63 return RegisterPlugin(command_line, library_name, FILE_PATH_LITERAL(""));
66 } // namespace ppapi