android: Deflake ChildProcessLauncherHelperTest
Test was relying on Debug.waitForDebugger to hang child service, which turns out to not always work on bots. Instead, just add a new command line switch to get the desired behavior. Bug: 354765949 Change-Id: I8ec11b228f1955a8ddee80b2cc160c3a61113093 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6113740 Reviewed-by: Andrew Grieve <agrieve@chromium.org> Commit-Queue: Bo Liu <boliu@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1399312}
This commit is contained in:
base
content/public/android/javatests/src/org/chromium/content/browser
@ -293,6 +293,11 @@ public class ChildProcessService {
|
||||
assert mServiceBound;
|
||||
CommandLine.init(mCommandLineParams);
|
||||
|
||||
if (CommandLine.getInstance()
|
||||
.hasSwitch(BaseSwitches.ANDROID_SKIP_CHILD_SERVICE_INIT_FOR_TESTING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CommandLine.getInstance().hasSwitch(BaseSwitches.RENDERER_WAIT_FOR_JAVA_DEBUGGER)) {
|
||||
android.os.Debug.waitForDebugger();
|
||||
}
|
||||
|
@ -148,6 +148,11 @@ const char kEnableCrashReporterForTesting[] =
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
// For testing, do not initialize child service process but also do not exit
|
||||
// (until requested by browser).
|
||||
const char kAndroidSkipChildServiceInitForTesting[] =
|
||||
"android-skip-child-service-init-for-testing";
|
||||
|
||||
// Default country code to be used for search engine localization.
|
||||
const char kDefaultCountryCodeAtInstall[] = "default-country-code";
|
||||
|
||||
|
@ -50,6 +50,7 @@ extern const char kEnableCrashReporterForTesting[];
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
extern const char kAndroidSkipChildServiceInitForTesting[];
|
||||
extern const char kDefaultCountryCodeAtInstall[];
|
||||
extern const char kEnableIdleTracing[];
|
||||
extern const char kHostPackageName[];
|
||||
|
@ -8,7 +8,6 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
@ -37,7 +36,6 @@ import org.chromium.base.process_launcher.ChildProcessConnection;
|
||||
import org.chromium.base.process_launcher.FileDescriptorInfo;
|
||||
import org.chromium.base.test.util.Criteria;
|
||||
import org.chromium.base.test.util.CriteriaHelper;
|
||||
import org.chromium.base.test.util.DisableIf;
|
||||
import org.chromium.base.test.util.DisabledTest;
|
||||
import org.chromium.base.test.util.Feature;
|
||||
import org.chromium.content_public.browser.test.ContentJUnit4ClassRunner;
|
||||
@ -55,7 +53,7 @@ public class ChildProcessLauncherHelperTest {
|
||||
// Allowing the process to continue would lead to a crash when attempting to initialize IPC
|
||||
// channels that are not being set up in this test.
|
||||
private static final String[] sProcessWaitArguments = {
|
||||
"_", "--" + BaseSwitches.RENDERER_WAIT_FOR_JAVA_DEBUGGER
|
||||
"_", "--" + BaseSwitches.ANDROID_SKIP_CHILD_SERVICE_INIT_FOR_TESTING
|
||||
};
|
||||
private static final String DEFAULT_SANDBOXED_PROCESS_SERVICE =
|
||||
"org.chromium.content.app.SandboxedProcessService";
|
||||
@ -267,9 +265,6 @@ public class ChildProcessLauncherHelperTest {
|
||||
@Test
|
||||
@MediumTest
|
||||
@Feature({"ProcessManagement"})
|
||||
@DisableIf.Build(
|
||||
sdk_is_greater_than = Build.VERSION_CODES.TIRAMISU,
|
||||
message = "Broken in 14+, crbug.com/354765949")
|
||||
public void testWarmUp() {
|
||||
// Use the default creation parameters.
|
||||
testWarmUpImpl();
|
||||
@ -278,9 +273,6 @@ public class ChildProcessLauncherHelperTest {
|
||||
@Test
|
||||
@MediumTest
|
||||
@Feature({"ProcessManagement"})
|
||||
@DisableIf.Build(
|
||||
sdk_is_greater_than = Build.VERSION_CODES.TIRAMISU,
|
||||
message = "Broken in 14+, crbug.com/354765949")
|
||||
public void testWarmUpWithBindToCaller() {
|
||||
Context context = InstrumentationRegistry.getTargetContext();
|
||||
ChildProcessCreationParamsImpl.set(
|
||||
@ -299,9 +291,6 @@ public class ChildProcessLauncherHelperTest {
|
||||
@Test
|
||||
@MediumTest
|
||||
@Feature({"ProcessManagement"})
|
||||
@DisableIf.Build(
|
||||
sdk_is_greater_than = Build.VERSION_CODES.TIRAMISU,
|
||||
message = "Broken in 14+, crbug.com/354765949")
|
||||
public void testWarmUpProcessCrashBeforeUse() {
|
||||
Assert.assertEquals(0, getConnectedSandboxedServicesCount());
|
||||
|
||||
@ -329,9 +318,6 @@ public class ChildProcessLauncherHelperTest {
|
||||
@Test
|
||||
@MediumTest
|
||||
@Feature({"ProcessManagement"})
|
||||
@DisableIf.Build(
|
||||
sdk_is_greater_than = Build.VERSION_CODES.TIRAMISU,
|
||||
message = "Broken in 14+, crbug.com/354765949")
|
||||
public void testWarmUpProcessCrashAfterUse() {
|
||||
Context context = InstrumentationRegistry.getTargetContext();
|
||||
warmUpOnUiThreadBlocking(context);
|
||||
@ -356,9 +342,6 @@ public class ChildProcessLauncherHelperTest {
|
||||
@Test
|
||||
@MediumTest
|
||||
@Feature({"ProcessManagement"})
|
||||
@DisableIf.Build(
|
||||
sdk_is_greater_than = Build.VERSION_CODES.TIRAMISU,
|
||||
message = "Broken in 14+, crbug.com/354765949")
|
||||
public void testLauncherCleanup() {
|
||||
ChildProcessLauncherHelperImpl launcher =
|
||||
startSandboxedChildProcess(BLOCK_UNTIL_SETUP, /* doSetupConnection= */ true);
|
||||
|
Reference in New Issue
Block a user