| Index: components/task_scheduler_util/common/variations_util_unittest.cc
|
| diff --git a/components/task_scheduler_util/common/variations_util_unittest.cc b/components/task_scheduler_util/common/variations_util_unittest.cc
|
| index 386d0b0163c0b015ab572786c6db4299302f3985..7376cba09214b4ab0978cad8f0159d77a8413e05 100644
|
| --- a/components/task_scheduler_util/common/variations_util_unittest.cc
|
| +++ b/components/task_scheduler_util/common/variations_util_unittest.cc
|
| @@ -8,6 +8,7 @@
|
| #include <string>
|
| #include <vector>
|
|
|
| +#include "base/command_line.h"
|
| #include "base/task_scheduler/scheduler_worker_pool_params.h"
|
| #include "base/threading/platform_thread.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -20,6 +21,9 @@ using StandbyThreadPolicy =
|
| base::SchedulerWorkerPoolParams::StandbyThreadPolicy;
|
| using ThreadPriority = base::ThreadPriority;
|
|
|
| +constexpr char kTaskSchedulerVariationParamsSwitch[] =
|
| + "task-scheduler-variation-params";
|
| +
|
| std::vector<SchedulerImmutableWorkerPoolParams> GetImmutableWorkerPoolParams() {
|
| std::vector<SchedulerImmutableWorkerPoolParams> constant_worker_pool_params;
|
| constant_worker_pool_params.emplace_back("Background",
|
| @@ -145,4 +149,65 @@ TEST(TaskSchedulerUtilVariationsUtilTest, InvalidParameters) {
|
| .empty());
|
| }
|
|
|
| +TEST(TaskSchedulerUtilVariationsUtilTest, CommandLine) {
|
| + std::map<std::string, std::string> in_variation_params;
|
| + in_variation_params["PrefixFoo"] = "Foo";
|
| + in_variation_params["PrefixBar"] = "Bar";
|
| + in_variation_params["NoPrefix"] = "NoPrefix";
|
| +
|
| + base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
|
| + AddVariationParamsToCommandLine(in_variation_params, "Prefix", &command_line);
|
| + const std::map<std::string, std::string> out_variation_params =
|
| + GetVariationParamsFromCommandLine(command_line);
|
| +
|
| + std::map<std::string, std::string> expected_out_variation_params;
|
| + expected_out_variation_params["PrefixFoo"] = "Foo";
|
| + expected_out_variation_params["PrefixBar"] = "Bar";
|
| + EXPECT_EQ(expected_out_variation_params, out_variation_params);
|
| +}
|
| +
|
| +TEST(TaskSchedulerUtilVariationsUtilTest,
|
| + CommandLineSeparatorInVariationParamsKey) {
|
| + std::map<std::string, std::string> in_variation_params;
|
| + in_variation_params["PrefixFoo"] = "Foo";
|
| + in_variation_params["PrefixKey|"] = "Value";
|
| +
|
| + base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
|
| + AddVariationParamsToCommandLine(in_variation_params, "Prefix", &command_line);
|
| + EXPECT_TRUE(
|
| + command_line.GetSwitchValueASCII(kTaskSchedulerVariationParamsSwitch)
|
| + .empty());
|
| +}
|
| +
|
| +TEST(TaskSchedulerUtilVariationsUtilTest,
|
| + CommandLineSeparatorInVariationParamsValue) {
|
| + std::map<std::string, std::string> in_variation_params;
|
| + in_variation_params["PrefixFoo"] = "Foo";
|
| + in_variation_params["PrefixKey"] = "Value|";
|
| +
|
| + base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
|
| + AddVariationParamsToCommandLine(in_variation_params, "Prefix", &command_line);
|
| + EXPECT_TRUE(
|
| + command_line.GetSwitchValueASCII(kTaskSchedulerVariationParamsSwitch)
|
| + .empty());
|
| +}
|
| +
|
| +TEST(TaskSchedulerUtilVariationsUtilTest, CommandLineInvalidSwitch) {
|
| + base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
|
| + command_line.AppendSwitchASCII(kTaskSchedulerVariationParamsSwitch,
|
| + "one|two|three");
|
| + EXPECT_TRUE(GetVariationParamsFromCommandLine(command_line).empty());
|
| +}
|
| +
|
| +TEST(TaskSchedulerUtilVariationsUtilTest, CommandLineEmptySwitch) {
|
| + base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
|
| + command_line.AppendSwitchASCII(kTaskSchedulerVariationParamsSwitch, "");
|
| + EXPECT_TRUE(GetVariationParamsFromCommandLine(command_line).empty());
|
| +}
|
| +
|
| +TEST(TaskSchedulerUtilVariationsUtilTest, CommandLineNoSwitch) {
|
| + base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
|
| + EXPECT_TRUE(GetVariationParamsFromCommandLine(command_line).empty());
|
| +}
|
| +
|
| } // namespace task_scheduler_util
|
|
|