Comments (5)
Hi, @juanscigliano I'll try to answer your question but I'm also going to close this issue. We aim to use GitHub issues for bug reporting or feature request, sorry for that.
When trying to use screenshot testing every animated component has to be disabled. But just during the test execution. You need to disable the progress bar animation and the edit text cursor blinking because if you don't do that the screenshot test to become indeterminate. You'd need to wrap your components using a flavor and disable the animations, or in some point in your code detect if you are running a test or not and disable the animations.
As you might be thinking, this is a smell. Your production code should not change the behavior implemented based on if the execution context is a test runner or the production environment. But this is the only way you have to use this testing strategy. When using Espresso or screenshot testing you'll face similar issues with animations.
TLDR: You need to update your code to disable animations and the cursor just during the tests execution.
I hope this is the answer to your question. If you have any other doubt please, drop a question at stack overflow or send me an email at [email protected] and I'll try to answer
from shot.
@pedrovgs Thanks for the answer, your approach make total sense.
from shot.
You can also recursively kill the cursors. Here's a full example for anyone wanting to copypasta stuff:
fun <T : Activity> ActivityScenario<T>.takeScreenshot() {
lateinit var activity: Activity
onActivity {
activity = it
}
activity.hideCursors()
Thread.sleep(500) // Wait for animations to finish
// The automated screenshot naming is based off of stack trace analysis. We can't put this in
// the onActivity lambda because that gets posted to the main thread.
Screenshot.snapActivity(activity).record()
}
private fun Activity.hideCursors() {
runOnUiThread { findViewById<ViewGroup>(android.R.id.content).hideCursors() }
}
private fun ViewGroup.hideCursors() {
for (child in children) {
if (child is ViewGroup) child.hideCursors()
if (child is TextView) child.isCursorVisible = false
}
}
from shot.
@SUPERCILEX Assumptions like wait 500 ms then you should be good to go
are the reason most tests fail and we stay like a stickman thinking about what the hell caused the issue
from shot.
TLDR: You need to update your code to disable animations and the cursor just during the tests execution.
Rewriting the app :)
from shot.
Related Issues (20)
- Aggregate all modules report together to a root report
- "Unresolved reference: shot" HOT 6
- `ManagedVirtualDevice` support HOT 2
- Snapshot on multipe devices only saving last screenshot HOT 1
- How to compare screens with dynamic content
- Screenshots get deleted after being recorded.
- XML report not showing failing tests HOT 1
- Failed to grant permissions HOT 2
- Waiting for remote image fetch HOT 1
- Generated diff image does not show all differences
- Removing the Toolbar shadow (elevation) HOT 1
- Is it possble to test screenshots for gif animated image?
- Feature Request / Question - Record Screenshots at Runtime HOT 2
- Failing to record screenshots HOT 8
- compareScreenshot to capture and verify full screen
- Support for Java 17 and AGP 8.0 HOT 1
- Failing landscape tests due to screen dimensions HOT 1
- Plugin not found issue with new plugin configuration method in gradle HOT 3
- Upgrade Scrimage to latest version
- Please consider transferring ownership to the community HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shot.