0

I can currently rotate the display for my application from my espresso test by doing:

val currentActivity = getCurrentActivity()
currentActivity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
getInstrumentation().waitForIdleSync()

However, this will only rotate the display; the emulator itself remains in portrait mode. I have the auto-rotate setting turned to on / rotate contents of the screen.

Does anyone know how to get the emulator to also rotate?

reutsey
  • 1,743
  • 1
  • 17
  • 36
  • 2
    Does this answer your question? [How to rotate activity, I mean: screen orientation change using Espresso?](https://stackoverflow.com/questions/37362200/how-to-rotate-activity-i-mean-screen-orientation-change-using-espresso) – jeprubio Oct 13 '20 at 15:07
  • 1
    No because I am using the suggested request orientation however it only rotates the screen, not the emulator. I also tried UiDevice set orientation and it also only rotates the display, not the emulator. – reutsey Oct 14 '20 at 17:24

1 Answers1

1

You can rotate the display using emulator commands over telnet.

From the docs:

$ telnet localhost 5554
...
auth 123456789ABCdefZ
...
rotate
...

(on macOS, you might need to brew install telnet)

yogurtearl
  • 3,035
  • 18
  • 24