[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" |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 10 | #include "base/logging.h" |
avi | 66a0772 | 2015-12-25 23:38:12 | [diff] [blame] | 11 | #include "base/macros.h" |
[email protected] | a88f636 | 2014-03-18 04:25:35 | [diff] [blame] | 12 | #include "base/process/memory.h" |
Sebastien Marchand | 75a7cdf | 2018-11-13 23:47:03 | [diff] [blame] | 13 | #include "base/system/sys_info.h" |
Mostyn Bramley-Moore | d5588cf | 2017-07-01 12:57:18 | [diff] [blame] | 14 | #include "base/test/launcher/test_launcher.h" |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 15 | #include "base/test/test_suite.h" |
[email protected] | a88f636 | 2014-03-18 04:25:35 | [diff] [blame] | 16 | #include "base/test/test_timeouts.h" |
avi | 66a0772 | 2015-12-25 23:38:12 | [diff] [blame] | 17 | #include "build/build_config.h" |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 18 | #include "content/public/common/content_switches.h" |
19 | #include "content/public/test/content_test_suite_base.h" | ||||
20 | #include "content/shell/app/shell_main_delegate.h" | ||||
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 21 | #include "content/shell/common/shell_switches.h" |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 22 | #include "testing/gtest/include/gtest/gtest.h" |
Scott Violet | b72577d | 2019-01-09 22:18:18 | [diff] [blame] | 23 | #include "ui/base/buildflags.h" |
Sadrul Habib Chowdhury | eeb5a94 | 2017-11-28 21:17:23 | [diff] [blame] | 24 | #include "ui/base/ui_base_switches.h" |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 25 | |
Cliff Smolinsky | f1006d008 | 2019-06-03 19:12:41 | [diff] [blame] | 26 | #if defined(OS_WIN) |
27 | #include "base/win/win_util.h" | ||||
28 | #endif // OS_WIN | ||||
29 | |||||
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 30 | namespace content { |
31 | |||||
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 32 | class ContentBrowserTestSuite : public ContentTestSuiteBase { |
33 | public: | ||||
34 | ContentBrowserTestSuite(int argc, char** argv) | ||||
35 | : ContentTestSuiteBase(argc, argv) { | ||||
36 | } | ||||
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 37 | ~ContentBrowserTestSuite() override {} |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 38 | |
39 | protected: | ||||
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 40 | void Initialize() override { |
François Doray | 2b82f40 | 2019-11-04 21:16:48 | [diff] [blame] | 41 | // Browser tests are expected not to tear-down various globals and may |
42 | // complete with the thread priority being above NORMAL. | ||||
Wez | 31890108 | 2018-08-24 23:57:42 | [diff] [blame] | 43 | base::TestSuite::DisableCheckForLeakedGlobals(); |
François Doray | 2b82f40 | 2019-11-04 21:16:48 | [diff] [blame] | 44 | base::TestSuite::DisableCheckForThreadPriorityAtTestEnd(); |
Wez | 31890108 | 2018-08-24 23:57:42 | [diff] [blame] | 45 | |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 46 | ContentTestSuiteBase::Initialize(); |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 47 | |
[email protected] | a88f636 | 2014-03-18 04:25:35 | [diff] [blame] | 48 | #if defined(OS_ANDROID) |
danakj | 4115ec73 | 2019-05-13 18:34:22 | [diff] [blame] | 49 | RegisterInProcessThreads(); |
[email protected] | a88f636 | 2014-03-18 04:25:35 | [diff] [blame] | 50 | #endif |
danakj | 4115ec73 | 2019-05-13 18:34:22 | [diff] [blame] | 51 | } |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 52 | |
53 | DISALLOW_COPY_AND_ASSIGN(ContentBrowserTestSuite); | ||||
54 | }; | ||||
55 | |||||
56 | class ContentTestLauncherDelegate : public TestLauncherDelegate { | ||||
57 | public: | ||||
58 | ContentTestLauncherDelegate() {} | ||||
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 59 | ~ContentTestLauncherDelegate() override {} |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 60 | |
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 61 | int RunTestSuite(int argc, char** argv) override { |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 62 | return ContentBrowserTestSuite(argc, argv).Run(); |
63 | } | ||||
64 | |||||
Scott Violet | ed61240 | 2020-01-23 23:55:13 | [diff] [blame^] | 65 | std::string GetUserDataDirectoryCommandLineSwitch() override { |
66 | return switches::kContentShellDataPath; | ||||
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 67 | } |
68 | |||||
69 | protected: | ||||
danakj | 6e6186d | 2019-05-10 21:37:16 | [diff] [blame] | 70 | #if !defined(OS_ANDROID) |
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 71 | ContentMainDelegate* CreateContentMainDelegate() override { |
John Abd-El-Malek | 925dad6 | 2018-05-18 20:29:50 | [diff] [blame] | 72 | return new ShellMainDelegate(true); |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 73 | } |
danakj | 6e6186d | 2019-05-10 21:37:16 | [diff] [blame] | 74 | #endif |
[email protected] | 96f503fe | 2013-05-16 19:41:51 | [diff] [blame] | 75 | |
76 | private: | ||||
77 | DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); | ||||
78 | }; | ||||
79 | |||||
80 | } // namespace content | ||||
81 | |||||
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 82 | int main(int argc, char** argv) { |
Mostyn Bramley-Moore | d5588cf | 2017-07-01 12:57:18 | [diff] [blame] | 83 | base::CommandLine::Init(argc, argv); |
84 | size_t parallel_jobs = base::NumParallelJobs(); | ||||
85 | if (parallel_jobs > 1U) { | ||||
86 | parallel_jobs /= 2U; | ||||
87 | } | ||||
Cliff Smolinsky | f1006d008 | 2019-06-03 19:12:41 | [diff] [blame] | 88 | #if defined(OS_WIN) |
89 | // Load and pin user32.dll to avoid having to load it once tests start while | ||||
90 | // on the main thread loop where blocking calls are disallowed. | ||||
91 | base::win::PinUser32(); | ||||
92 | #endif // OS_WIN | ||||
[email protected] | bdcf915 | 2012-07-19 17:43:21 | [diff] [blame] | 93 | content::ContentTestLauncherDelegate launcher_delegate; |
Mostyn Bramley-Moore | d5588cf | 2017-07-01 12:57:18 | [diff] [blame] | 94 | return LaunchTests(&launcher_delegate, parallel_jobs, argc, argv); |
[email protected] | 76df8e36 | 2011-09-30 21:23:58 | [diff] [blame] | 95 | } |