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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/BindingManagerIntegrationTest.java

Issue 1308623003: Assume crashed RenderWidgetHost to be invisible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply the change to all platforms Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser; 5 package org.chromium.chrome.browser;
6 6
7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E ND_DEVICE;
8
7 import android.content.Context; 9 import android.content.Context;
8 import android.test.FlakyTest; 10 import android.test.FlakyTest;
9 import android.test.suitebuilder.annotation.LargeTest; 11 import android.test.suitebuilder.annotation.LargeTest;
10 import android.util.SparseArray; 12 import android.util.SparseArray;
11 import android.util.SparseBooleanArray; 13 import android.util.SparseBooleanArray;
12 14
13 import org.chromium.base.ThreadUtils; 15 import org.chromium.base.ThreadUtils;
14 import org.chromium.base.test.util.CommandLineFlags; 16 import org.chromium.base.test.util.CommandLineFlags;
15 import org.chromium.base.test.util.Feature; 17 import org.chromium.base.test.util.Feature;
18 import org.chromium.base.test.util.Restriction;
16 import org.chromium.chrome.browser.compositor.layouts.Layout; 19 import org.chromium.chrome.browser.compositor.layouts.Layout;
17 import org.chromium.chrome.browser.tab.Tab; 20 import org.chromium.chrome.browser.tab.Tab;
18 import org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator; 21 import org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator;
19 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; 22 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
20 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; 23 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType;
21 import org.chromium.chrome.browser.tabmodel.TabModelUtils; 24 import org.chromium.chrome.browser.tabmodel.TabModelUtils;
22 import org.chromium.chrome.test.ChromeActivityTestCaseBase; 25 import org.chromium.chrome.test.ChromeActivityTestCaseBase;
23 import org.chromium.chrome.test.util.ChromeTabUtils; 26 import org.chromium.chrome.test.util.ChromeTabUtils;
24 import org.chromium.chrome.test.util.TestHttpServerClient; 27 import org.chromium.chrome.test.util.TestHttpServerClient;
25 import org.chromium.content.browser.BindingManager; 28 import org.chromium.content.browser.BindingManager;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 public void releaseAllModerateBindings() { 112 public void releaseAllModerateBindings() {
110 mIsReleaseAllModerateBindingsCalled = true; 113 mIsReleaseAllModerateBindingsCalled = true;
111 } 114 }
112 } 115 }
113 116
114 private MockBindingManager mBindingManager; 117 private MockBindingManager mBindingManager;
115 118
116 private static final String FILE_PATH = "chrome/test/data/android/test.html" ; 119 private static final String FILE_PATH = "chrome/test/data/android/test.html" ;
117 // about:version will always be handled by a different renderer than a local file. 120 // about:version will always be handled by a different renderer than a local file.
118 private static final String ABOUT_VERSION_PATH = "chrome://version/"; 121 private static final String ABOUT_VERSION_PATH = "chrome://version/";
122 private static final String SHARED_RENDERER_PAGE_PATH =
123 "chrome/test/data/android/bindingmanager/shared_renderer1.html";
119 124
120 public BindingManagerIntegrationTest() { 125 public BindingManagerIntegrationTest() {
121 super(ChromeActivity.class); 126 super(ChromeActivity.class);
122 } 127 }
123 128
124 /** 129 /**
125 * Verifies that the .setProcessInForeground() signal is called correctly as the tabs are 130 * Verifies that the .setProcessInForeground() signal is called correctly as the tabs are
126 * created and switched. 131 * created and switched.
127 */ 132 */
128 @LargeTest 133 @LargeTest
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 // Foreground tab. 476 // Foreground tab.
472 tabs[2] = tabCreator.createNewTab( 477 tabs[2] = tabCreator.createNewTab(
473 new LoadUrlParams("about:blank"), TabLaunchType.FROM_KEY BOARD, null); 478 new LoadUrlParams("about:blank"), TabLaunchType.FROM_KEY BOARD, null);
474 } 479 }
475 }); 480 });
476 ChromeTabUtils.waitForTabPageLoaded(tabs[2], "about:blank"); 481 ChromeTabUtils.waitForTabPageLoaded(tabs[2], "about:blank");
477 // At this point all the sanboxed services are allocated. 482 // At this point all the sanboxed services are allocated.
478 assertTrue(mBindingManager.isReleaseAllModerateBindingsCalled()); 483 assertTrue(mBindingManager.isReleaseAllModerateBindingsCalled());
479 } 484 }
480 485
486 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
no sievers 2015/09/08 19:56:34 Why is the behavior different on low end wrt this
Jaekyun Seok (inactive) 2015/09/08 23:03:55 I thought that this test didn't run on low end bec
487 @LargeTest
488 @Feature({"ProcessManagement"})
489 public void testRestoreSharedRenderer() throws Exception {
490 loadUrl(TestHttpServerClient.getUrl(SHARED_RENDERER_PAGE_PATH));
491
492 final Tab[] tabs = new Tab[2];
493 tabs[0] = getActivity().getActivityTab();
494 singleClickView(tabs[0].getView());
495
496 assertTrue("Child tab isn't opened.", CriteriaHelper.pollForCriteria(new Criteria() {
497 @Override
498 public boolean isSatisfied() {
499 return getActivity().getCurrentTabModel().getCount() == 2
500 && getActivity()
501 .getActivityTab()
502 .getContentViewCore()
503 .getCurrentRenderProcessId()
504 != 0;
505 }
506 }));
507 tabs[1] = getActivity().getActivityTab();
508 assertEquals(tabs[0].getContentViewCore().getCurrentRenderProcessId(),
509 tabs[1].getContentViewCore().getCurrentRenderProcessId());
510
511 getInstrumentation().runOnMainSync(new Runnable() {
512 @Override
513 public void run() {
514 // Verify the visibility of the renderer.
515 assertTrue(mBindingManager.isInForeground(
516 tabs[0].getContentViewCore().getCurrentRenderProcessId() ));
517 }
518 });
519
520 assertTrue(ChildProcessLauncher.crashProcessForTesting(
521 tabs[1].getContentViewCore().getCurrentRenderProcessId()));
522
523 assertTrue("Renderer crash wasn't noticed by the browser.",
524 CriteriaHelper.pollForCriteria(new Criteria() {
525 @Override
526 public boolean isSatisfied() {
527 return tabs[1].getContentViewCore().getCurrentRenderProc essId() == 0;
528 }
529 }));
530 // Reload the tab, respawning the renderer.
531 getInstrumentation().runOnMainSync(new Runnable() {
532 @Override
533 public void run() {
534 tabs[1].reload();
535 }
536 });
537
538 // Wait until the process is spawned and its visibility is determined.
539 assertTrue("Process for the crashed tab was not respawned.",
540 CriteriaHelper.pollForCriteria(new Criteria() {
541 @Override
542 public boolean isSatisfied() {
543 return tabs[1].getContentViewCore().getCurrentRenderProc essId() != 0;
544 }
545 }));
546
547 assertTrue("isInForeground() was not called for the process.",
no sievers 2015/09/08 19:56:34 you mean 'setInForeground()' *was* called?
Jaekyun Seok (inactive) 2015/09/08 23:03:55 This is an error message when the condition is wro
548 CriteriaHelper.pollForCriteria(new Criteria() {
549 @Override
550 public boolean isSatisfied() {
551 return mBindingManager.setInForegroundWasCalled(
552 tabs[1].getContentViewCore().getCurrentRenderPro cessId());
553 }
554 }));
555
556 getInstrumentation().runOnMainSync(new Runnable() {
557 @Override
558 public void run() {
559 // Verify the visibility of the renderer.
560 assertTrue(mBindingManager.isInForeground(
561 tabs[1].getContentViewCore().getCurrentRenderProcessId() ));
562 tabs[1].hide();
563 }
564 });
565
566 assertTrue("Renderer process isn't gone to the background.",
no sievers 2015/09/08 19:56:34 you mean 'renderer process *was* backgrounded'?
Jaekyun Seok (inactive) 2015/09/08 23:03:55 This is an error message when the condition is wro
567 CriteriaHelper.pollForCriteria(new Criteria() {
no sievers 2015/09/08 19:56:34 do we really need to poll for visibility changes?
Jaekyun Seok (inactive) 2015/09/08 23:03:55 I moved the checking behind tabs[1].hide().
568 @Override
569 public boolean isSatisfied() {
570 return mBindingManager.isInBackground(
571 tabs[1].getContentViewCore().getCurrentRenderPro cessId());
572 }
573 }));
574 }
575
481 @Override 576 @Override
482 public void startMainActivity() throws InterruptedException { 577 public void startMainActivity() throws InterruptedException {
483 startMainActivityOnBlankPage(); 578 startMainActivityOnBlankPage();
484 } 579 }
485 580
486 @Override 581 @Override
487 protected void setUp() throws Exception { 582 protected void setUp() throws Exception {
488 super.setUp(); 583 super.setUp();
489 584
490 // Hook in the test binding manager. 585 // Hook in the test binding manager.
491 mBindingManager = new MockBindingManager(); 586 mBindingManager = new MockBindingManager();
492 ChildProcessLauncher.setBindingManagerForTesting(mBindingManager); 587 ChildProcessLauncher.setBindingManagerForTesting(mBindingManager);
493 } 588 }
494 589
495 /** 590 /**
496 * @return the index of the given tab in the current tab model 591 * @return the index of the given tab in the current tab model
497 */ 592 */
498 private int indexOf(Tab tab) { 593 private int indexOf(Tab tab) {
499 return getActivity().getCurrentTabModel().indexOf(tab); 594 return getActivity().getCurrentTabModel().indexOf(tab);
500 } 595 }
501 } 596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698