blob: 8ed2e810b3abced5ba1180cbf891a053b481c9f2 [file] [log] [blame]
[email protected]f573ed6b2012-02-10 15:58:521// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]bb36d822011-09-30 20:55:092// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]7d855a12012-06-04 06:08:095#include "content/public/test/test_launcher.h"
[email protected]bb36d822011-09-30 20:55:096
[email protected]96f503fe2013-05-16 19:41:517#include "base/base_paths.h"
8#include "base/command_line.h"
[email protected]49f8a922014-06-11 14:35:579#include "base/i18n/icu_util.h"
avi66a07722015-12-25 23:38:1210#include "base/macros.h"
[email protected]a88f6362014-03-18 04:25:3511#include "base/process/memory.h"
Sebastien Marchand75a7cdf2018-11-13 23:47:0312#include "base/system/sys_info.h"
Mostyn Bramley-Moored5588cf2017-07-01 12:57:1813#include "base/test/launcher/test_launcher.h"
[email protected]96f503fe2013-05-16 19:41:5114#include "base/test/test_suite.h"
[email protected]a88f6362014-03-18 04:25:3515#include "base/test/test_timeouts.h"
avi66a07722015-12-25 23:38:1216#include "build/build_config.h"
[email protected]96f503fe2013-05-16 19:41:5117#include "content/public/common/content_switches.h"
18#include "content/public/test/content_test_suite_base.h"
19#include "content/shell/app/shell_main_delegate.h"
[email protected]96f503fe2013-05-16 19:41:5120#include "content/shell/common/shell_switches.h"
[email protected]96f503fe2013-05-16 19:41:5121#include "testing/gtest/include/gtest/gtest.h"
Scott Violetb72577d2019-01-09 22:18:1822#include "ui/base/buildflags.h"
Sadrul Habib Chowdhuryeeb5a942017-11-28 21:17:2323#include "ui/base/ui_base_switches.h"
[email protected]96f503fe2013-05-16 19:41:5124
Cliff Smolinskyf1006d0082019-06-03 19:12:4125#if defined(OS_WIN)
26#include "base/win/win_util.h"
27#endif // OS_WIN
28
[email protected]96f503fe2013-05-16 19:41:5129namespace content {
30
[email protected]96f503fe2013-05-16 19:41:5131class ContentBrowserTestSuite : public ContentTestSuiteBase {
32 public:
33 ContentBrowserTestSuite(int argc, char** argv)
34 : ContentTestSuiteBase(argc, argv) {
35 }
dchenge933b3e2014-10-21 11:44:0936 ~ContentBrowserTestSuite() override {}
[email protected]96f503fe2013-05-16 19:41:5137
38 protected:
dchenge933b3e2014-10-21 11:44:0939 void Initialize() override {
Etienne Bergeron80a2bd32020-06-25 20:20:1440 // Browser tests are expected not to tear-down various globals.
Wez318901082018-08-24 23:57:4241 base::TestSuite::DisableCheckForLeakedGlobals();
42
[email protected]96f503fe2013-05-16 19:41:5143 ContentTestSuiteBase::Initialize();
[email protected]96f503fe2013-05-16 19:41:5144
[email protected]a88f6362014-03-18 04:25:3545#if defined(OS_ANDROID)
danakj4115ec732019-05-13 18:34:2246 RegisterInProcessThreads();
[email protected]a88f6362014-03-18 04:25:3547#endif
danakj4115ec732019-05-13 18:34:2248 }
[email protected]96f503fe2013-05-16 19:41:5149
50 DISALLOW_COPY_AND_ASSIGN(ContentBrowserTestSuite);
51};
52
53class ContentTestLauncherDelegate : public TestLauncherDelegate {
54 public:
55 ContentTestLauncherDelegate() {}
dchenge933b3e2014-10-21 11:44:0956 ~ContentTestLauncherDelegate() override {}
[email protected]96f503fe2013-05-16 19:41:5157
dchenge933b3e2014-10-21 11:44:0958 int RunTestSuite(int argc, char** argv) override {
[email protected]96f503fe2013-05-16 19:41:5159 return ContentBrowserTestSuite(argc, argv).Run();
60 }
61
Scott Violeted612402020-01-23 23:55:1362 std::string GetUserDataDirectoryCommandLineSwitch() override {
63 return switches::kContentShellDataPath;
[email protected]96f503fe2013-05-16 19:41:5164 }
65
66 protected:
danakj6e6186d2019-05-10 21:37:1667#if !defined(OS_ANDROID)
dchenge933b3e2014-10-21 11:44:0968 ContentMainDelegate* CreateContentMainDelegate() override {
John Abd-El-Malek925dad62018-05-18 20:29:5069 return new ShellMainDelegate(true);
[email protected]96f503fe2013-05-16 19:41:5170 }
danakj6e6186d2019-05-10 21:37:1671#endif
[email protected]96f503fe2013-05-16 19:41:5172
73 private:
74 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate);
75};
76
77} // namespace content
78
[email protected]bb36d822011-09-30 20:55:0979int main(int argc, char** argv) {
Mostyn Bramley-Moored5588cf2017-07-01 12:57:1880 base::CommandLine::Init(argc, argv);
Fergal Daly903473ed2020-07-02 04:04:4981 size_t parallel_jobs = base::NumParallelJobs(/*cores_per_job=*/2);
82 if (parallel_jobs == 0U)
83 return 1;
84
Cliff Smolinskyf1006d0082019-06-03 19:12:4185#if defined(OS_WIN)
86 // Load and pin user32.dll to avoid having to load it once tests start while
87 // on the main thread loop where blocking calls are disallowed.
88 base::win::PinUser32();
89#endif // OS_WIN
[email protected]bdcf9152012-07-19 17:43:2190 content::ContentTestLauncherDelegate launcher_delegate;
Mostyn Bramley-Moored5588cf2017-07-01 12:57:1891 return LaunchTests(&launcher_delegate, parallel_jobs, argc, argv);
[email protected]76df8e362011-09-30 21:23:5892}