blob: b91c16cacfd6c9838d0aa44296ea61f4f207c4ee [file] [log] [blame]
Francois Doray6d3c649692017-06-16 19:20:251// Copyright 2017 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/browser/browser_main_loop.h"
6
7#include "base/command_line.h"
8#include "base/message_loop/message_loop.h"
9#include "base/sys_info.h"
10#include "base/task_scheduler/task_scheduler.h"
11#include "base/test/scoped_command_line.h"
12#include "content/public/common/content_switches.h"
13#include "content/public/common/main_function_params.h"
14#include "testing/gtest/include/gtest/gtest.h"
15
16namespace content {
17
18// Verify that a single-process browser process has at least as many threads as
19// the number of cores in its foreground pool.
20TEST(BrowserMainLoopTest, CreateThreadsInSingleProcess) {
21 {
22 base::MessageLoop message_loop;
23 base::test::ScopedCommandLine scoped_command_line;
24 scoped_command_line.GetProcessCommandLine()->AppendSwitch(
25 switches::kSingleProcess);
26 MainFunctionParams main_function_params(
27 *scoped_command_line.GetProcessCommandLine());
28 BrowserMainLoop browser_main_loop(main_function_params);
29 browser_main_loop.MainMessageLoopStart();
30 browser_main_loop.CreateThreads();
31 EXPECT_GE(base::TaskScheduler::GetInstance()
Jeffrey Hed628419b2017-08-23 18:51:5132 ->GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
Francois Doray6d3c649692017-06-16 19:20:2533 {base::TaskPriority::USER_VISIBLE}),
34 base::SysInfo::NumberOfProcessors());
35 browser_main_loop.ShutdownThreadsAndCleanUp();
36 }
37 base::TaskScheduler::GetInstance()->JoinForTesting();
38 base::TaskScheduler::SetInstance(nullptr);
39}
40
41} // namespace content