Replaced --single_process with --single-process-tests
Ensured that functionality that runs tests + launcher in a
single process is consistently referred to with the switch
--single-process-tests rather than previous content::
specific --single_process in both code and documentation.
Performed basic cleanup to ensure that unused declarations
were removed and made sure switches in content:: are more
consistently declared in the appropriate headers.
Bug: 460513
Change-Id: Ic901d7af972ad43c9e0e2d31e34cc778d388d34a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1848365
Reviewed-by: Mike Pinkerton <[email protected]>
Reviewed-by: Peter Kasting <[email protected]>
Commit-Queue: Thomas Lukaszewicz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#705635}
diff --git a/apps/load_and_launch_browsertest.cc b/apps/load_and_launch_browsertest.cc
index bd35115..de73e18 100644
--- a/apps/load_and_launch_browsertest.cc
+++ b/apps/load_and_launch_browsertest.cc
@@ -10,6 +10,7 @@
#include "base/process/launch.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/test_switches.h"
#include "base/test/test_timeouts.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
@@ -65,7 +66,7 @@
new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp,
app_path.value());
- new_cmdline.AppendSwitch(content::kLaunchAsBrowser);
+ new_cmdline.AppendSwitch(switches::kLaunchAsBrowser);
base::Process process =
base::LaunchProcess(new_cmdline, base::LaunchOptionsForTest());
ASSERT_TRUE(process.IsValid());
@@ -105,7 +106,7 @@
new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp,
app_path.value());
- new_cmdline.AppendSwitch(content::kLaunchAsBrowser);
+ new_cmdline.AppendSwitch(switches::kLaunchAsBrowser);
new_cmdline.AppendArgPath(test_file_path);
base::Process process =
diff --git a/chrome/browser/bitmap_fetcher/bitmap_fetcher_browsertest.cc b/chrome/browser/bitmap_fetcher/bitmap_fetcher_browsertest.cc
index ed0818a..25b2b69 100644
--- a/chrome/browser/bitmap_fetcher/bitmap_fetcher_browsertest.cc
+++ b/chrome/browser/bitmap_fetcher/bitmap_fetcher_browsertest.cc
@@ -134,7 +134,7 @@
}
};
-// WARNING: These tests work with --single_process, but not
+// WARNING: These tests work with --single-process-tests, but not
// --single-process. The reason is that the sandbox does not get created
// for us by the test process if --single-process is used.
diff --git a/chrome/browser/ui/send_mouse_move_uitest_win.cc b/chrome/browser/ui/send_mouse_move_uitest_win.cc
index 20e3a21..0d04093 100644
--- a/chrome/browser/ui/send_mouse_move_uitest_win.cc
+++ b/chrome/browser/ui/send_mouse_move_uitest_win.cc
@@ -25,8 +25,9 @@
// This test positions the mouse at every point on the screen. It is not meant
// to be run on the bots, as it takes too long. Run it manually as needed to
// verify ui_controls::SendMouseMoveNotifyWhenDone with:
-// interactive_ui_tests.exe --single_process --gtest_also_run_disabled_tests \
-// --gtest_filter=SendMouseMoveUITest.DISABLED_Fullscreen
+// interactive_ui_tests.exe --single-process-tests \
+// --gtest_also_run_disabled_tests \
+// --gtest_filter=SendMouseMoveUITest.DISABLED_Fullscreen
IN_PROC_BROWSER_TEST_F(SendMouseMoveUITest, DISABLED_Fullscreen) {
// Make the browser fullscreen so that we can position the mouse anywhere on
// the display, as ui_controls::SendMouseMoveNotifyWhenDone can only provide
diff --git a/chrome/test/base/chrome_test_launcher.cc b/chrome/test/base/chrome_test_launcher.cc
index ad45e43b..5e3c3d32 100644
--- a/chrome/test/base/chrome_test_launcher.cc
+++ b/chrome/test/base/chrome_test_launcher.cc
@@ -20,6 +20,7 @@
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/test/test_file_util.h"
+#include "base/test/test_switches.h"
#include "chrome/app/chrome_main_delegate.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
@@ -210,7 +211,7 @@
// mimics the behavior in standalone Chrome, where this is done in
// chrome/app/chrome_main.cc, which does not get called by tests.
std::unique_ptr<MainThreadStackSamplingProfiler> sampling_profiler;
- if (command_line.HasSwitch(content::kLaunchAsBrowser))
+ if (command_line.HasSwitch(switches::kLaunchAsBrowser))
sampling_profiler = std::make_unique<MainThreadStackSamplingProfiler>();
#if defined(OS_LINUX) || defined(OS_ANDROID)
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index 28dbb2f..dfec8850 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -20,6 +20,7 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/test_file_util.h"
+#include "base/test/test_switches.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/after_startup_task_utils.h"
@@ -475,9 +476,9 @@
base::CommandLine::SwitchMap switches =
base::CommandLine::ForCurrentProcess()->GetSwitches();
switches.erase(switches::kUserDataDir);
- switches.erase(content::kSingleProcessTestsFlag);
+ switches.erase(switches::kSingleProcessTests);
switches.erase(switches::kSingleProcess);
- new_command_line.AppendSwitch(content::kLaunchAsBrowser);
+ new_command_line.AppendSwitch(switches::kLaunchAsBrowser);
base::FilePath user_data_dir;
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
diff --git a/chrome/test/base/web_ui_browser_test.cc b/chrome/test/base/web_ui_browser_test.cc
index eaab1a4..0cceb38 100644
--- a/chrome/test/base/web_ui_browser_test.cc
+++ b/chrome/test/base/web_ui_browser_test.cc
@@ -16,6 +16,7 @@
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/test_switches.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "chrome/browser/chrome_content_browser_client.h"
@@ -256,7 +257,7 @@
libraries_preloaded_ = true;
bool should_wait_flag = base::CommandLine::ForCurrentProcess()->HasSwitch(
- ::content::kWaitForDebuggerWebUI);
+ ::switches::kWaitForDebuggerWebUI);
if (should_wait_flag)
RunJavascriptUsingHandler("setWaitUser", {}, false, false, preload_host);
diff --git a/components/policy/core/browser/browser_policy_connector_base.cc b/components/policy/core/browser/browser_policy_connector_base.cc
index ad6944c..29718da 100644
--- a/components/policy/core/browser/browser_policy_connector_base.cc
+++ b/components/policy/core/browser/browser_policy_connector_base.cc
@@ -57,8 +57,9 @@
g_testing_provider->Shutdown();
for (const auto& provider : policy_providers_)
provider->Shutdown();
- // Drop g_testing_provider so that tests executed with --single_process can
- // call SetPolicyProviderForTesting() again. It is still owned by the test.
+ // Drop g_testing_provider so that tests executed with --single-process-tests
+ // can call SetPolicyProviderForTesting() again. It is still owned by the
+ // test.
g_testing_provider = nullptr;
g_created_policy_service = false;
}
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 11f3786..d0e2b583 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -404,7 +404,7 @@
// is only useful for tests.
const char kEnableServiceBinaryLauncher[] = "enable-service-binary-launcher";
-// Enables the Skia benchmarking extension
+// Enables the Skia benchmarking extension.
const char kEnableSkiaBenchmarking[] = "enable-skia-benchmarking";
// On platforms that support it, enables smooth scroll animation.
@@ -558,9 +558,12 @@
// Enables experimental Harmony (ECMAScript 6) features.
const char kJavaScriptHarmony[] = "javascript-harmony";
-// Specifies the flags passed to JS engine
+// Specifies the flags passed to JS engine.
const char kJavaScriptFlags[] = "js-flags";
+// Flag to launch tests in the browser process.
+const char kLaunchAsBrowser[] = "as-browser";
+
// Overrides the Lite Page Subresource host.
const char kLitePagesServerSubresourceHost[] =
"litepage-server-subresource-host";
@@ -857,6 +860,9 @@
// kWaitForDebugger flag passed on or not.
const char kWaitForDebuggerChildren[] = "wait-for-debugger-children";
+// Flag used by WebUI test runners to wait for debugger to be attached.
+const char kWaitForDebuggerWebUI[] = "wait-for-debugger-webui";
+
// Set the antialiasing method used for webgl. (none, explicit, implicit, or
// screenspace)
const char kWebglAntialiasingMode[] = "webgl-antialiasing-mode";
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index 856f21b..20acdce1 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -167,6 +167,7 @@
CONTENT_EXPORT extern const char kIsolateOrigins[];
CONTENT_EXPORT extern const char kJavaScriptFlags[];
CONTENT_EXPORT extern const char kJavaScriptHarmony[];
+CONTENT_EXPORT extern const char kLaunchAsBrowser[];
CONTENT_EXPORT extern const char kLitePagesServerSubresourceHost[];
CONTENT_EXPORT extern const char kLogGpuControlListDecisions[];
CONTENT_EXPORT extern const char kLoggingLevel[];
@@ -248,6 +249,7 @@
CONTENT_EXPORT extern const char kEnableWebRtcStunOrigin[];
CONTENT_EXPORT extern const char kEnforceWebRtcIPPermissionCheck[];
CONTENT_EXPORT extern const char kForceWebRtcIPHandlingPolicy[];
+CONTENT_EXPORT extern const char kWaitForDebuggerWebUI[];
extern const char kWebRtcMaxCaptureFramerate[];
extern const char kWebRtcMaxCpuConsumptionPercentage[];
CONTENT_EXPORT extern const char kWebRtcStunProbeTrialParameter[];
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index ef4c3e6..0c99317 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -25,6 +25,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
+#include "base/test/test_switches.h"
#include "base/test/test_timeouts.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
@@ -1767,8 +1768,8 @@
DOMMessageQueue message_queue;
- bool should_wait_flag =
- base::CommandLine::ForCurrentProcess()->HasSwitch(kWaitForDebuggerWebUI);
+ bool should_wait_flag = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kWaitForDebuggerWebUI);
if (should_wait_flag) {
ExecuteScriptAsync(
diff --git a/content/public/test/test_launcher.cc b/content/public/test/test_launcher.cc
index fa500d1..a164ef3 100644
--- a/content/public/test/test_launcher.cc
+++ b/content/public/test/test_launcher.cc
@@ -208,7 +208,7 @@
// tests unless this flag was specified to the browser test executable.
new_cmd_line.AppendSwitch("gtest_also_run_disabled_tests");
new_cmd_line.AppendSwitchASCII("gtest_filter", test_name);
- new_cmd_line.AppendSwitch(kSingleProcessTestsFlag);
+ new_cmd_line.AppendSwitch(switches::kSingleProcessTests);
return new_cmd_line;
}
@@ -243,14 +243,6 @@
} // namespace
-const char kHelpFlag[] = "help";
-
-const char kLaunchAsBrowser[] = "as-browser";
-
-const char kSingleProcessTestsFlag[] = "single_process";
-
-const char kWaitForDebuggerWebUI[] = "wait-for-debugger-webui";
-
void AppendCommandLineSwitches() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@@ -273,7 +265,7 @@
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(kHelpFlag)) {
+ if (command_line->HasSwitch(switches::kHelpFlag)) {
PrintUsage();
return 0;
}
@@ -310,12 +302,12 @@
// This needs to be before trying to run tests as otherwise utility processes
// end up being launched as a test, which leads to rerunning the test.
if (command_line->HasSwitch(switches::kProcessType) ||
- command_line->HasSwitch(kLaunchAsBrowser)) {
+ command_line->HasSwitch(switches::kLaunchAsBrowser)) {
return ContentMain(params);
}
#endif
- if (command_line->HasSwitch(kSingleProcessTestsFlag) ||
+ if (command_line->HasSwitch(switches::kSingleProcessTests) ||
(command_line->HasSwitch(switches::kSingleProcess) &&
command_line->HasSwitch(base::kGTestFilterFlag)) ||
command_line->HasSwitch(base::kGTestListTestsFlag) ||
@@ -331,11 +323,12 @@
TestTimeouts::Initialize();
fprintf(stdout,
- "IMPORTANT DEBUGGING NOTE: each test is run inside its own process.\n"
- "For debugging a test inside a debugger, use the\n"
- "--gtest_filter=<your_test_name> flag along with either\n"
- "--single_process (to run the test in one launcher/browser process) or\n"
- "--single-process (to do the above, and also run Chrome in single-"
+ "IMPORTANT DEBUGGING NOTE: each test is run inside its own process.\n"
+ "For debugging a test inside a debugger, use the\n"
+ "--gtest_filter=<your_test_name> flag along with either\n"
+ "--single-process-tests (to run the test in one launcher/browser "
+ "process) or\n"
+ "--single-process (to do the above, and also run Chrome in single-"
"process mode).\n");
base::debug::VerifyDebugger();
diff --git a/content/public/test/test_launcher.h b/content/public/test/test_launcher.h
index 062640c7..bf733bd 100644
--- a/content/public/test/test_launcher.h
+++ b/content/public/test/test_launcher.h
@@ -21,17 +21,6 @@
class ContentMainDelegate;
struct ContentMainParams;
-extern const char kEmptyTestName[];
-extern const char kHelpFlag[];
-extern const char kLaunchAsBrowser[];
-extern const char kSingleProcessTestsFlag[];
-
-// Flag that causes only the kEmptyTestName test to be run.
-extern const char kWarmupFlag[];
-
-// Flag used by WebUI test runners to wait for debugger to be attached.
-extern const char kWaitForDebuggerWebUI[];
-
class TestLauncherDelegate {
public:
virtual int RunTestSuite(int argc, char** argv) = 0;
@@ -46,13 +35,13 @@
// Called prior to running each test.
//
- // NOTE: this is not called if --single_process is supplied.
+ // NOTE: this is not called if --single-process-tests is supplied.
virtual void PreRunTest() {}
// Called after running each test. Can modify test result.
//
- // NOTE: Just like PreRunTest, this is not called when --single_process is
- // supplied.
+ // NOTE: Just like PreRunTest, this is not called when --single-process-tests
+ // is supplied.
virtual void PostRunTest(base::TestResult* result) {}
// Allows a TestLauncherDelegate to do work before the launcher shards test
diff --git a/content/renderer/render_thread_impl_browsertest.cc b/content/renderer/render_thread_impl_browsertest.cc
index 129cea20..91dab8b 100644
--- a/content/renderer/render_thread_impl_browsertest.cc
+++ b/content/renderer/render_thread_impl_browsertest.cc
@@ -23,6 +23,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool/thread_pool_instance.h"
+#include "base/test/test_switches.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/app/mojo/mojo_init.h"
@@ -227,7 +228,7 @@
void TearDown() override {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- kSingleProcessTestsFlag)) {
+ switches::kSingleProcessTests)) {
// In a single-process mode, we need to avoid destructing mock_process_
// because it will call _exit(0) and kill the process before the browser
// side is ready to exit.
diff --git a/content/test/content_browser_test_test.cc b/content/test/content_browser_test_test.cc
index d329ef9..4f5abb0 100644
--- a/content/test/content_browser_test_test.cc
+++ b/content/test/content_browser_test_test.cc
@@ -16,6 +16,7 @@
#include "base/test/launcher/test_launcher.h"
#include "base/test/launcher/test_launcher_test_utils.h"
#include "base/test/scoped_feature_list.h"
+#include "base/test/test_switches.h"
#include "base/test/test_timeouts.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -82,7 +83,7 @@
new_test.AppendSwitchASCII(base::kGTestFilterFlag,
"ContentBrowserTest.MANUAL_RendererCrash");
new_test.AppendSwitch(switches::kRunManualTestsFlag);
- new_test.AppendSwitch(kSingleProcessTestsFlag);
+ new_test.AppendSwitch(switches::kSingleProcessTests);
#if defined(THREAD_SANITIZER)
// TSan appears to not be able to report intentional crashes from sandboxed
@@ -123,7 +124,7 @@
new_test.AppendSwitchASCII(base::kGTestFilterFlag,
"ContentBrowserTest.MANUAL_BrowserCrash");
new_test.AppendSwitch(switches::kRunManualTestsFlag);
- new_test.AppendSwitch(kSingleProcessTestsFlag);
+ new_test.AppendSwitch(switches::kSingleProcessTests);
std::string output;
base::GetAppOutputAndError(new_test, &output);
@@ -193,11 +194,11 @@
// will need to change accordingly.
std::string file_name = "../../content/test/content_browser_test_test.cc";
EXPECT_TRUE(base::test_launcher_utils::ValidateTestLocation(
- val, "MockContentBrowserTest.DISABLED_PassTest", file_name, 152));
+ val, "MockContentBrowserTest.DISABLED_PassTest", file_name, 153));
EXPECT_TRUE(base::test_launcher_utils::ValidateTestLocation(
- val, "MockContentBrowserTest.DISABLED_FailTest", file_name, 156));
+ val, "MockContentBrowserTest.DISABLED_FailTest", file_name, 157));
EXPECT_TRUE(base::test_launcher_utils::ValidateTestLocation(
- val, "MockContentBrowserTest.DISABLED_CrashTest", file_name, 160));
+ val, "MockContentBrowserTest.DISABLED_CrashTest", file_name, 161));
val = root->FindListKey("per_iteration_data");
ASSERT_TRUE(val);
diff --git a/docs/linux_debugging.md b/docs/linux_debugging.md
index 36e35da..430778e 100644
--- a/docs/linux_debugging.md
+++ b/docs/linux_debugging.md
@@ -332,10 +332,10 @@
browser side of a single test, use a command like
```
-gdb --args out/Debug/browser_tests --single_process --gtest_filter=MyTestName
+gdb --args out/Debug/browser_tests --single-process-tests --gtest_filter=MyTestName
```
-**note the underscore in `single_process`** -- this makes the test harness and
+**note the use of `single-process-tests`** -- this makes the test harness and
browser process share the outermost process.
diff --git a/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTest.java b/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTest.java
index dfb23e3..683b20fc 100644
--- a/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTest.java
+++ b/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTest.java
@@ -20,8 +20,8 @@
// Set the command line flags to be passed to the C++ main() method. Each
// browser tests Activity should ensure these are included.
public static final String BROWSER_TESTS_FLAGS[] = {
- // content::kSingleProcessTestsFlag
- "--single_process",
+ // switches::kSingleProcessTests
+ "--single-process-tests",
// switches::kUseFakeDeviceForMediaStream
"--use-fake-device-for-media-stream"};
diff --git a/third_party/blink/tools/blinkpy/web_tests/port/browser_test_driver.py b/third_party/blink/tools/blinkpy/web_tests/port/browser_test_driver.py
index 4cdaa78..505af53 100644
--- a/third_party/blink/tools/blinkpy/web_tests/port/browser_test_driver.py
+++ b/third_party/blink/tools/blinkpy/web_tests/port/browser_test_driver.py
@@ -79,7 +79,7 @@
cmd.append(self._port._path_to_driver())
cmd.append('--gtest_filter=PrintPreviewPdfGeneratedBrowserTest.MANUAL_LayoutTestDriver')
cmd.append('--run-manual')
- cmd.append('--single_process')
+ cmd.append('--single-process-tests')
cmd.extend(per_test_args)
cmd.extend(self._port.get_option('additional_driver_flag', []))
return cmd
diff --git a/tools/vscode/launch.json5 b/tools/vscode/launch.json5
index 8591577..efb6eee30 100644
--- a/tools/vscode/launch.json5
+++ b/tools/vscode/launch.json5
@@ -34,7 +34,7 @@
"targetArchitecture": "x64",
"program": "${workspaceRoot}/out/Debug/unit_tests",
"args": ["--gtest_filter=*",
- "--single_process",
+ "--single-process-tests",
"--ui-test-action-max-timeout=1000000",
"--test-launcher-timeout=1000000"],
"preLaunchTask": "5-build_test_debug",