[email protected] | f573ed6b | 2012-02-10 15:58:52 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 7d855a1 | 2012-06-04 06:08:09 | [diff] [blame] | 5 | #include "content/public/test/test_launcher.h" |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 6 | |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 7 | #include "base/base_paths.h" |
8 | #include "base/command_line.h" | ||||
[email protected] | 49f8a92 | 2014-06-11 14:35:57 | [diff] [blame] | 9 | #include "base/i18n/icu_util.h" |
avi | 66a0772 | 2015-12-25 23:38:12 | [diff] [blame] | 10 | #include "base/macros.h" |
[email protected] | a88f636 | 2014-03-18 04:25:35 | [diff] [blame] | 11 | #include "base/process/memory.h" |
Sebastien Marchand | 75a7cdf | 2018-11-13 23:47:03 | [diff] [blame] | 12 | #include "base/system/sys_info.h" |
Mostyn Bramley-Moore | d5588cf | 2017-07-01 12:57:18 | [diff] [blame] | 13 | #include "base/test/launcher/test_launcher.h" |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 14 | #include "base/test/test_suite.h" |
[email protected] | a88f636 | 2014-03-18 04:25:35 | [diff] [blame] | 15 | #include "base/test/test_timeouts.h" |
avi | 66a0772 | 2015-12-25 23:38:12 | [diff] [blame] | 16 | #include "build/build_config.h" |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 17 | #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] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 20 | #include "content/shell/common/shell_switches.h" |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 21 | #include "testing/gtest/include/gtest/gtest.h" |
Scott Violet | b72577d | 2019-01-09 22:18:18 | [diff] [blame] | 22 | #include "ui/base/buildflags.h" |
Sadrul Habib Chowdhury | eeb5a94 | 2017-11-28 21:17:23 | [diff] [blame] | 23 | #include "ui/base/ui_base_switches.h" |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 24 | |
Cliff Smolinsky | f1006d008 | 2019-06-03 19:12:41 | [diff] [blame] | 25 | #if defined(OS_WIN) |
26 | #include "base/win/win_util.h" | ||||
27 | #endif // OS_WIN | ||||
28 | |||||
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 29 | namespace content { |
30 | |||||
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 31 | class ContentBrowserTestSuite : public ContentTestSuiteBase { |
32 | public: | ||||
33 | ContentBrowserTestSuite(int argc, char** argv) | ||||
34 | : ContentTestSuiteBase(argc, argv) { | ||||
35 | } | ||||
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 36 | ~ContentBrowserTestSuite() override {} |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 37 | |
38 | protected: | ||||
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 39 | void Initialize() override { |
Etienne Bergeron | 80a2bd3 | 2020-06-25 20:20:14 | [diff] [blame] | 40 | // Browser tests are expected not to tear-down various globals. |
Wez | 31890108 | 2018-08-24 23:57:42 | [diff] [blame] | 41 | base::TestSuite::DisableCheckForLeakedGlobals(); |
42 | |||||
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 43 | ContentTestSuiteBase::Initialize(); |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 44 | |
[email protected] | a88f636 | 2014-03-18 04:25:35 | [diff] [blame] | 45 | #if defined(OS_ANDROID) |
danakj | 4115ec73 | 2019-05-13 18:34:22 | [diff] [blame] | 46 | RegisterInProcessThreads(); |
[email protected] | a88f636 | 2014-03-18 04:25:35 | [diff] [blame] | 47 | #endif |
danakj | 4115ec73 | 2019-05-13 18:34:22 | [diff] [blame] | 48 | } |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 49 | |
50 | DISALLOW_COPY_AND_ASSIGN(ContentBrowserTestSuite); | ||||
51 | }; | ||||
52 | |||||
53 | class ContentTestLauncherDelegate : public TestLauncherDelegate { | ||||
54 | public: | ||||
55 | ContentTestLauncherDelegate() {} | ||||
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 56 | ~ContentTestLauncherDelegate() override {} |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 57 | |
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 58 | int RunTestSuite(int argc, char** argv) override { |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 59 | return ContentBrowserTestSuite(argc, argv).Run(); |
60 | } | ||||
61 | |||||
Scott Violet | ed61240 | 2020-01-23 23:55:13 | [diff] [blame] | 62 | std::string GetUserDataDirectoryCommandLineSwitch() override { |
63 | return switches::kContentShellDataPath; | ||||
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 64 | } |
65 | |||||
66 | protected: | ||||
danakj | 6e6186d | 2019-05-10 21:37:16 | [diff] [blame] | 67 | #if !defined(OS_ANDROID) |
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 68 | ContentMainDelegate* CreateContentMainDelegate() override { |
John Abd-El-Malek | 925dad6 | 2018-05-18 20:29:50 | [diff] [blame] | 69 | return new ShellMainDelegate(true); |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 70 | } |
danakj | 6e6186d | 2019-05-10 21:37:16 | [diff] [blame] | 71 | #endif |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 72 | |
73 | private: | ||||
74 | DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); | ||||
75 | }; | ||||
76 | |||||
77 | } // namespace content | ||||
78 | |||||
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 79 | int main(int argc, char** argv) { |
Mostyn Bramley-Moore | d5588cf | 2017-07-01 12:57:18 | [diff] [blame] | 80 | base::CommandLine::Init(argc, argv); |
Fergal Daly | 903473ed | 2020-07-02 04:04:49 | [diff] [blame^] | 81 | size_t parallel_jobs = base::NumParallelJobs(/*cores_per_job=*/2); |
82 | if (parallel_jobs == 0U) | ||||
83 | return 1; | ||||
84 | |||||
Cliff Smolinsky | f1006d008 | 2019-06-03 19:12:41 | [diff] [blame] | 85 | #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] | bdcf915 | 2012-07-19 17:43:21 | [diff] [blame] | 90 | content::ContentTestLauncherDelegate launcher_delegate; |
Mostyn Bramley-Moore | d5588cf | 2017-07-01 12:57:18 | [diff] [blame] | 91 | return LaunchTests(&launcher_delegate, parallel_jobs, argc, argv); |
[email protected] | 76df8e36 | 2011-09-30 21:23:58 | [diff] [blame] | 92 | } |