Chromium Code Reviews| Index: content/public/android/javatests/src/org/chromium/content/browser/ChildProcessLauncherTest.java |
| diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ChildProcessLauncherTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ChildProcessLauncherTest.java |
| index 276547534550a2561e139d1890a67475f1a2fcbc..d5f71b1aa35d380db2ad328e6c5453864c21dbda 100644 |
| --- a/content/public/android/javatests/src/org/chromium/content/browser/ChildProcessLauncherTest.java |
| +++ b/content/public/android/javatests/src/org/chromium/content/browser/ChildProcessLauncherTest.java |
| @@ -24,6 +24,7 @@ import org.chromium.base.test.util.CommandLineFlags; |
| import org.chromium.base.test.util.Feature; |
| import org.chromium.content.browser.test.util.Criteria; |
| import org.chromium.content.browser.test.util.CriteriaHelper; |
| +import org.chromium.content.common.ContentSwitches; |
| import org.chromium.content.common.FileDescriptorInfo; |
| import org.chromium.content_shell_apk.ChildProcessLauncherTestHelperService; |
| @@ -451,14 +452,37 @@ public class ChildProcessLauncherTest extends InstrumentationTestCase { |
| ChildProcessLauncher.warmUp(context); // Not on UI thread. |
| assertEquals(1, allocatedChromeSandboxedConnectionsCount()); |
| - final ChildProcessConnection conn = ChildProcessLauncher.startForTesting(context, |
| - new String[0], new FileDescriptorInfo[0], |
| - getDefaultChildProcessCreationParams(context.getPackageName())); |
| + final ChildProcessConnection conn = ChildProcessLauncher.startForTesting( |
| + context, new String[0], new FileDescriptorInfo[0], null); |
| assertEquals(1, allocatedChromeSandboxedConnectionsCount()); // Used warmup connection. |
| ChildProcessLauncher.stop(conn.getPid()); |
| } |
| + @MediumTest |
| + @Feature({"ProcessManagement"}) |
| + public void testCustomCreationParamDoesNotReuseWarmupConnection() { |
| + // Since warmUp only uses default params. |
| + Context context = getInstrumentation().getTargetContext(); |
| + // Check uses object identity, having the params match exactly is fine. |
| + ChildProcessCreationParams.registerDefault( |
| + getDefaultChildProcessCreationParams(context.getPackageName())); |
| + int paramId = ChildProcessCreationParams.register( |
| + getDefaultChildProcessCreationParams(context.getPackageName())); |
| + |
| + ChildProcessLauncher.warmUp(context); // Not on UI thread. |
| + assertEquals(1, allocatedChromeSandboxedConnectionsCount()); |
| + |
| + startChildProcess(context, paramId, new FileDescriptorInfo[0]); |
| + assertEquals(2, allocatedChromeSandboxedConnectionsCount()); // Warmup not used. |
| + |
| + startChildProcess( |
| + context, ChildProcessCreationParams.DEFAULT_ID, new FileDescriptorInfo[0]); |
| + assertEquals(2, allocatedChromeSandboxedConnectionsCount()); // Warmup used. |
| + |
| + ChildProcessCreationParams.unregister(paramId); |
| + } |
| + |
| private ChildProcessConnectionImpl startConnection() { |
| // Allocate a new connection. |
| Context context = getInstrumentation().getTargetContext(); |
| @@ -477,6 +501,14 @@ public class ChildProcessLauncherTest extends InstrumentationTestCase { |
| return connection; |
| } |
| + private static void startChildProcess( |
|
Ted C
2017/02/27 22:25:18
maybe startRendererProcess since this hardcodes th
boliu
2017/02/27 23:43:02
Done.
|
| + Context context, int paramId, FileDescriptorInfo[] filesToMap) { |
| + ChildProcessLauncher.start(context, paramId, |
| + new String[] {"--" + ContentSwitches.SWITCH_PROCESS_TYPE + "=" |
| + + ContentSwitches.SWITCH_RENDERER_PROCESS}, |
| + 0 /* childProcessId */, filesToMap, 0 /* clientContext */); |
| + } |
| + |
| /** |
| * Returns a new connection if it is allocated. Note this function only allocates a connection |
| * but doesn't really start the connection to bind a service. It is for testing whether the |