Comments (6)
Yes. Although that doesn't cover Box.
I think we should actually switch to a completely empty Modifier not just remove one. Then every test should snap back to the same image.
from redwood.
Can we add these modifier removal test functions to the existing shared screenshot tests AbstractFlexContainerTest?
from redwood.
What is the proper method for switching to an empty modifier? I tried widget.modifier = Modifier
which results in different behaviors from ComposeUI and View.
For example when I created and recorded the following screenshot test inside AbstractFlexContainerTest
@Test
fun testColumnWithChildModifierChanges() {
testContainerWithChildrenModifierChanges(FlexDirection.Column)
}
@Test
fun testRowWithChildModifierChanges() {
testContainerWithChildrenModifierChanges(FlexDirection.Row)
}
private fun testContainerWithChildrenModifierChanges(
flexDirection: FlexDirection,
) {
assumeTrue(flexDirection in listOf(FlexDirection.Row, FlexDirection.Column))
val container = flexContainer(flexDirection)
container.width(Constraint.Fill)
container.height(Constraint.Fill)
val first = text(longText(), backgroundColor = Red)
first.modifier = MarginImpl(30.dp)
container.add(first)
container.add(text(mediumText(), backgroundColor = Green))
container.add(text(shortText(), backgroundColor = Blue))
container.onEndChanges()
verifySnapshot(container, "Assigned_Modifier")
first.modifier = Modifier
container.onEndChanges()
verifySnapshot(container, "Empty_Modifier")
}
ComposeUI
outputs the expected screenshots, while View
always outputs the screenshot with a margin applied, Note that I tried different modifiers and widgets and I get similar results
I feel that I'm missing something ๐
Platform | Assigned Modifier | Empty Modifier |
---|---|---|
ComposeUI | ||
View |
from redwood.
Also in AbstractBoxTest When I attempt to call verifySnapshot(widget.value)
once with the modifier assigned and again when the modifier is emptied, I receive a crash from the View
platform.
app.cash.redwood.layout.view.ViewBoxTest > testChildrenModifierChanges[RTL] FAILED
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:5248)
at android.view.ViewGroup.addView(ViewGroup.java:5077)
at android.view.ViewGroup.addView(ViewGroup.java:5017)
at android.view.ViewGroup.addView(ViewGroup.java:4989)
at app.cash.redwood.layout.view.ViewBoxTest.verifySnapshot(ViewBoxTest.kt:69)
at app.cash.redwood.layout.view.ViewBoxTest.verifySnapshot(ViewBoxTest.kt:33)
Test function
@Test
fun testChildrenModifierChanges() {
val redColor = coloredText(MarginImpl(30.dp), longText(), Red)
val widget = box().apply {
width(Constraint.Fill)
height(Constraint.Fill)
children.insert(0, redColor)
children.insert(1, coloredText(text = mediumText(), color = Blue))
children.insert(2, coloredText(text = shortText(), color = Green))
}
verifySnapshot(widget.value)
redColor.modifier = Modifier
widget.children.onModifierUpdated(0, redColor)
verifySnapshot(widget.value)
}
from redwood.
@JakeWharton , sorry for bothering you with a lot of questions ๐, Let me know if my approach with the test functions is what we need
from redwood.
So it sounds like views are just broken today (which is the point of the tests!). We can file a separate bug about them not clearing state.
from redwood.
Related Issues (20)
- Support for Widget.dispose() for non-protocol applications
- Add layout direction variation to iOS snapshot tests
- `CrossAxisAlignment.Start` forces child to wrap its size on Android
- Turn off Zipline API tracking for test app
- Ship a BOM
- Close TreehouseDispatchers in TreehouseApp.Factory.close() HOT 2
- Support unsetting of unscoped modifiers
- Remove code dealing with old memory model
- Changes to `Modifier.size` are not reflected HOT 2
- Consider splitting the binding for scrolling vs. non-scrolling layouts.
- Root componentโs dimensions inconsistent across platforms HOT 1
- Please add a Default EventListener HOT 2
- Treehouse Gradle Plugin
- IndexOutOfBoundsException in LazyListUpdateProcessor HOT 1
- Protocol does JSON decoding on the main thread
- Determine if density multiplier still should exist
- UncaughtTreehouseException: toIndex = 1
- Use a Redwood schema for loading and error UIs HOT 6
- [jwilson] use this once we update Zipline. HOT 1
- Once QuickJS supports WeakRef, enable regular tests:
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 redwood.