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

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

Issue 2821583002: android: Post stop/onServiceDisconnected to launcher (Closed)
Patch Set: rebase Created 3 years, 8 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/LauncherThread.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 3ce51aee8e6b82ea34567adecbf5d6bffb05cd12..ab17b60daf26bc7e316c7e32b00aa35eee67f081 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
@@ -562,48 +562,82 @@ public class ChildProcessLauncherTest extends InstrumentationTestCase {
* but doesn't really start the connection to bind a service. It is for testing whether the
* connection is allocated properly for different application packages.
*/
- private ChildProcessConnectionImpl allocateConnection(String packageName) {
- // Allocate a new connection.
- Context context = getInstrumentation().getTargetContext();
- ChildProcessCreationParams creationParams =
- getDefaultChildProcessCreationParams(packageName);
- return (ChildProcessConnectionImpl) ChildProcessLauncher.allocateConnection(
- new ChildSpawnData(context, null /* commandLine */, 0 /* childProcessId */,
- null /* filesToBeMapped */, null /* launchCallback */,
- null /* childProcessCallback */, true /* inSandbox */,
- false /* alwaysInForeground */, creationParams),
- ChildProcessLauncher.createCommonParamsBundle(creationParams),
- false /* forWarmUp */);
+ private ChildProcessConnectionImpl allocateConnection(final String packageName) {
+ return ChildProcessLauncherTestHelperService.runOnLauncherAndGetResult(
+ new Callable<ChildProcessConnectionImpl>() {
+ @Override
+ public ChildProcessConnectionImpl call() {
+ // Allocate a new connection.
+ Context context = getInstrumentation().getTargetContext();
+ ChildProcessCreationParams creationParams =
+ getDefaultChildProcessCreationParams(packageName);
+ return (ChildProcessConnectionImpl) ChildProcessLauncher.allocateConnection(
+ new ChildSpawnData(context, null /* commandLine */,
+ 0 /* childProcessId */, null /* filesToBeMapped */,
+ null /* launchCallback */, null /* childProcessCallback */,
+ true /* inSandbox */, false /* alwaysInForeground */,
+ creationParams),
+ ChildProcessLauncher.createCommonParamsBundle(creationParams),
+ false /* forWarmUp */);
+ }
+ });
}
- private static void enqueuePendingSpawnForTesting(Context context, String[] commandLine,
- ChildProcessCreationParams creationParams, boolean inSandbox) {
- String packageName =
- creationParams != null ? creationParams.getPackageName() : context.getPackageName();
- ChildConnectionAllocator allocator =
- ChildConnectionAllocator.getAllocator(context, packageName, inSandbox);
- allocator.enqueuePendingQueueForTesting(new ChildSpawnData(context, commandLine,
- 1 /* childProcessId */, new FileDescriptorInfo[0], null /* launchCallback */,
- null /* childProcessCallback */, true /* inSandbox */,
- false /* alwaysInForeground */, creationParams));
+ private static void enqueuePendingSpawnForTesting(final Context context,
+ final String[] commandLine, final ChildProcessCreationParams creationParams,
+ final boolean inSandbox) {
+ ChildProcessLauncherTestHelperService.runOnLauncherThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ String packageName = creationParams != null ? creationParams.getPackageName()
+ : context.getPackageName();
+ ChildConnectionAllocator allocator =
+ ChildConnectionAllocator.getAllocator(context, packageName, inSandbox);
+ allocator.enqueuePendingQueueForTesting(new ChildSpawnData(context, commandLine,
+ 1 /* childProcessId */, new FileDescriptorInfo[0],
+ null /* launchCallback */, null /* childProcessCallback */,
+ true /* inSandbox */, false /* alwaysInForeground */, creationParams));
+ }
+ });
}
private static int allocatedSandboxedConnectionsCountForTesting(
- Context context, String packageName) {
- return ChildConnectionAllocator.getAllocator(context, packageName, true /*isSandboxed */)
- .allocatedConnectionsCountForTesting();
+ final Context context, final String packageName) {
+ return ChildProcessLauncherTestHelperService.runOnLauncherAndGetResult(
+ new Callable<Integer>() {
+ @Override
+ public Integer call() {
+ return ChildConnectionAllocator
+ .getAllocator(context, packageName, true /*isSandboxed */)
+ .allocatedConnectionsCountForTesting();
+ }
+ });
}
private static ChildProcessConnection[] getSandboxedConnectionArrayForTesting(
- Context context, String packageName) {
- return ChildConnectionAllocator.getAllocator(context, packageName, true /*isSandboxed */)
- .connectionArrayForTesting();
+ final Context context, final String packageName) {
+ return ChildProcessLauncherTestHelperService.runOnLauncherAndGetResult(
+ new Callable<ChildProcessConnection[]>() {
+ @Override
+ public ChildProcessConnection[] call() {
+ return ChildConnectionAllocator
+ .getAllocator(context, packageName, true /*isSandboxed */)
+ .connectionArrayForTesting();
+ }
+ });
}
private static int pendingSpawnsCountForTesting(
- Context context, String packageName, boolean inSandbox) {
- return ChildConnectionAllocator.getAllocator(context, packageName, inSandbox)
- .pendingSpawnsCountForTesting();
+ final Context context, final String packageName, final boolean inSandbox) {
+ return ChildProcessLauncherTestHelperService.runOnLauncherAndGetResult(
+ new Callable<Integer>() {
+ @Override
+ public Integer call() {
+ return ChildConnectionAllocator
+ .getAllocator(context, packageName, inSandbox)
+ .pendingSpawnsCountForTesting();
+ }
+ });
}
/**
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/LauncherThread.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698