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