3

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.

Leandro Borges Ferreira
  • 12,422
  • 10
  • 53
  • 73

2 Answers2

7

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.

Community
  • 1
  • 1
albodelu
  • 7,931
  • 7
  • 41
  • 84
  • Didn't work for me - `android.support.test.espresso.PerformException: Error performing 'single click' on view 'Animations or transitions are enabled on the target device.`. Using emulator API 22. – aragaer Jun 01 '17 at 18:06
  • I think that it works and your error message is generic. If you create a new question, I'll try to help you. Probably, the lock screen is overlapping your activity (explained in the links I shared). – albodelu Jun 01 '17 at 19:05
  • Nope, I have 8 test cases and I only get one failure. I can not reproduce it on my own computer, only on travis. – aragaer Jun 01 '17 at 19:10
  • 2
    It seems that the problem is not related to animation - I've got the same message when performing an action on wrong target. – aragaer Jun 01 '17 at 20:58
  • 1
    [Green](https://www.travis-ci.org/albodelu/jtt_android/builds/238501694) :). seems that an issue with the [screen size](https://github.com/albodelu/jtt_android/blob/440bf5332b0d970096fc392090831cff55cf005d/.travis.yml#L35) due to [landscape tests](https://github.com/albodelu/jtt_android/blob/master/JttAndroidTest/src/com/aragaer/jtt/LandscapeTest.java). I used a nexus 4 device with skin 768x128 to fix it. – albodelu Jun 01 '17 at 21:07
  • Further information about screen sizes [here](https://stackoverflow.com/q/32914660/1009132), I just added this case. – albodelu Jun 01 '17 at 21:33
5

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