How to disable Android emulator animations in Trav

2019-04-02 01:34发布

I am running Espresso tests in the Travis CI. When I run my tests in my device, I normally disable all my animations so I don't have to use Thread.sleep all the time.

But I really don't know how to do this in the Travis CI, so my tests fail without the Thread.sleep. I looked over the internet... but I didn't find any tutorial about how to do disable the animations in the emulator

I could use idling resource in Espresso, I know. But some times I would prefer not to.

2条回答
看我几分像从前
2楼-- · 2019-04-02 02:13

If you try @azizbekian's path, I wrote about this here, created new test rules here and tested it here

I confirm @Testujaca Malpeczka path works on Travis-ci for Android APIs 17-22 as discussed here

If you are looking for a solution for latest Android APIs and tools, work in progress here and here

before_script:
  # Wait for emulator fully-booted and disable animations
  - android-wait-for-emulator
  - adb shell settings put global window_animation_scale 0 &
  - adb shell settings put global transition_animation_scale 0 &
  - adb shell settings put global animator_duration_scale 0 &
  - adb shell input keyevent 82 &

It also works in Circle-ci and probably any continuous integration build server, see broken link here

test:
  pre:
    - ...
    - circle-android wait-for-boot
    - adb shell input keyevent 82
    - adb shell settings put global window_animation_scale 0
    - adb shell settings put global transition_animation_scale 0
    - adb shell settings put global animator_duration_scale 0

My extended test rules work for Android APIs 15-22, and there was a bug in Android 23 emulator.

I'll try it for later versions 24+ using android-topeka sample another day, probably it works.

Any help, improvement or effective alternative using sdkmanager would be much appreciated.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-04-02 02:28

If it possible use adb shell command:

adb shell settings put global window_animation_scale 0.0
adb shell settings put global transition_animation_scale 0.0
adb shell settings put global animator_duration_scale 0.0

tested on jenkins ci

查看更多
登录 后发表回答