Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1562)

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/ChildProcessLauncherTest.java

Issue 2705133002: android: Allow registering multiple CreationParams (Closed)
Patch Set: explode loudly if param not found Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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(
+ 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

Powered by Google App Engine
This is Rietveld 408576698