4

I try to test Activity's instance state save and restore in Espresso.

How to test the full life cycle? The suggest at How to test saving and restoring state of an android activity with Espresso? is helping already, but how can we test the Parcelable writeToParcel / createFromParcel stuff? (means when InstanceState is not just saved and restored but serialized in between, which is causing this nice "Unmarshalling unknown type code" exceptions if code does not work)

Destroy and restart Activity with Testing Support Library test rule does not keep instance state.

I experimented a bit with getInstrumentation().callActivityOnSaveInstanceState(oldActivity, stateBundle); but no success.

Any idea?

allofmex
  • 557
  • 1
  • 4
  • 16
  • This answer has the solution: https://stackoverflow.com/a/63465944/9636 – Heath Borders Sep 26 '21 at 16:55
  • The solution at https://stackoverflow.com/a/63465944/6937282 does not completely answers this question because it does not use `createFromParcel`. See comment there. – allofmex Oct 24 '21 at 18:36

0 Answers0