Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghostbuster91/espresso-animations-disabled-test
https://github.com/ghostbuster91/espresso-animations-disabled-test
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ghostbuster91/espresso-animations-disabled-test
- Owner: ghostbuster91
- Created: 2017-11-04T20:22:01.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-19T19:34:26.000Z (over 6 years ago)
- Last Synced: 2024-10-03T12:19:48.320Z (about 1 month ago)
- Language: Java
- Size: 127 KB
- Stars: 47
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# Espresso animations test
It is not a secret that espresso fails when there are some animations in your application.
But not many people know that there is a flag for disabling animations in tests:
```
testOptions {
animationsDisabled = true
}
```
Link to official documentation: [here](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.TestOptions.html#com.android.build.gradle.internal.dsl.TestOptions:animationsDisabled)Ok, that's great, but does it really work? Do I still have to turn off animations manually?
(Setting `window_animation_scale` and `transition_animation_scale` and `animator_duration_scale` to `0`)### TDLR; Yes, it mostly works.
Also thanks to [dryrun](https://github.com/cesarferreira/dryrun) you can try it yourself.
Just run `dryrun -a [email protected]:ghostbuster91/espresso-animations-disabled-test.git`
### Overview
Because it is very hard to find any information about this flag I decided to check it by myself.
To do this I ran some tests against emulators with apis within range <16, 26>.My tests consists of:
- checking if progress bar is visible
- checking if snackbar is visible
- performing click on snackbar actionResults:
Below tables show what should be the state of animation settings so the corresponding tests passed, while having this flag turned on.The row `animations` represents the state of animations which can be altered through settings screen or adb commands.
Assert progressBar is visible:
| API level | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 |
|------------|----|----|----|----|----|----|----|-----|----|----|
| Animations | DM | DM | DM | DM | ON | ON | ON | OFF | DM | DM |*DM stand for doesn't matter*
*OFF means that animations have to be turned off*
*ON means that animations have to be turned on*
Assert snackbar is visible:
| API level | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 |
|------------|----|----|----|----|-----|-----|-----|-----|-----|-----|
| Animations | DM | DM | DM | DM | OFF | OFF | OFF | OFF | OFF | OFF |Assert snackbar is clickable:
| API level | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 |
|------------|----|----|----|----|-----|-----|-----|-----|-----|-----|
| Animations | DM | DM | DM | DM | DM | DM | DM | DM | DM | DM |Summary:
The `animationsDisabled` flag is not a silver bullet. It can helps us a lot,
but on some apis there is no easy solution to get espresso work with animations.E.g. On api 22 we can't have both progressBar and snackbar working.