OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "components/task_scheduler_util/initialization/browser_util.h" |
| 6 |
| 7 #include <vector> |
| 8 |
| 9 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
| 10 #include "base/time/time.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace task_scheduler_util { |
| 14 namespace initialization { |
| 15 |
| 16 TEST(TaskSchedulerUtilBrowserUtilTest, CheckOrdering) { |
| 17 using StandbyThreadPolicy = |
| 18 base::SchedulerWorkerPoolParams::StandbyThreadPolicy; |
| 19 BrowserWorkerPoolsConfiguration config; |
| 20 config.background.standby_thread_policy = StandbyThreadPolicy::LAZY; |
| 21 config.background.threads = 1; |
| 22 config.background.detach_period = base::TimeDelta::FromSeconds(2); |
| 23 |
| 24 config.background_file_io.standby_thread_policy = StandbyThreadPolicy::ONE; |
| 25 config.background_file_io.threads = 3; |
| 26 config.background_file_io.detach_period = base::TimeDelta::FromSeconds(4); |
| 27 |
| 28 config.foreground.standby_thread_policy = StandbyThreadPolicy::LAZY; |
| 29 config.foreground.threads = 5; |
| 30 config.foreground.detach_period = base::TimeDelta::FromSeconds(6); |
| 31 |
| 32 config.foreground_file_io.standby_thread_policy = StandbyThreadPolicy::ONE; |
| 33 config.foreground_file_io.threads = 7; |
| 34 config.foreground_file_io.detach_period = base::TimeDelta::FromSeconds(8); |
| 35 |
| 36 const std::vector<base::SchedulerWorkerPoolParams> params_vector = |
| 37 BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams(config); |
| 38 |
| 39 ASSERT_EQ(4U, params_vector.size()); |
| 40 |
| 41 EXPECT_EQ(StandbyThreadPolicy::LAZY, |
| 42 params_vector[0].standby_thread_policy()); |
| 43 EXPECT_EQ(1U, params_vector[0].max_threads()); |
| 44 EXPECT_EQ(base::TimeDelta::FromSeconds(2), |
| 45 params_vector[0].suggested_reclaim_time()); |
| 46 |
| 47 EXPECT_EQ(StandbyThreadPolicy::ONE, params_vector[1].standby_thread_policy()); |
| 48 EXPECT_EQ(3U, params_vector[1].max_threads()); |
| 49 EXPECT_EQ(base::TimeDelta::FromSeconds(4), |
| 50 params_vector[1].suggested_reclaim_time()); |
| 51 |
| 52 EXPECT_EQ(StandbyThreadPolicy::LAZY, |
| 53 params_vector[2].standby_thread_policy()); |
| 54 EXPECT_EQ(5U, params_vector[2].max_threads()); |
| 55 EXPECT_EQ(base::TimeDelta::FromSeconds(6), |
| 56 params_vector[2].suggested_reclaim_time()); |
| 57 |
| 58 EXPECT_EQ(StandbyThreadPolicy::ONE, params_vector[3].standby_thread_policy()); |
| 59 EXPECT_EQ(7U, params_vector[3].max_threads()); |
| 60 EXPECT_EQ(base::TimeDelta::FromSeconds(8), |
| 61 params_vector[3].suggested_reclaim_time()); |
| 62 } |
| 63 |
| 64 } // namespace initialization |
| 65 } // namespace task_scheduler_util |
OLD | NEW |