I'm trying to do instrumentation testing of an activity that uses fragments.
I'm trying to test the onSaveInstanceState by doing this:
/*************/
runTestOnUiThread(new Runnable() {
@Override
public void run() {
instrumentation.callActivityOnSaveInstanceState(activity,
outState);
}
});
instrumentation.waitForIdleSync();
assertEquals(MainActivity.MY_TITLES,
outState.getInt(MainActivity.SELECTED_TAB));
Log.d(TAG, "so far, so good...");
/*************/
That works fine, but that's the end of my test.
The test runner shows this:
---
Running tests
Test running started
Test failed to run to completion. Reason: 'Instrumentation run failed
due to 'java.lang.IllegalStateException''. Check device logcat for
details
Test running failed: Instrumentation run failed due to
'java.lang.IllegalStateException'
---
Looking in logcat, I see this:
---
02-19 08:25:58.840:
DEBUG/com.alex.android.test.ui8.activity.MainActivityTest(990): so
far, so good...
02-19 08:25:58.890:
DEBUG/com.alex.android.service.LocalBroadcastHelper(990):
unregistering receiver:
com.alex.android.ui8.fragment.MyTitlesFragment$1@41296eb0
02-19 08:25:58.890:
DEBUG/com.alex.android.ui8.activity.MainActivity(990): onPause
02-19 08:25:58.890: DEBUG/AndroidRuntime(990): Shutting down VM
02-19 08:25:58.890: WARN/dalvikvm(990): threadid=1: thread exiting
with uncaught exception (group=0x409c01f8)
02-19 08:25:58.930: ERROR/AndroidRuntime(990): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to pause activity
{com.alex.android/com.alex.android.ui8.activity.MainActivity}:
java.lang.IllegalStateException: Can not perform this action after
onSaveInstanceState
at
android.app.ActivityThread.performPauseActivity(ActivityThread.java:2706)
at
android.app.ActivityThread.performPauseActivity(ActivityThread.java:2662)
---
The thing that has me perplexed here is that IllegalStateException -
the code it ultimately points back to in the stack trace is in the
onPause() of my activity. I'm trying to commit a fragment transaction
and in the application it works fine - it just fails in my test.
I suspect I'm doing something out of order, but googled all morning
and can't find anything that seems to point me in the right direction.
Any hints?
Larry
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.