diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2018-02-15 22:11:59 +0000 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2018-02-15 22:32:02 +0000 |
commit | aacac603553d56c7d6b7202bf9a27c83df0308ac (patch) | |
tree | 4a55ad305258866d389519e4e9efa8a485f0afbf /tests/AppLaunch/src | |
parent | 2792c7f6a2477e0e0a4fbf829ed3973654383a9c (diff) |
Small cleanup in AppLaunch.
closeApp is always force closing app. Just make it so.
Move the go home intent into its own method.
Test: adb shell "am instrument -w -e drop_cache true -e simpleperf_app true -e compiler_filters speed\|speed-profile\|quicken\|verify -e apps Maps^Maps -e launch_directory /data/local/tmp com.android.tests.applaunch/android.test.InstrumentationTestRunner"
Change-Id: I0d7d28a99a1ce9dfcefc4572ec3a0142482b1e48
Diffstat (limited to 'tests/AppLaunch/src')
-rw-r--r-- | tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java index 228f9bbddcd1..83354d55b005 100644 --- a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java +++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java @@ -302,7 +302,7 @@ public class AppLaunch extends InstrumentationTestCase { atraceLogger.atraceStop(); } } - closeApp(launch.getApp(), true); + closeApp(launch.getApp()); sleep(BETWEEN_LAUNCH_SLEEP_TIMEOUT); } } finally { @@ -575,22 +575,23 @@ public class AppLaunch extends InstrumentationTestCase { } } - private void closeApp(String appName, boolean forceStopApp) { + private void startHomeIntent() { Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); getInstrumentation().getContext().startActivity(homeIntent); sleep(POST_LAUNCH_IDLE_TIMEOUT); - if (forceStopApp) { - Intent startIntent = mNameToIntent.get(appName); - if (startIntent != null) { - String packageName = startIntent.getComponent().getPackageName(); - try { - mAm.forceStopPackage(packageName, UserHandle.USER_CURRENT); - } catch (RemoteException e) { - Log.w(TAG, "Error closing app", e); - } + } + + private void closeApp(String appName) { + Intent startIntent = mNameToIntent.get(appName); + if (startIntent != null) { + String packageName = startIntent.getComponent().getPackageName(); + try { + mAm.forceStopPackage(packageName, UserHandle.USER_CURRENT); + } catch (RemoteException e) { + Log.w(TAG, "Error closing app", e); } } } |