admin管理员组

文章数量:1122832

I have a composable with unit tests. When I add the clip modifier to it to clip the background to a particular shape, the unit tests verify click behavior starts to fail.

If I use default compose shape RoundCornerShape or CircleShape for the clip the tests pass, only when I use a custom shape (using Outline.Generic) the tests start failing.

// Layout
MyView.clip().background().border().padding().clickable().testTag("CONTAINER_TAG")

// Test
composeRule.onNodeWithTag("CONTAINER_TAG", true).performClick() // Fail only when clip modifier with custom shape is added.

I have a composable with unit tests. When I add the clip modifier to it to clip the background to a particular shape, the unit tests verify click behavior starts to fail.

If I use default compose shape RoundCornerShape or CircleShape for the clip the tests pass, only when I use a custom shape (using Outline.Generic) the tests start failing.

// Layout
MyView.clip().background().border().padding().clickable().testTag("CONTAINER_TAG")

// Test
composeRule.onNodeWithTag("CONTAINER_TAG", true).performClick() // Fail only when clip modifier with custom shape is added.
Share Improve this question edited Nov 23, 2024 at 16:37 Rachit Mishra asked Nov 23, 2024 at 3:57 Rachit MishraRachit Mishra 6,1124 gold badges31 silver badges51 bronze badges
Add a comment  | 

1 Answer 1

Reset to default -1
clip().background().border().padding().clickable() 

All this modifiers require values. For example:

.clip(shape: Shape) 
.background(color: Color)

Or, if your code has this, can you provide mode code for understanding your problem ?

本文标签: androidCompose Adding clip modifier makes unit tests failStack Overflow