blob: 830d8d7e0561e1557fbf20b191270316df9f2200 [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"
[email protected]96f503fe2013-05-16 19:41:5110#include "base/logging.h"
avi66a07722015-12-25 23:38:1211#include "base/macros.h"
[email protected]a88f6362014-03-18 04:25:3512#include "base/process/memory.h"
Sebastien Marchand75a7cdf2018-11-13 23:47:0313#include "base/system/sys_info.h"
Mostyn Bramley-Moored5588cf2017-07-01 12:57:1814#include "base/test/launcher/test_launcher.h"
[email protected]96f503fe2013-05-16 19:41:5115#include "base/test/test_suite.h"
[email protected]a88f6362014-03-18 04:25:3516#include "base/test/test_timeouts.h"
avi66a07722015-12-25 23:38:1217#include "build/build_config.h"
[email protected]96f503fe2013-05-16 19:41:5118#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]96f503fe2013-05-16 19:41:5121#include "content/shell/common/shell_switches.h"
[email protected]96f503fe2013-05-16 19:41:5122#include "testing/gtest/include/gtest/gtest.h"
Scott Violetb72577d2019-01-09 22:18:1823#include "ui/base/buildflags.h"
Sadrul Habib Chowdhuryeeb5a942017-11-28 21:17:2324#include "ui/base/ui_base_switches.h"
[email protected]96f503fe2013-05-16 19:41:5125
Cliff Smolinskyf1006d0082019-06-03 19:12:4126#if defined(OS_WIN)
27#include "base/win/win_util.h"
28#endif // OS_WIN
29
[email protected]96f503fe2013-05-16 19:41:5130namespace content {
31
[email protected]96f503fe2013-05-16 19:41:5132class ContentBrowserTestSuite : public ContentTestSuiteBase {
33 public:
34 ContentBrowserTestSuite(int argc, char** argv)
35 : ContentTestSuiteBase(argc, argv) {
36 }
dchenge933b3e2014-10-21 11:44:0937 ~ContentBrowserTestSuite() override {}
[email protected]96f503fe2013-05-16 19:41:5138
39 protected:
dchenge933b3e2014-10-21 11:44:0940 void Initialize() override {
François Doray2b82f402019-11-04 21:16:4841 // Browser tests are expected not to tear-down various globals and may
42 // complete with the thread priority being above NORMAL.
Wez318901082018-08-24 23:57:4243 base::TestSuite::DisableCheckForLeakedGlobals();
François Doray2b82f402019-11-04 21:16:4844 base::TestSuite::DisableCheckForThreadPriorityAtTestEnd();
Wez318901082018-08-24 23:57:4245
[email protected]96f503fe2013-05-16 19:41:5146 ContentTestSuiteBase::Initialize();
[email protected]96f503fe2013-05-16 19:41:5147
[email protected]a88f6362014-03-18 04:25:3548#if defined(OS_ANDROID)
danakj4115ec732019-05-13 18:34:2249 RegisterInProcessThreads();
[email protected]a88f6362014-03-18 04:25:3550#endif
danakj4115ec732019-05-13 18:34:2251 }
[email protected]96f503fe2013-05-16 19:41:5152
53 DISALLOW_COPY_AND_ASSIGN(ContentBrowserTestSuite);
54};
55
56class ContentTestLauncherDelegate : public TestLauncherDelegate {
57 public:
58 ContentTestLauncherDelegate() {}
dchenge933b3e2014-10-21 11:44:0959 ~ContentTestLauncherDelegate() override {}
[email protected]96f503fe2013-05-16 19:41:5160
dchenge933b3e2014-10-21 11:44:0961 int RunTestSuite(int argc, char** argv) override {
[email protected]96f503fe2013-05-16 19:41:5162 return ContentBrowserTestSuite(argc, argv).Run();
63 }
64
Scott Violeted612402020-01-23 23:55:1365 std::string GetUserDataDirectoryCommandLineSwitch() override {
66 return switches::kContentShellDataPath;
[email protected]96f503fe2013-05-16 19:41:5167 }
68
69 protected:
danakj6e6186d2019-05-10 21:37:1670#if !defined(OS_ANDROID)
dchenge933b3e2014-10-21 11:44:0971 ContentMainDelegate* CreateContentMainDelegate() override {
John Abd-El-Malek925dad62018-05-18 20:29:5072 return new ShellMainDelegate(true);
[email protected]96f503fe2013-05-16 19:41:5173 }
danakj6e6186d2019-05-10 21:37:1674#endif
[email protected]96f503fe2013-05-16 19:41:5175
76 private:
77 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate);
78};
79
80} // namespace content
81
[email protected]bb36d822011-09-30 20:55:0982int main(int argc, char** argv) {
Mostyn Bramley-Moored5588cf2017-07-01 12:57:1883 base::CommandLine::Init(argc, argv);
84 size_t parallel_jobs = base::NumParallelJobs();
85 if (parallel_jobs > 1U) {
86 parallel_jobs /= 2U;
87 }
Cliff Smolinskyf1006d0082019-06-03 19:12:4188#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]bdcf9152012-07-19 17:43:2193 content::ContentTestLauncherDelegate launcher_delegate;
Mostyn Bramley-Moored5588cf2017-07-01 12:57:1894 return LaunchTests(&launcher_delegate, parallel_jobs, argc, argv);
[email protected]76df8e362011-09-30 21:23:5895}