Jordan Silva
09/28/2021, 10:49 AMAccessibilityChecks.enable()
. However I noticed the View Hierarchy printed from Espresso only had a ComposeView
and AndroidComposeView
with no extra information like text, content description.
+---->AndroidComposeView{id=-1, visibility=VISIBLE, width=1080, height=1808, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams@6460a4, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+----->RippleContainer{id=-1, visibility=VISIBLE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams@ef261c2, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+------>RippleHostView{id=-1, visibility=VISIBLE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams@508ebd3, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
Another issue I had migrating to Compose is that our Espresso tests will fail after a simple screen migration. 😐
If we have a simple screen with just a Text. And we migrate to Compose, Espresso won’t find that Text anymore.
So, just creating an Activity with a Text, and changing that to ComposeView and adding a Compose Text (with the same information). If we try to do the following code, it won’t find the View.
Espresso.onView(withText(R.string.app_intro)).check(matches(isDisplayed()))
I found this answer, so I guess I have to implement new tests while migrating to compose:
https://github.com/android/compose-samples/commit/a6907c5dc236e9c18f062c44453b1c15359962cf#commitcomment-51521777
----------
So, after this huge text, I have 2 questions 😬
1. Will Compose Semantics Test or Test libraries have something similar to Espresso AccessibilityChecks.enable()
?
2. How can I check colors, images and other components properties like Modifiers/borders? These are not visible with SemanticsNode using Jetpack Compose tests.
a. Right now I’m having to check with Snapshots (then some workarounds on top of Snapshot to work across different APIs)Zach Klippenstein (he/him) [MOD]
09/28/2021, 2:18 PMZach Klippenstein (he/him) [MOD]
09/28/2021, 2:19 PMJordan Silva
09/28/2021, 3:44 PMJordan Silva
09/28/2021, 3:46 PMvals
to hold such values, then, unit test these values. But it doesn’t guarantee that our component is actually consuming those values. So, in the end, it doesn’t test anything. 😐Zach Klippenstein (he/him) [MOD]
09/28/2021, 5:10 PMZach Klippenstein (he/him) [MOD]
09/28/2021, 5:26 PMcaptureToImage()
and do mini-screenshot tests on that.Jordan Silva
09/28/2021, 5:35 PMZach Klippenstein (he/him) [MOD]
09/28/2021, 5:48 PMZach Klippenstein (he/him) [MOD]
09/28/2021, 8:37 PMJordan Silva
09/29/2021, 7:10 AMJordan Silva
09/29/2021, 9:07 AM.semantics {
set(BackgroundColor, backgroundColor.toArgb())
set(ForegroundColor, foregroundColor.toArgb())
...
}
ppvi
09/29/2021, 9:34 AMppvi
09/29/2021, 9:34 AMJelle Fresen [G]
09/29/2021, 10:05 AMJordan Silva
09/29/2021, 11:02 AMJordan Silva
09/29/2021, 11:06 AMJordan Silva
09/29/2021, 11:06 AMZach Klippenstein (he/him) [MOD]
09/29/2021, 4:17 PMJordan Silva
09/29/2021, 4:57 PMZach Klippenstein (he/him) [MOD]
09/29/2021, 5:04 PMZach Klippenstein (he/him) [MOD]
09/29/2021, 5:05 PMppvi
09/29/2021, 5:23 PMJordan Silva
09/29/2021, 5:29 PM