Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android UI Automator wait orientation change applied

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?

like image 358
vadimvolk Avatar asked Dec 03 '25 22:12

vadimvolk


1 Answers

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.

like image 100
Allen Hair Avatar answered Dec 05 '25 13:12

Allen Hair



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!