I am making tests using Android UI automator FW. I am trying to detect memory leak during device orientation change using following code:
InstrumentationRegistry.getInstrumentation().getUiAutomation()
.setRotation(orientation);
It changes device orientation, but my questions is:
What is a proper way (except sleep) to wait that device finished orientation change?
I've tried:
mDevice.wait(Until.hasObject(By.pkg(<MyPackage>).depth(0)), LAUNCH_TIMEOUT);
Sometimes work, sometimes not.
mDevice.waitForIdle();
Not working at all.
Any other ways to wait?
You can use the UiDevice.setOrientationXXX() methods instead of UiAutomation.setRotation().
The UiDevice methods have a build in call to UiDevice.waitForIdle() which will block until the UI has not changed for at least 500ms.