I am using espresso for android ui testing. I want to test whether my screen is in portrait mode. I am using Kotlin programming language.
What did I try: I tried to search how to perform this. But all I could get was change the orientation of the app using espresso.
So I tried this:
@Test
fun isOrientationVertical() {
assertEquals(resources.configuration.orientation, Configuration.ORIENTATION_LANDSCAPE.toString())
}
However, 'resources' (to be precise, getResources()) is not getting detected.
What am I expecting: Something like this:
Thanks a lot in advance. Please do let me know if I am not clear.
Have a look at this answer: https://stackoverflow.com/a/42591933/20356055
Instead of setRequestedOrientation()
you can use getRequestedOrientation