| Index: chrome/android/javatests/src/org/chromium/chrome/browser/BindingManagerIntegrationTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/BindingManagerIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/BindingManagerIntegrationTest.java
|
| index d8d7829974b8ac3f92f7ac08e4c178bf1cfaff8c..8837d040afd039eac374a128ab4b2b27c67e3ec2 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/BindingManagerIntegrationTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/BindingManagerIntegrationTest.java
|
| @@ -4,6 +4,8 @@
|
|
|
| package org.chromium.chrome.browser;
|
|
|
| +import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_END_DEVICE;
|
| +
|
| import android.content.Context;
|
| import android.test.FlakyTest;
|
| import android.test.suitebuilder.annotation.LargeTest;
|
| @@ -13,6 +15,7 @@ import android.util.SparseBooleanArray;
|
| import org.chromium.base.ThreadUtils;
|
| import org.chromium.base.test.util.CommandLineFlags;
|
| import org.chromium.base.test.util.Feature;
|
| +import org.chromium.base.test.util.Restriction;
|
| import org.chromium.chrome.browser.compositor.layouts.Layout;
|
| import org.chromium.chrome.browser.tab.Tab;
|
| import org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator;
|
| @@ -116,6 +119,8 @@ public class BindingManagerIntegrationTest extends ChromeActivityTestCaseBase<Ch
|
| private static final String FILE_PATH = "chrome/test/data/android/test.html";
|
| // about:version will always be handled by a different renderer than a local file.
|
| private static final String ABOUT_VERSION_PATH = "chrome://version/";
|
| + private static final String SHARED_RENDERER_PAGE_PATH =
|
| + "chrome/test/data/android/bindingmanager/shared_renderer1.html";
|
|
|
| public BindingManagerIntegrationTest() {
|
| super(ChromeActivity.class);
|
| @@ -478,6 +483,96 @@ public class BindingManagerIntegrationTest extends ChromeActivityTestCaseBase<Ch
|
| assertTrue(mBindingManager.isReleaseAllModerateBindingsCalled());
|
| }
|
|
|
| + @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
|
| + @LargeTest
|
| + @Feature({"ProcessManagement"})
|
| + public void testRestoreSharedRenderer() throws Exception {
|
| + loadUrl(TestHttpServerClient.getUrl(SHARED_RENDERER_PAGE_PATH));
|
| +
|
| + final Tab[] tabs = new Tab[2];
|
| + tabs[0] = getActivity().getActivityTab();
|
| + singleClickView(tabs[0].getView());
|
| +
|
| + assertTrue("Child tab isn't opened.", CriteriaHelper.pollForCriteria(new Criteria() {
|
| + @Override
|
| + public boolean isSatisfied() {
|
| + return getActivity().getCurrentTabModel().getCount() == 2
|
| + && getActivity()
|
| + .getActivityTab()
|
| + .getContentViewCore()
|
| + .getCurrentRenderProcessId()
|
| + != 0;
|
| + }
|
| + }));
|
| + tabs[1] = getActivity().getActivityTab();
|
| + assertEquals(tabs[0].getContentViewCore().getCurrentRenderProcessId(),
|
| + tabs[1].getContentViewCore().getCurrentRenderProcessId());
|
| +
|
| + getInstrumentation().runOnMainSync(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + // Verify the visibility of the renderer.
|
| + assertTrue(mBindingManager.isInForeground(
|
| + tabs[0].getContentViewCore().getCurrentRenderProcessId()));
|
| + }
|
| + });
|
| +
|
| + assertTrue(ChildProcessLauncher.crashProcessForTesting(
|
| + tabs[1].getContentViewCore().getCurrentRenderProcessId()));
|
| +
|
| + assertTrue("Renderer crash wasn't noticed by the browser.",
|
| + CriteriaHelper.pollForCriteria(new Criteria() {
|
| + @Override
|
| + public boolean isSatisfied() {
|
| + return tabs[1].getContentViewCore().getCurrentRenderProcessId() == 0;
|
| + }
|
| + }));
|
| + // Reload the tab, respawning the renderer.
|
| + getInstrumentation().runOnMainSync(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + tabs[1].reload();
|
| + }
|
| + });
|
| +
|
| + // Wait until the process is spawned and its visibility is determined.
|
| + assertTrue("Process for the crashed tab was not respawned.",
|
| + CriteriaHelper.pollForCriteria(new Criteria() {
|
| + @Override
|
| + public boolean isSatisfied() {
|
| + return tabs[1].getContentViewCore().getCurrentRenderProcessId() != 0;
|
| + }
|
| + }));
|
| +
|
| + assertTrue("isInForeground() was not called for the process.",
|
| + CriteriaHelper.pollForCriteria(new Criteria() {
|
| + @Override
|
| + public boolean isSatisfied() {
|
| + return mBindingManager.setInForegroundWasCalled(
|
| + tabs[1].getContentViewCore().getCurrentRenderProcessId());
|
| + }
|
| + }));
|
| +
|
| + getInstrumentation().runOnMainSync(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + // Verify the visibility of the renderer.
|
| + assertTrue(mBindingManager.isInForeground(
|
| + tabs[1].getContentViewCore().getCurrentRenderProcessId()));
|
| + tabs[1].hide();
|
| + }
|
| + });
|
| +
|
| + assertTrue("Renderer process isn't gone to the background.",
|
| + CriteriaHelper.pollForCriteria(new Criteria() {
|
| + @Override
|
| + public boolean isSatisfied() {
|
| + return mBindingManager.isInBackground(
|
| + tabs[1].getContentViewCore().getCurrentRenderProcessId());
|
| + }
|
| + }));
|
| + }
|
| +
|
| @Override
|
| public void startMainActivity() throws InterruptedException {
|
| startMainActivityOnBlankPage();
|
|
|