My Android app is landscape-only. This means that all activity tags in AndroidManifest.xml have the attribute android:screenOrientation="landscape".
I am trying to write tests for a specific activity using a 'ActivityInstrumentationTestCase2' subclass. When I run this test under AndroidStudio the app always appears in 'portrait' mode on the device that is used for testing.
Is there a way to force the activity being tested to start in landscape orientation?
I know I can call:
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
in the setUp method, but that will switch the activity to landscape, not start it in landscape initially. It feels I somehow need to influence the AndroidManifest.xml generated by gradle for testing to include Activity declarations with the screenOrientation="landscape" attributes.
Aucun commentaire:
Enregistrer un commentaire