| Index: base/android/junit/src/org/chromium/base/process_launcher/BindingManagerImplTest.java
|
| diff --git a/content/public/android/junit/src/org/chromium/content/browser/BindingManagerImplTest.java b/base/android/junit/src/org/chromium/base/process_launcher/BindingManagerImplTest.java
|
| similarity index 96%
|
| rename from content/public/android/junit/src/org/chromium/content/browser/BindingManagerImplTest.java
|
| rename to base/android/junit/src/org/chromium/base/process_launcher/BindingManagerImplTest.java
|
| index 42578238305513ab3cb7e24e3ef3b90c16606d7e..e89f01daf879fc876108f8beafc1d621af03dd7a 100644
|
| --- a/content/public/android/junit/src/org/chromium/content/browser/BindingManagerImplTest.java
|
| +++ b/base/android/junit/src/org/chromium/base/process_launcher/BindingManagerImplTest.java
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -package org.chromium.content.browser;
|
| +package org.chromium.base.process_launcher;
|
|
|
| import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL;
|
| import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW;
|
| @@ -10,9 +10,9 @@ import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE;
|
|
|
| import android.app.Activity;
|
| import android.app.Application;
|
| +import android.os.Handler;
|
| import android.util.Pair;
|
|
|
| -import org.junit.After;
|
| import org.junit.Assert;
|
| import org.junit.Before;
|
| import org.junit.Test;
|
| @@ -21,7 +21,6 @@ import org.robolectric.Robolectric;
|
| import org.robolectric.annotation.Config;
|
| import org.robolectric.shadows.ShadowLooper;
|
|
|
| -import org.chromium.base.process_launcher.ChildProcessCreationParams;
|
| import org.chromium.base.test.util.Feature;
|
| import org.chromium.testing.local.LocalRobolectricTestRunner;
|
|
|
| @@ -67,7 +66,7 @@ public class BindingManagerImplTest {
|
| * connection is established: with initial binding bound and no strong binding.
|
| */
|
| private TestChildProcessConnection(int pid) {
|
| - super(null /* context */, pid /* number */, true /* sandboxed */,
|
| + super(new Handler(), null /* context */, pid /* number */, true /* sandboxed */,
|
| null /* deathCallback */, null /* serviceClassName */,
|
| null /* childProcessCommonParameters */,
|
| new ChildProcessCreationParams("org.chromium.test",
|
| @@ -112,7 +111,7 @@ public class BindingManagerImplTest {
|
| */
|
| private static class ManagerEntry {
|
| BindingManagerImpl mManager;
|
| - String mLabel; // Name of the manager.
|
| + String mLabel; // Name of the manager.
|
|
|
| ManagerEntry(BindingManagerImpl manager, String label) {
|
| mManager = manager;
|
| @@ -134,30 +133,20 @@ public class BindingManagerImplTest {
|
|
|
| @Before
|
| public void setUp() {
|
| - // The tests run on only one thread. Pretend that is the launcher thread so LauncherThread
|
| - // asserts are not triggered.
|
| - LauncherThread.setCurrentThreadAsLauncherThread();
|
| -
|
| mActivity = Robolectric.buildActivity(Activity.class).setup().get();
|
| -
|
| - mLowEndManager =
|
| - BindingManagerImpl.createBindingManagerForTesting(true /* isLowEndDevice */);
|
| - mHighEndManager =
|
| - BindingManagerImpl.createBindingManagerForTesting(false /* isLowEndDevice */);
|
| - mModerateBindingManager =
|
| - BindingManagerImpl.createBindingManagerForTesting(false /* isLowEndDevice */);
|
| + Handler handler = new Handler();
|
| + mLowEndManager = BindingManagerImpl.createBindingManagerForTesting(
|
| + handler, true /* isLowEndDevice */);
|
| + mHighEndManager = BindingManagerImpl.createBindingManagerForTesting(
|
| + handler, false /* isLowEndDevice */);
|
| + mModerateBindingManager = BindingManagerImpl.createBindingManagerForTesting(
|
| + handler, false /* isLowEndDevice */);
|
| mModerateBindingManager.startModerateBindingManagement(mActivity, 4 /* maxSize */);
|
| - mAllManagers = new ManagerEntry[] {
|
| - new ManagerEntry(mLowEndManager, "low-end"),
|
| + mAllManagers = new ManagerEntry[] {new ManagerEntry(mLowEndManager, "low-end"),
|
| new ManagerEntry(mHighEndManager, "high-end"),
|
| new ManagerEntry(mModerateBindingManager, "moderate-binding")};
|
| }
|
|
|
| - @After
|
| - public void tearDown() {
|
| - LauncherThread.setLauncherThreadAsLauncherThread();
|
| - }
|
| -
|
| /**
|
| * Verifies that when running on low-end, the binding manager drops the oom bindings for the
|
| * previously bound connection when a new connection is used in foreground.
|
| @@ -614,7 +603,8 @@ public class BindingManagerImplTest {
|
| @Test
|
| @Feature({"ProcessManagement"})
|
| public void testModerateBindingTillBackgroundedBackgroundProcess() {
|
| - BindingManagerImpl manager = BindingManagerImpl.createBindingManagerForTesting(false);
|
| + BindingManagerImpl manager =
|
| + BindingManagerImpl.createBindingManagerForTesting(new Handler(), false);
|
| manager.startModerateBindingManagement(mActivity, 4);
|
|
|
| TestChildProcessConnection connection = new TestChildProcessConnection(0);
|
| @@ -636,7 +626,8 @@ public class BindingManagerImplTest {
|
| @Test
|
| @Feature({"ProcessManagement"})
|
| public void testModerateBindingTillBackgroundedForegroundProcess() {
|
| - BindingManagerImpl manager = BindingManagerImpl.createBindingManagerForTesting(false);
|
| + BindingManagerImpl manager =
|
| + BindingManagerImpl.createBindingManagerForTesting(new Handler(), false);
|
| manager.startModerateBindingManagement(mActivity, 4);
|
|
|
| TestChildProcessConnection connection = new TestChildProcessConnection(0);
|
| @@ -660,7 +651,8 @@ public class BindingManagerImplTest {
|
| @Test
|
| @Feature({"ProcessManagement"})
|
| public void testModerateBindingTillBackgroundedSentToBackground() {
|
| - BindingManagerImpl manager = BindingManagerImpl.createBindingManagerForTesting(false);
|
| + BindingManagerImpl manager =
|
| + BindingManagerImpl.createBindingManagerForTesting(new Handler(), false);
|
| manager.startModerateBindingManagement(mActivity, 4);
|
|
|
| TestChildProcessConnection connection = new TestChildProcessConnection(0);
|
|
|