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

Unified Diff: chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java

Issue 2396253002: Finish AppTasks on UI thread during test tear down (Closed)
Patch Set: Finish AppTasks on UI thread during test tear down Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java
diff --git a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java
index 07768135a2bbee027f5794ca2ddb7a9e694a1ea2..85710eaff69e2bc289b79f2fbae82319b3030e3e 100644
--- a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java
+++ b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java
@@ -158,14 +158,24 @@ public class ApplicationTestUtils {
/** Finishes all tasks Chrome has listed in Android's Overview. */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void finishAllChromeTasks(final Context context) throws Exception {
- // Close all of the tasks one by one.
- ActivityManager activityManager =
- (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
- for (ActivityManager.AppTask task : activityManager.getAppTasks()) {
- task.finishAndRemoveTask();
- }
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ // Close all of the tasks one by one.
+ ActivityManager activityManager =
+ (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ for (ActivityManager.AppTask task : activityManager.getAppTasks()) {
+ task.finishAndRemoveTask();
+ }
+ } catch (Exception e) {
+ // Ignore any exceptions the Android framework throws so that otherwise passing
+ // tests don't fail during tear down. See crbug.com/653731.
+ }
+ }
+ });
- CriteriaHelper.pollInstrumentationThread(Criteria.equals(0, new Callable<Integer>() {
+ CriteriaHelper.pollUiThread(Criteria.equals(0, new Callable<Integer>() {
@Override
public Integer call() {
return getNumChromeTasks(context);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698