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 5f1a34bddfcf90b848a82669554103450e683072..b95b2f894a578e1b25cfeb89dde7ca6561fa74bc 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,43 @@ 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 < sandboxedConnections.length; ++i) { |
| + ChildProcessConnection conn = sandboxedConnections[i]; |
| + if (i <= 1) { |
| + allChildrenConnected &= conn != null && conn.getService() != null; |
| + } else { |
| + allChildrenConnected &= conn == null; |
|
boliu
2017/01/26 19:00:35
is there any reason to check this?
Robert Sesek
2017/01/26 19:27:01
Just to ensure the retry only happens once.
boliu
2017/01/26 19:30:28
You can check that after the poll, this just makes
Robert Sesek
2017/01/26 19:47:24
Done.
|
| + } |
| } |
| 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; |
| - } else { |
| - assertFalse(testedSlot1); |
| - assertEquals(1, childProcess.getServiceNumber()); |
| - assertTrue(childProcess.getPid() > 0); |
| - assertTrue(childProcess.getPid() != helperConnPid); |
| - assertTrue(childProcess.getService().bindToCaller()); |
| - testedSlot1 = true; |
| - } |
| - } |
| + assertTrue(conn == sandboxedConnections[0]); |
| + final ChildProcessConnection retryConn = sandboxedConnections[1]; |
| + |
| + assertFalse(conn == retryConn); |
| + |
| + assertEquals(0, conn.getServiceNumber()); |
| + assertEquals(0, conn.getPid()); |
| + assertFalse(conn.getService().bindToCaller()); |
| - assertTrue(testedSlot0); |
| - assertTrue(testedSlot1); |
| + assertEquals(1, retryConn.getServiceNumber()); |
| + assertTrue(retryConn.getPid() > 0); |
| + assertTrue(retryConn.getPid() != helperConnPid); |
| + assertTrue(retryConn.getService().bindToCaller()); |
| } |
| private ChildProcessConnectionImpl startConnection() { |