Luca Vitucci
Luca Vitucci

Reputation: 3734

Disable animations for tests in cloud services (Programmatically?)

Currently we can see that two of the major cloud testing services:

do not support disabling device animations as suggested by espresso developers: https://google.github.io/android-testing-support-library/docs/espresso/setup/index.html#setup-your-test-environment

Amazon actually disables the window-animation but this is not enough as the biggest source of flakyness is the Animator.

Google acknowledged the issue but fixing it will take some time.

In the meantime, how would you disable Animator animations without having access to the device?

Upvotes: 9

Views: 1177

Answers (1)

Nikola Despotoski
Nikola Despotoski

Reputation: 50548

Do you mean Window animations in dev options? If that so, disabling through reflection (maybe?) at @Before or beforeActivityLaunched() might be worth trying.

Basically, Window scale and animation value is set through global IWindowManager. Values in developer options are stored as shared preferences.

I doubt accessing ServiceManager or IWindowManager will not rise SecurityException however you may want to look at Settings.Global.ANIMATOR_DURATION_SCALE and WINDOW_ANIMATION_SCALE. Changing this global settings might require additional permission in your application.

From documentation, toggling WINDOW_ANIMATION_SCALE to 0 will get rid of any window animations:

Scaling factor for normal window animations. Setting to 0 will disable window animations.

Upvotes: 0

Related Questions