| OLD | NEW |
| 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 android.content.Context; | 7 import android.content.Context; |
| 8 import android.support.test.filters.LargeTest; | 8 import android.support.test.filters.LargeTest; |
| 9 import android.test.MoreAsserts; | 9 import android.test.MoreAsserts; |
| 10 import android.util.SparseArray; | 10 import android.util.SparseArray; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 private MockBindingManager mBindingManager; | 152 private MockBindingManager mBindingManager; |
| 153 private EmbeddedTestServer mTestServer; | 153 private EmbeddedTestServer mTestServer; |
| 154 | 154 |
| 155 private static final String FILE_PATH = "/chrome/test/data/android/test.html
"; | 155 private static final String FILE_PATH = "/chrome/test/data/android/test.html
"; |
| 156 private static final String FILE_PATH2 = "/chrome/test/data/android/simple.h
tml"; | 156 private static final String FILE_PATH2 = "/chrome/test/data/android/simple.h
tml"; |
| 157 // about:version will always be handled by a different renderer than a local
file. | 157 // about:version will always be handled by a different renderer than a local
file. |
| 158 private static final String ABOUT_VERSION_PATH = "chrome://version/"; | 158 private static final String ABOUT_VERSION_PATH = "chrome://version/"; |
| 159 private static final String SHARED_RENDERER_PAGE_PATH = | 159 private static final String SHARED_RENDERER_PAGE_PATH = |
| 160 "/chrome/test/data/android/bindingmanager/shared_renderer1.html"; | 160 "/chrome/test/data/android/bindingmanager/shared_renderer1.html"; |
| 161 private static final String SHARED_RENDERER_PAGE2_PATH = |
| 162 "/chrome/test/data/android/bindingmanager/shared_renderer2.html"; |
| 161 | 163 |
| 162 public BindingManagerIntegrationTest() { | 164 public BindingManagerIntegrationTest() { |
| 163 super(ChromeActivity.class); | 165 super(ChromeActivity.class); |
| 164 } | 166 } |
| 165 | 167 |
| 166 /** | 168 /** |
| 167 * Verifies that the .setProcessInForeground() signal is called correctly as
the tabs are | 169 * Verifies that the .setProcessInForeground() signal is called correctly as
the tabs are |
| 168 * created and switched. | 170 * created and switched. |
| 169 */ | 171 */ |
| 170 @LargeTest | 172 @LargeTest |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 343 } |
| 342 | 344 |
| 343 /** | 345 /** |
| 344 * Verifies that a renderer that crashes in foreground has the correct visib
ility when | 346 * Verifies that a renderer that crashes in foreground has the correct visib
ility when |
| 345 * recreated. | 347 * recreated. |
| 346 */ | 348 */ |
| 347 @LargeTest | 349 @LargeTest |
| 348 @Feature({"ProcessManagement"}) | 350 @Feature({"ProcessManagement"}) |
| 349 public void testCrashInForeground() throws InterruptedException { | 351 public void testCrashInForeground() throws InterruptedException { |
| 350 // Create a tab in foreground and wait until it is loaded. | 352 // Create a tab in foreground and wait until it is loaded. |
| 353 final String testUrl = mTestServer.getURL(FILE_PATH); |
| 351 final Tab tab = ThreadUtils.runOnUiThreadBlockingNoException( | 354 final Tab tab = ThreadUtils.runOnUiThreadBlockingNoException( |
| 352 new Callable<Tab>() { | 355 new Callable<Tab>() { |
| 353 @Override | 356 @Override |
| 354 public Tab call() throws Exception { | 357 public Tab call() throws Exception { |
| 355 TabCreator tabCreator = getActivity().getCurrentTabCreat
or(); | 358 TabCreator tabCreator = getActivity().getCurrentTabCreat
or(); |
| 356 return tabCreator.createNewTab( | 359 return tabCreator.createNewTab( |
| 357 new LoadUrlParams(mTestServer.getURL(FILE_PATH))
, | 360 new LoadUrlParams(testUrl), TabLaunchType.FROM_C
HROME_UI, null); |
| 358 TabLaunchType.FROM_CHROME_UI, null); | |
| 359 } | 361 } |
| 360 }); | 362 }); |
| 361 ChromeTabUtils.waitForTabPageLoaded(tab, mTestServer.getURL(FILE_PATH)); | 363 ChromeTabUtils.waitForTabPageLoaded(tab, testUrl); |
| 362 getInstrumentation().waitForIdleSync(); | 364 getInstrumentation().waitForIdleSync(); |
| 363 | 365 |
| 364 // Kill the renderer and wait for the crash to be noted by the browser p
rocess. | 366 // Kill the renderer and wait for the crash to be noted by the browser p
rocess. |
| 365 assertTrue(ChildProcessLauncher.crashProcessForTesting( | 367 assertTrue(ChildProcessLauncher.crashProcessForTesting( |
| 366 tab.getContentViewCore().getCurrentRenderProcessId())); | 368 tab.getContentViewCore().getCurrentRenderProcessId())); |
| 367 | 369 |
| 368 CriteriaHelper.pollInstrumentationThread( | 370 CriteriaHelper.pollInstrumentationThread( |
| 369 new Criteria("Renderer crash wasn't noticed by the browser.") { | 371 new Criteria("Renderer crash wasn't noticed by the browser.") { |
| 370 @Override | 372 @Override |
| 371 public boolean isSatisfied() { | 373 public boolean isSatisfied() { |
| 372 return tab.getContentViewCore().getCurrentRenderProcessI
d() == 0; | 374 return tab.getContentViewCore().getCurrentRenderProcessI
d() == 0; |
| 373 } | 375 } |
| 374 }); | 376 }); |
| 375 | 377 |
| 376 // Reload the tab, respawning the renderer. | 378 // Reload the tab, respawning the renderer. |
| 377 getInstrumentation().runOnMainSync(new Runnable() { | 379 getInstrumentation().runOnMainSync(new Runnable() { |
| 378 @Override | 380 @Override |
| 379 public void run() { | 381 public void run() { |
| 380 tab.reload(); | 382 tab.reload(); |
| 381 } | 383 } |
| 382 }); | 384 }); |
| 383 | 385 |
| 386 ChromeTabUtils.waitForTabPageLoaded(tab, testUrl); |
| 387 |
| 384 // Wait until the process is spawned and its visibility is determined. | 388 // Wait until the process is spawned and its visibility is determined. |
| 385 CriteriaHelper.pollInstrumentationThread( | 389 CriteriaHelper.pollInstrumentationThread( |
| 386 new Criteria("Process for the crashed tab was not respawned.") { | 390 new Criteria("Process for the crashed tab was not respawned.") { |
| 387 @Override | 391 @Override |
| 388 public boolean isSatisfied() { | 392 public boolean isSatisfied() { |
| 389 return tab.getContentViewCore().getCurrentRenderProcessI
d() != 0; | 393 return tab.getContentViewCore().getCurrentRenderProcessI
d() != 0; |
| 390 } | 394 } |
| 391 }); | 395 }); |
| 392 | 396 |
| 393 mBindingManager.assertSetInForegroundWasCalled( | 397 mBindingManager.assertSetInForegroundWasCalled( |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 } | 590 } |
| 587 }); | 591 }); |
| 588 // Reload the tab, respawning the renderer. | 592 // Reload the tab, respawning the renderer. |
| 589 getInstrumentation().runOnMainSync(new Runnable() { | 593 getInstrumentation().runOnMainSync(new Runnable() { |
| 590 @Override | 594 @Override |
| 591 public void run() { | 595 public void run() { |
| 592 tabs[1].reload(); | 596 tabs[1].reload(); |
| 593 } | 597 } |
| 594 }); | 598 }); |
| 595 | 599 |
| 600 ChromeTabUtils.waitForTabPageLoaded( |
| 601 tabs[1], mTestServer.getURL(SHARED_RENDERER_PAGE2_PATH)); |
| 602 |
| 596 // Wait until the process is spawned and its visibility is determined. | 603 // Wait until the process is spawned and its visibility is determined. |
| 597 CriteriaHelper.pollInstrumentationThread( | 604 CriteriaHelper.pollInstrumentationThread( |
| 598 new Criteria("Process for the crashed tab was not respawned.") { | 605 new Criteria("Process for the crashed tab was not respawned.") { |
| 599 @Override | 606 @Override |
| 600 public boolean isSatisfied() { | 607 public boolean isSatisfied() { |
| 601 return tabs[1].getContentViewCore().getCurrentRenderProc
essId() != 0; | 608 return tabs[1].getContentViewCore().getCurrentRenderProc
essId() != 0; |
| 602 } | 609 } |
| 603 }); | 610 }); |
| 604 | 611 |
| 605 mBindingManager.assertSetInForegroundWasCalled( | 612 mBindingManager.assertSetInForegroundWasCalled( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 super.tearDown(); | 648 super.tearDown(); |
| 642 } | 649 } |
| 643 | 650 |
| 644 /** | 651 /** |
| 645 * @return the index of the given tab in the current tab model | 652 * @return the index of the given tab in the current tab model |
| 646 */ | 653 */ |
| 647 private int indexOf(Tab tab) { | 654 private int indexOf(Tab tab) { |
| 648 return getActivity().getCurrentTabModel().indexOf(tab); | 655 return getActivity().getCurrentTabModel().indexOf(tab); |
| 649 } | 656 } |
| 650 } | 657 } |
| OLD | NEW |