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

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

Issue 704573002: Android: Use a spawning queue for child processes while we are at capacity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for assert message. Created 6 years 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
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2481eaafde431ee9496a296365aeee61e9578399..22a6a446c6fce24fca3920ce28d7197b2164c813 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,7 +24,7 @@ public class ChildProcessLauncherTest extends InstrumentationTestCase {
@MediumTest
@Feature({"ProcessManagement"})
public void testServiceFailedToBind() throws InterruptedException, RemoteException {
- Context appContext = getInstrumentation().getTargetContext();
+ final Context appContext = getInstrumentation().getTargetContext();
assertEquals(0, ChildProcessLauncher.allocatedConnectionsCountForTesting(appContext));
assertEquals(0, ChildProcessLauncher.connectedServicesCountForTesting());
@@ -35,8 +35,22 @@ public class ChildProcessLauncherTest extends InstrumentationTestCase {
ChildProcessLauncher.allocateBoundConnectionForTesting(context);
// Verify that the connection is not considered as allocated.
- assertEquals(0, ChildProcessLauncher.allocatedConnectionsCountForTesting(appContext));
- assertEquals(0, ChildProcessLauncher.connectedServicesCountForTesting());
+ assertTrue("Failed connection wasn't released from the allocator.",
+ CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return ChildProcessLauncher.allocatedConnectionsCountForTesting(
+ appContext) == 0;
+ }
+ }));
+
+ assertTrue("Failed connection wasn't released from ChildProcessLauncher.",
+ CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return ChildProcessLauncher.connectedServicesCountForTesting() == 0;
+ }
+ }));
}
/**
@@ -138,6 +152,75 @@ public class ChildProcessLauncherTest extends InstrumentationTestCase {
assertTrue(connection.getPid() != 0);
}
+ /**
+ * Tests spawning a pending process from queue.
+ */
+ @MediumTest
+ @Feature({"ProcessManagement"})
+ public void testPendingSpawnQueue() throws InterruptedException, RemoteException {
+ final Context appContext = getInstrumentation().getTargetContext();
+ assertEquals(0, ChildProcessLauncher.allocatedConnectionsCountForTesting(appContext));
+
+ // Start and connect to a new service.
+ final ChildProcessConnectionImpl connection = startConnection();
+ assertEquals(1, ChildProcessLauncher.allocatedConnectionsCountForTesting(appContext));
+
+ // Queue up a a new spawn request.
+ ChildProcessLauncher.enqueuePendingSpawnForTesting(appContext);
+ assertEquals(1, ChildProcessLauncher.pendingSpawnsCountForTesting());
+
+ // Initiate the connection setup.
+ ChildProcessLauncher.triggerConnectionSetup(connection, new String[0], 1,
+ new FileDescriptorInfo[0], ChildProcessLauncher.CALLBACK_FOR_RENDERER_PROCESS, 0);
+
+ // Verify that the connection completes the setup.
+ assertTrue("The connection wasn't registered in ChildProcessLauncher after setup.",
+ CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return ChildProcessLauncher.connectedServicesCountForTesting() == 1;
+ }
+ }));
+
+ assertTrue("The connection failed to get a pid in setup.",
+ CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return connection.getPid() != 0;
+ }
+ }));
+
+ // Crash the service.
+ assertTrue(connection.crashServiceForTesting());
+
+ // Verify that a new service is started for the pending spawn.
+ assertTrue("Failed to spawn from queue.",
+ CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return ChildProcessLauncher.pendingSpawnsCountForTesting() == 0;
+ }
+ }));
+
+ assertTrue("The connection wasn't allocated for the pending spawn.",
+ CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return ChildProcessLauncher.allocatedConnectionsCountForTesting(
+ appContext) == 1;
+ }
+ }));
+
+ // Verify that the connection completes the setup for the pending spawn.
+ assertTrue("The connection wasn't registered in ChildProcessLauncher after setup.",
+ CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return ChildProcessLauncher.connectedServicesCountForTesting() == 1;
+ }
+ }));
+ }
+
private ChildProcessConnectionImpl startConnection() throws InterruptedException {
// Allocate a new connection.
Context context = getInstrumentation().getTargetContext();
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698