summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGuang Zhu <guangzhu@google.com>2012-12-01 23:37:57 -0800
committerGuang Zhu <guangzhu@google.com>2012-12-01 23:40:10 -0800
commitc28a062ffd7edbdbd936c750fa3ec3f81b0d1b44 (patch)
tree988c8dd107e2ec95bc4c48a789bc187f87498a74 /tests
parent76277df27c4d4df39321c400bd5adece32a59b58 (diff)
downloadframeworks_base-c28a062ffd7edbdbd936c750fa3ec3f81b0d1b44.zip
frameworks_base-c28a062ffd7edbdbd936c750fa3ec3f81b0d1b44.tar.gz
frameworks_base-c28a062ffd7edbdbd936c750fa3ec3f81b0d1b44.tar.bz2
app launch test fixes and improvements
* fixed NPE when specified app name does not exist * force stop package before starting, because some names may resolve into the same package * ensure app is launched in the order as sepcified in command line * fixed time recording: it should have been 'thisTime' as reported by ActivityManager, to be consistent with previous harness Change-Id: I411a568580feef21821dcbe6ec15884f697af6fd
Diffstat (limited to 'tests')
-rw-r--r--tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java27
1 files changed, 16 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 e9374e0..af74da2 100644
--- a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
+++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
@@ -17,6 +17,7 @@ package com.android.tests.applaunch;
import android.app.ActivityManager;
import android.app.ActivityManager.ProcessErrorStateInfo;
+import android.app.IActivityManager.WaitResult;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.content.Context;
@@ -31,7 +32,7 @@ import android.test.InstrumentationTestCase;
import android.test.InstrumentationTestRunner;
import android.util.Log;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -79,7 +80,7 @@ public class AppLaunch extends InstrumentationTestCase {
}
private void parseArgs(Bundle args) {
- mNameToResultKey = new HashMap<String, String>();
+ mNameToResultKey = new LinkedHashMap<String, String>();
String appList = args.getString(KEY_APPS);
if (appList == null)
@@ -98,8 +99,8 @@ public class AppLaunch extends InstrumentationTestCase {
}
private void createMappings() {
- mNameToIntent = new HashMap<String, Intent>();
- mNameToProcess = new HashMap<String, String>();
+ mNameToIntent = new LinkedHashMap<String, Intent>();
+ mNameToProcess = new LinkedHashMap<String, String>();
PackageManager pm = getInstrumentation().getContext()
.getPackageManager();
@@ -127,24 +128,26 @@ public class AppLaunch extends InstrumentationTestCase {
Log.i(TAG, "Starting " + appName);
Intent startIntent = mNameToIntent.get(appName);
+ if (startIntent == null) {
+ Log.w(TAG, "App does not exist: " + appName);
+ return;
+ }
AppLaunchRunnable runnable = new AppLaunchRunnable(startIntent);
Thread t = new Thread(runnable);
- long startTime = System.currentTimeMillis();
t.start();
try {
t.join(JOIN_TIMEOUT);
} catch (InterruptedException e) {
// ignore
}
- if(t.isAlive() || (runnable.getResult() != null &&
- runnable.getResult().result != ActivityManager.START_SUCCESS)) {
+ WaitResult result = runnable.getResult();
+ if(t.isAlive() || (result != null && result.result != ActivityManager.START_SUCCESS)) {
Log.w(TAG, "Assuming app " + appName + " crashed.");
reportError(appName, mNameToProcess.get(appName), results);
return;
}
- long startUpTime = System.currentTimeMillis() - startTime;
- results.putString(mNameToResultKey.get(appName), String.valueOf(startUpTime));
- sleep(5000);
+ results.putString(mNameToResultKey.get(appName), String.valueOf(result.thisTime));
+ sleep(1000);
}
private void closeApp() {
@@ -153,7 +156,7 @@ public class AppLaunch extends InstrumentationTestCase {
homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
getInstrumentation().getContext().startActivity(homeIntent);
- sleep(3000);
+ sleep(1000);
}
private void sleep(int time) {
@@ -198,6 +201,8 @@ public class AppLaunch extends InstrumentationTestCase {
public void run() {
try {
+ String packageName = mLaunchIntent.getComponent().getPackageName();
+ mAm.forceStopPackage(packageName, UserHandle.USER_CURRENT);
String mimeType = mLaunchIntent.getType();
if (mimeType == null && mLaunchIntent.getData() != null
&& "content".equals(mLaunchIntent.getData().getScheme())) {