summaryrefslogtreecommitdiffstats
path: root/test-runner
diff options
context:
space:
mode:
authorFilip Gruszczynski <gruszczy@google.com>2014-09-29 14:05:19 -0700
committerFilip Gruszczynski <gruszczy@google.com>2014-10-03 14:06:19 -0700
commitbc7f4f0e1275fca1484c02ba465fce907c6692f7 (patch)
tree522551f4acd35259cd4398dd92586ac4e419d952 /test-runner
parent35eb89097f4f555dc03d4d406359a9ebfa64144d (diff)
downloadframeworks_base-bc7f4f0e1275fca1484c02ba465fce907c6692f7.zip
frameworks_base-bc7f4f0e1275fca1484c02ba465fce907c6692f7.tar.gz
frameworks_base-bc7f4f0e1275fca1484c02ba465fce907c6692f7.tar.bz2
Log exception when creating Activity in ActivityUnitTestCase.
If the creation of an Activity fails, it is impossible to determine what went wrong. We should log the exception immediately before failing on assert. Change-Id: Ie6cbe87ff342b8d60989f5e1a6ffa3efc058c585
Diffstat (limited to 'test-runner')
-rw-r--r--test-runner/src/android/test/ActivityUnitTestCase.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/test-runner/src/android/test/ActivityUnitTestCase.java b/test-runner/src/android/test/ActivityUnitTestCase.java
index 8aa8824..40cca90 100644
--- a/test-runner/src/android/test/ActivityUnitTestCase.java
+++ b/test-runner/src/android/test/ActivityUnitTestCase.java
@@ -26,6 +26,9 @@ import android.os.Bundle;
import android.os.IBinder;
import android.test.mock.MockApplication;
import android.view.Window;
+import android.util.Log;
+
+
/**
* This class provides isolated testing of a single activity. The activity under test will
@@ -73,6 +76,7 @@ import android.view.Window;
public abstract class ActivityUnitTestCase<T extends Activity>
extends ActivityTestCase {
+ private static final String TAG = "ActivityUnitTestCase";
private Class<T> mActivityClass;
private Context mActivityContext;
@@ -132,27 +136,28 @@ public abstract class ActivityUnitTestCase<T extends Activity>
if (mApplication == null) {
setApplication(new MockApplication());
}
- ComponentName cn = new ComponentName(mActivityClass.getPackage().getName(),
+ ComponentName cn = new ComponentName(mActivityClass.getPackage().getName(),
mActivityClass.getName());
intent.setComponent(cn);
ActivityInfo info = new ActivityInfo();
CharSequence title = mActivityClass.getName();
mMockParent = new MockParent();
String id = null;
-
+
newActivity = (T) getInstrumentation().newActivity(mActivityClass, mActivityContext,
token, mApplication, intent, info, title, mMockParent, id,
lastNonConfigurationInstance);
} catch (Exception e) {
+ Log.w(TAG, "Catching exception", e);
assertNotNull(newActivity);
}
-
+
assertNotNull(newActivity);
setActivity(newActivity);
mAttached = true;
}
-
+
T result = getActivity();
if (result != null) {
getInstrumentation().callActivityOnCreate(getActivity(), savedInstanceState);