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

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

Issue 2655463012: Really de-flake ChildProcessLauncherTest#testBindServiceFromMultipleProcesses. (Closed)
Patch Set: Simpler poll criteria. Created 3 years, 11 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
« 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 5f1a34bddfcf90b848a82669554103450e683072..2b782cf5f30f0b2cc4cdadda44d4c26a81263a1a 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
@@ -27,7 +27,6 @@ import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.common.FileDescriptorInfo;
import org.chromium.content_shell_apk.ChildProcessLauncherTestHelperService;
-import java.util.Map;
import java.util.concurrent.Callable;
/**
@@ -399,50 +398,50 @@ public class ChildProcessLauncherTest extends InstrumentationTestCase {
}
});
- triggerConnectionSetup((ChildProcessConnectionImpl) conn);
-
assertEquals(0, conn.getServiceNumber());
- assertEquals(-1, conn.getPid()); // PID gets set to -1 if service is already bound.
- final Map<Integer, ChildProcessConnection> serviceMap =
- ChildProcessLauncher.getServiceMapForTesting();
+ final ChildProcessConnection[] sandboxedConnections =
+ ChildProcessLauncher.getSandboxedConnectionArrayForTesting(
+ context.getPackageName());
// Wait for the retry to succeed.
CriteriaHelper.pollInstrumentationThread(
new Criteria("Failed waiting for both child process services") {
@Override
public boolean isSatisfied() {
- boolean allChildrenConnected = serviceMap.size() == 2;
- for (ChildProcessConnection conn : serviceMap.values()) {
- allChildrenConnected &= conn.getService() != null;
+ boolean allChildrenConnected = true;
+ for (int i = 0; i <= 1; ++i) {
+ ChildProcessConnection conn = sandboxedConnections[i];
+ allChildrenConnected &= conn != null && conn.getService() != null;
}
return allChildrenConnected;
}
});
- assertEquals(2, serviceMap.size());
-
- boolean testedSlot0 = false, testedSlot1 = false;
-
- for (ChildProcessConnection childProcess : serviceMap.values()) {
- if (childProcess == conn) {
- assertFalse(testedSlot0);
- assertEquals(0, childProcess.getServiceNumber());
- assertEquals(-1, childProcess.getPid());
- assertFalse(childProcess.getService().bindToCaller());
- testedSlot0 = true;
+ // Check that only two connections are created.
+ for (int i = 0; i < sandboxedConnections.length; ++i) {
+ ChildProcessConnection sandboxedConn = sandboxedConnections[i];
+ if (i <= 1) {
+ assertNotNull(sandboxedConn);
+ assertNotNull(sandboxedConn.getService());
} else {
- assertFalse(testedSlot1);
- assertEquals(1, childProcess.getServiceNumber());
- assertTrue(childProcess.getPid() > 0);
- assertTrue(childProcess.getPid() != helperConnPid);
- assertTrue(childProcess.getService().bindToCaller());
- testedSlot1 = true;
+ assertNull(sandboxedConn);
}
}
- assertTrue(testedSlot0);
- assertTrue(testedSlot1);
+ assertTrue(conn == sandboxedConnections[0]);
+ final ChildProcessConnection retryConn = sandboxedConnections[1];
+
+ assertFalse(conn == retryConn);
+
+ assertEquals(0, conn.getServiceNumber());
+ assertEquals(0, conn.getPid());
+ assertFalse(conn.getService().bindToCaller());
+
+ assertEquals(1, retryConn.getServiceNumber());
+ assertTrue(retryConn.getPid() > 0);
+ assertTrue(retryConn.getPid() != helperConnPid);
+ assertTrue(retryConn.getService().bindToCaller());
}
private ChildProcessConnectionImpl startConnection() {
« 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