What's the best way to debug a CfD test? For insta...
# compose-desktop
e
What's the best way to debug a CfD test? For instance, the node I'm looking for isn't getting found, and I want to see what the window would look like at that point in the test so I can figure out where the node is.
@Igor Demin it looks like you recommend
TestComposeWindow
in a few places, but I can't get it to resolve using Jetbrains Compose 1.2.0-alpha01-dev707
i
It was renamed to
ImageComposeScene
. See examples here
e
Does passing a
time
to
render
advance the clock for coroutines inside launched effects?
i
No, it just provides the current time for animations. For driving coroutines, you need to use
UnconfinedTestDispatcher
and pass it as
coroutineContext
e
Are there any anti patterns there, like rendering at a past time after rendering at a future time, or interactions between driving animations with render, and coroutines with the test dispatcher?
Or for example I have a launched effect that delays for one second, then mutates state that causes Text to be added to the composition wrapped in an AnimatedVisibility, and the entry transition has a duration of one second. If I want to render halfway through the enter transition am I supposed to advance the coroutine clock by one second, and then call render with
1500.milliseconds
?
i
like rendering at a past time after rendering at a future time
The time passed to
render
should be monotonic, i.e. you shouldn't try to pass a lower time after you passed a greater time. Probably we'll add a check for that in the future and describe that in the docs.
I supposed to advance the coroutine clock by one second, and then call render with
1500.milliseconds
?
You should advance the clock by 1500 milliseconds, and pass 1500 to
render
. The time inside a coroutine clock should be same as the time passed to
render
function. There is idea to embed the test dispatcher into
ImageComposeScene
, but that is only an idea for now. That would also fix another issue
e
Thanks for the info. So in general if I'm dealing with coroutine clocks and
ImageComposeScene
I should always keep them in sync? And hopefully in the future this behavior will be embedded in
ImageComposeScene
?
i
Yes, that is correct
🙏 1
e
Could there be any issue with using an
AnimatedVisibility
? It doesn't seem to render those mid transition; only pre or post transition.
For example, running the following code yields a "screenshot" where the
AnimatedVisibility
content is visible when rendering the scene at `0`:
Using
animateDpAsState
does work:
Looks like it's just an issue with sliding enter transitions - https://github.com/JetBrains/compose-jb/issues/2109