| 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.os.Environment; | 8 import android.os.Environment; |
| 9 import android.test.MoreAsserts; | 9 import android.test.MoreAsserts; |
| 10 import android.test.suitebuilder.annotation.LargeTest; | 10 import android.test.suitebuilder.annotation.LargeTest; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 public void testTabSwitching() throws InterruptedException { | 185 public void testTabSwitching() throws InterruptedException { |
| 186 // Create two tabs and wait until they are loaded, so that their rendere
rs are around. | 186 // Create two tabs and wait until they are loaded, so that their rendere
rs are around. |
| 187 final Tab[] tabs = new Tab[2]; | 187 final Tab[] tabs = new Tab[2]; |
| 188 getInstrumentation().runOnMainSync(new Runnable() { | 188 getInstrumentation().runOnMainSync(new Runnable() { |
| 189 @Override | 189 @Override |
| 190 public void run() { | 190 public void run() { |
| 191 // Foreground tab. | 191 // Foreground tab. |
| 192 TabCreator tabCreator = getActivity().getCurrentTabCreator(); | 192 TabCreator tabCreator = getActivity().getCurrentTabCreator(); |
| 193 tabs[0] = tabCreator.createNewTab( | 193 tabs[0] = tabCreator.createNewTab( |
| 194 new LoadUrlParams(mTestServer.getURL(FILE_PATH)), | 194 new LoadUrlParams(mTestServer.getURL(FILE_PATH)), |
| 195 TabLaunchType.FROM_KEYBOARD, null); | 195 TabLaunchType.FROM_CHROME_UI, null); |
| 196 // Background tab. | 196 // Background tab. |
| 197 tabs[1] = tabCreator.createNewTab( | 197 tabs[1] = tabCreator.createNewTab( |
| 198 new LoadUrlParams(mTestServer.getURL(FILE_PATH)), | 198 new LoadUrlParams(mTestServer.getURL(FILE_PATH)), |
| 199 TabLaunchType.FROM_LONGPRESS_BACKGROUND, null); | 199 TabLaunchType.FROM_LONGPRESS_BACKGROUND, null); |
| 200 // On Svelte devices the background tab would not be loaded auto
matically, so | 200 // On Svelte devices the background tab would not be loaded auto
matically, so |
| 201 // trigger the load manually. | 201 // trigger the load manually. |
| 202 tabs[1].show(TabSelectionType.FROM_USER); | 202 tabs[1].show(TabSelectionType.FROM_USER); |
| 203 tabs[1].hide(); | 203 tabs[1].hide(); |
| 204 } | 204 } |
| 205 }); | 205 }); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 public void testCrashInBackground() throws InterruptedException { | 256 public void testCrashInBackground() throws InterruptedException { |
| 257 // Create two tabs and wait until they are loaded, so that their rendere
rs are around. | 257 // Create two tabs and wait until they are loaded, so that their rendere
rs are around. |
| 258 final Tab[] tabs = new Tab[2]; | 258 final Tab[] tabs = new Tab[2]; |
| 259 getInstrumentation().runOnMainSync(new Runnable() { | 259 getInstrumentation().runOnMainSync(new Runnable() { |
| 260 @Override | 260 @Override |
| 261 public void run() { | 261 public void run() { |
| 262 // Foreground tab. | 262 // Foreground tab. |
| 263 TabCreator tabCreator = getActivity().getCurrentTabCreator(); | 263 TabCreator tabCreator = getActivity().getCurrentTabCreator(); |
| 264 tabs[0] = tabCreator.createNewTab( | 264 tabs[0] = tabCreator.createNewTab( |
| 265 new LoadUrlParams(mTestServer.getURL(FILE_PATH)), | 265 new LoadUrlParams(mTestServer.getURL(FILE_PATH)), |
| 266 TabLaunchType.FROM_KEYBOARD, null); | 266 TabLaunchType.FROM_CHROME_UI, null); |
| 267 // Background tab. | 267 // Background tab. |
| 268 tabs[1] = tabCreator.createNewTab( | 268 tabs[1] = tabCreator.createNewTab( |
| 269 new LoadUrlParams(mTestServer.getURL(FILE_PATH)), | 269 new LoadUrlParams(mTestServer.getURL(FILE_PATH)), |
| 270 TabLaunchType.FROM_LONGPRESS_BACKGROUND, null); | 270 TabLaunchType.FROM_LONGPRESS_BACKGROUND, null); |
| 271 // On Svelte devices the background tab would not be loaded auto
matically, so | 271 // On Svelte devices the background tab would not be loaded auto
matically, so |
| 272 // trigger the load manually. | 272 // trigger the load manually. |
| 273 tabs[1].show(TabSelectionType.FROM_USER); | 273 tabs[1].show(TabSelectionType.FROM_USER); |
| 274 tabs[1].hide(); | 274 tabs[1].hide(); |
| 275 } | 275 } |
| 276 }); | 276 }); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 @Feature({"ProcessManagement"}) | 361 @Feature({"ProcessManagement"}) |
| 362 public void testCrashInForeground() throws InterruptedException { | 362 public void testCrashInForeground() throws InterruptedException { |
| 363 // Create a tab in foreground and wait until it is loaded. | 363 // Create a tab in foreground and wait until it is loaded. |
| 364 final Tab tab = ThreadUtils.runOnUiThreadBlockingNoException( | 364 final Tab tab = ThreadUtils.runOnUiThreadBlockingNoException( |
| 365 new Callable<Tab>() { | 365 new Callable<Tab>() { |
| 366 @Override | 366 @Override |
| 367 public Tab call() throws Exception { | 367 public Tab call() throws Exception { |
| 368 TabCreator tabCreator = getActivity().getCurrentTabCreat
or(); | 368 TabCreator tabCreator = getActivity().getCurrentTabCreat
or(); |
| 369 return tabCreator.createNewTab( | 369 return tabCreator.createNewTab( |
| 370 new LoadUrlParams(mTestServer.getURL(FILE_PATH))
, | 370 new LoadUrlParams(mTestServer.getURL(FILE_PATH))
, |
| 371 TabLaunchType.FROM_KEYBOARD, null); | 371 TabLaunchType.FROM_CHROME_UI, null); |
| 372 } | 372 } |
| 373 }); | 373 }); |
| 374 ChromeTabUtils.waitForTabPageLoaded(tab, mTestServer.getURL(FILE_PATH)); | 374 ChromeTabUtils.waitForTabPageLoaded(tab, mTestServer.getURL(FILE_PATH)); |
| 375 getInstrumentation().waitForIdleSync(); | 375 getInstrumentation().waitForIdleSync(); |
| 376 | 376 |
| 377 // Kill the renderer and wait for the crash to be noted by the browser p
rocess. | 377 // Kill the renderer and wait for the crash to be noted by the browser p
rocess. |
| 378 assertTrue(ChildProcessLauncher.crashProcessForTesting( | 378 assertTrue(ChildProcessLauncher.crashProcessForTesting( |
| 379 tab.getContentViewCore().getCurrentRenderProcessId())); | 379 tab.getContentViewCore().getCurrentRenderProcessId())); |
| 380 | 380 |
| 381 CriteriaHelper.pollForCriteria( | 381 CriteriaHelper.pollForCriteria( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 @Feature({"ProcessManagement"}) | 435 @Feature({"ProcessManagement"}) |
| 436 public void testVisibilityDetermined() throws InterruptedException { | 436 public void testVisibilityDetermined() throws InterruptedException { |
| 437 // Create a tab in foreground and wait until it is loaded. | 437 // Create a tab in foreground and wait until it is loaded. |
| 438 final Tab fgTab = ThreadUtils.runOnUiThreadBlockingNoException( | 438 final Tab fgTab = ThreadUtils.runOnUiThreadBlockingNoException( |
| 439 new Callable<Tab>() { | 439 new Callable<Tab>() { |
| 440 @Override | 440 @Override |
| 441 public Tab call() { | 441 public Tab call() { |
| 442 TabCreator tabCreator = getActivity().getCurrentTabCreat
or(); | 442 TabCreator tabCreator = getActivity().getCurrentTabCreat
or(); |
| 443 return tabCreator.createNewTab( | 443 return tabCreator.createNewTab( |
| 444 new LoadUrlParams(mTestServer.getURL(FILE_PATH))
, | 444 new LoadUrlParams(mTestServer.getURL(FILE_PATH))
, |
| 445 TabLaunchType.FROM_KEYBOARD, null); | 445 TabLaunchType.FROM_CHROME_UI, null); |
| 446 }}); | 446 }}); |
| 447 ChromeTabUtils.waitForTabPageLoaded(fgTab, mTestServer.getURL(FILE_PATH)
); | 447 ChromeTabUtils.waitForTabPageLoaded(fgTab, mTestServer.getURL(FILE_PATH)
); |
| 448 int initialNavigationPid = getRenderProcessId(fgTab); | 448 int initialNavigationPid = getRenderProcessId(fgTab); |
| 449 // Ensure the following calls happened: | 449 // Ensure the following calls happened: |
| 450 // - FG - setInForeground(true) - when the tab is created in the foregr
ound | 450 // - FG - setInForeground(true) - when the tab is created in the foregr
ound |
| 451 // - DETERMINED - visibilityDetermined() - after the initial navigation
is committed | 451 // - DETERMINED - visibilityDetermined() - after the initial navigation
is committed |
| 452 assertEquals("FG;DETERMINED;", mBindingManager.getVisibilityCalls(initia
lNavigationPid)); | 452 assertEquals("FG;DETERMINED;", mBindingManager.getVisibilityCalls(initia
lNavigationPid)); |
| 453 | 453 |
| 454 // Navigate to about:version which requires a different renderer. | 454 // Navigate to about:version which requires a different renderer. |
| 455 loadUrlInTab(ABOUT_VERSION_PATH, PageTransition.LINK, fgTab); | 455 loadUrlInTab(ABOUT_VERSION_PATH, PageTransition.LINK, fgTab); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 @LargeTest | 497 @LargeTest |
| 498 @Feature({"ProcessManagement"}) | 498 @Feature({"ProcessManagement"}) |
| 499 public void testReleaseAllModerateBindings() throws InterruptedException { | 499 public void testReleaseAllModerateBindings() throws InterruptedException { |
| 500 final TabCreator tabCreator = getActivity().getCurrentTabCreator(); | 500 final TabCreator tabCreator = getActivity().getCurrentTabCreator(); |
| 501 final Tab[] tabs = new Tab[3]; | 501 final Tab[] tabs = new Tab[3]; |
| 502 getInstrumentation().runOnMainSync(new Runnable() { | 502 getInstrumentation().runOnMainSync(new Runnable() { |
| 503 @Override | 503 @Override |
| 504 public void run() { | 504 public void run() { |
| 505 // Foreground tab. | 505 // Foreground tab. |
| 506 tabs[0] = tabCreator.createNewTab( | 506 tabs[0] = tabCreator.createNewTab( |
| 507 new LoadUrlParams("about:blank"), TabLaunchType.FROM_KEY
BOARD, null); | 507 new LoadUrlParams("about:blank"), TabLaunchType.FROM_CHR
OME_UI, null); |
| 508 // Background tab. | 508 // Background tab. |
| 509 tabs[1] = tabCreator.createNewTab( | 509 tabs[1] = tabCreator.createNewTab( |
| 510 new LoadUrlParams("about:blank"), TabLaunchType.FROM_KEY
BOARD, null); | 510 new LoadUrlParams("about:blank"), TabLaunchType.FROM_CHR
OME_UI, null); |
| 511 } | 511 } |
| 512 }); | 512 }); |
| 513 ChromeTabUtils.waitForTabPageLoaded(tabs[0], "about:blank"); | 513 ChromeTabUtils.waitForTabPageLoaded(tabs[0], "about:blank"); |
| 514 ChromeTabUtils.waitForTabPageLoaded(tabs[1], "about:blank"); | 514 ChromeTabUtils.waitForTabPageLoaded(tabs[1], "about:blank"); |
| 515 // At this point 3 sanboxed services are allocated; the initial one + 2
new tabs. | 515 // At this point 3 sanboxed services are allocated; the initial one + 2
new tabs. |
| 516 assertFalse(mBindingManager.isReleaseAllModerateBindingsCalled()); | 516 assertFalse(mBindingManager.isReleaseAllModerateBindingsCalled()); |
| 517 | 517 |
| 518 getInstrumentation().runOnMainSync(new Runnable() { | 518 getInstrumentation().runOnMainSync(new Runnable() { |
| 519 @Override | 519 @Override |
| 520 public void run() { | 520 public void run() { |
| 521 // Foreground tab. | 521 // Foreground tab. |
| 522 tabs[2] = tabCreator.createNewTab( | 522 tabs[2] = tabCreator.createNewTab( |
| 523 new LoadUrlParams("about:blank"), TabLaunchType.FROM_KEY
BOARD, null); | 523 new LoadUrlParams("about:blank"), TabLaunchType.FROM_CHR
OME_UI, null); |
| 524 } | 524 } |
| 525 }); | 525 }); |
| 526 ChromeTabUtils.waitForTabPageLoaded(tabs[2], "about:blank"); | 526 ChromeTabUtils.waitForTabPageLoaded(tabs[2], "about:blank"); |
| 527 // At this point all the sanboxed services are allocated. | 527 // At this point all the sanboxed services are allocated. |
| 528 mBindingManager.assertIsReleaseAllModerateBindingsCalled(); | 528 mBindingManager.assertIsReleaseAllModerateBindingsCalled(); |
| 529 } | 529 } |
| 530 | 530 |
| 531 @LargeTest | 531 @LargeTest |
| 532 @Feature({"ProcessManagement"}) | 532 @Feature({"ProcessManagement"}) |
| 533 public void testRestoreSharedRenderer() throws Exception { | 533 public void testRestoreSharedRenderer() throws Exception { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 super.tearDown(); | 629 super.tearDown(); |
| 630 } | 630 } |
| 631 | 631 |
| 632 /** | 632 /** |
| 633 * @return the index of the given tab in the current tab model | 633 * @return the index of the given tab in the current tab model |
| 634 */ | 634 */ |
| 635 private int indexOf(Tab tab) { | 635 private int indexOf(Tab tab) { |
| 636 return getActivity().getCurrentTabModel().indexOf(tab); | 636 return getActivity().getCurrentTabModel().indexOf(tab); |
| 637 } | 637 } |
| 638 } | 638 } |
| OLD | NEW |