Merge "Log exception when creating Activity in ActivityUnitTestCase." into lmp-sprout-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
49e2371a27
@@ -26,6 +26,9 @@ import android.os.Bundle;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.test.mock.MockApplication;
|
import android.test.mock.MockApplication;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides isolated testing of a single activity. The activity under test will
|
* 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>
|
public abstract class ActivityUnitTestCase<T extends Activity>
|
||||||
extends ActivityTestCase {
|
extends ActivityTestCase {
|
||||||
|
|
||||||
|
private static final String TAG = "ActivityUnitTestCase";
|
||||||
private Class<T> mActivityClass;
|
private Class<T> mActivityClass;
|
||||||
|
|
||||||
private Context mActivityContext;
|
private Context mActivityContext;
|
||||||
@@ -132,27 +136,28 @@ public abstract class ActivityUnitTestCase<T extends Activity>
|
|||||||
if (mApplication == null) {
|
if (mApplication == null) {
|
||||||
setApplication(new MockApplication());
|
setApplication(new MockApplication());
|
||||||
}
|
}
|
||||||
ComponentName cn = new ComponentName(mActivityClass.getPackage().getName(),
|
ComponentName cn = new ComponentName(mActivityClass.getPackage().getName(),
|
||||||
mActivityClass.getName());
|
mActivityClass.getName());
|
||||||
intent.setComponent(cn);
|
intent.setComponent(cn);
|
||||||
ActivityInfo info = new ActivityInfo();
|
ActivityInfo info = new ActivityInfo();
|
||||||
CharSequence title = mActivityClass.getName();
|
CharSequence title = mActivityClass.getName();
|
||||||
mMockParent = new MockParent();
|
mMockParent = new MockParent();
|
||||||
String id = null;
|
String id = null;
|
||||||
|
|
||||||
newActivity = (T) getInstrumentation().newActivity(mActivityClass, mActivityContext,
|
newActivity = (T) getInstrumentation().newActivity(mActivityClass, mActivityContext,
|
||||||
token, mApplication, intent, info, title, mMockParent, id,
|
token, mApplication, intent, info, title, mMockParent, id,
|
||||||
lastNonConfigurationInstance);
|
lastNonConfigurationInstance);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Log.w(TAG, "Catching exception", e);
|
||||||
assertNotNull(newActivity);
|
assertNotNull(newActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNotNull(newActivity);
|
assertNotNull(newActivity);
|
||||||
setActivity(newActivity);
|
setActivity(newActivity);
|
||||||
|
|
||||||
mAttached = true;
|
mAttached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
T result = getActivity();
|
T result = getActivity();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
getInstrumentation().callActivityOnCreate(getActivity(), savedInstanceState);
|
getInstrumentation().callActivityOnCreate(getActivity(), savedInstanceState);
|
||||||
|
|||||||
Reference in New Issue
Block a user