Chromium Code Reviews| Index: content/public/test/ppapi_test_utils.cc |
| diff --git a/content/public/test/ppapi_test_utils.cc b/content/public/test/ppapi_test_utils.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ab52ceca4ca40ac27c368842135737d7783bed92 |
| --- /dev/null |
| +++ b/content/public/test/ppapi_test_utils.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/public/test/ppapi_test_utils.h" |
| + |
| +#include "base/command_line.h" |
| +#include "base/files/file_util.h" |
| +#include "base/macros.h" |
| +#include "base/path_service.h" |
| +#include "content/public/common/content_switches.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace ppapi { |
| + |
| +std::string StripTestPrefixes(const std::string& test_name) { |
| + const char* const kTestPrefixes[] = { |
| + "FAILS_", "FLAKY_", "DISABLED_", "SLOW_"}; |
|
Paweł Hajdan Jr.
2015/04/16 21:36:18
Why is this needed? Only DISABLED_ is a valid pref
tommycli
2015/04/16 22:18:51
Done. In the latest patch, these lines are untouch
tommycli
2015/04/16 23:35:42
This is the same as the file I moved it from.
Paweł Hajdan Jr.
2015/04/17 01:38:01
Even if it's just a move, I'd like to keep content
tommycli
2015/04/17 20:02:14
Done.
|
| + for (size_t i = 0; i < arraysize(kTestPrefixes); ++i) |
| + if (test_name.find(kTestPrefixes[i]) == 0) |
| + return test_name.substr(strlen(kTestPrefixes[i])); |
| + return test_name; |
| +} |
| + |
| +void RegisterTestPlugin(base::CommandLine* command_line) { |
| + RegisterTestPluginWithExtraParameters(command_line, FILE_PATH_LITERAL("")); |
| +} |
| + |
| +void RegisterTestPluginWithExtraParameters( |
|
Paweł Hajdan Jr.
2015/04/16 21:36:18
Shouldn't this return bool so that callers can bai
tommycli
2015/04/16 22:18:51
Done.
|
| + base::CommandLine* command_line, |
| + const base::FilePath::StringType& extra_registration_parameters) { |
| + base::FilePath plugin_dir; |
| + EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); |
| + |
| +#if defined(OS_WIN) |
| + base::FilePath plugin_path = plugin_dir.Append(L"ppapi_tests.dll"); |
| +#elif defined(OS_MACOSX) |
| + base::FilePath plugin_path = plugin_dir.Append("ppapi_tests.plugin"); |
| +#elif defined(OS_POSIX) |
| + base::FilePath plugin_path = plugin_dir.Append("libppapi_tests.so"); |
| +#endif |
| + |
| + // Append the switch to register the pepper plugin. |
| + EXPECT_TRUE(base::PathExists(plugin_path)); |
| + base::FilePath::StringType pepper_plugin = plugin_path.value(); |
| + pepper_plugin.append(extra_registration_parameters); |
| + pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests")); |
| + command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
| + pepper_plugin); |
| +} |
| + |
| +} // namespace ppapi |