jQrgen
05/28/2024, 4:27 PMUIKitInteropContainer
for Compose UI tests?
Failed tests
shoppingScreenTest[iosSimulatorArm64]
kotlin.IllegalStateException: UIKitInteropContainer not provided
at kotlin.Throwable#<init>(/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:28)
at kotlin.Exception#<init>(/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:23)
at kotlin.RuntimeException#<init>(/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:34)
at kotlin.IllegalStateException#<init>(/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:70)
at androidx.compose.ui.interop.LocalUIKitInteropContainer$lambda$0#internal(/opt/buildAgent/work/8a20760945d0aeba/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/interop/UIKitInteropContainer.uikit.kt:37)
at androidx.compose.ui.interop.$LocalUIKitInteropContainer$lambda$0$FUNCTION_REFERENCE$0.invoke#internal(/opt/buildAgent/work/8a20760945d0aeba/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/interop/UIKitInteropContainer.uikit.kt:37)
at kotlin.Function0#invoke(/Users/teamcity/.gradle/daemon/8.2.1/[K][Suspend]Functions:1)
And why is UIKitINteropContainer
required to run a simple view for this composable?
@Composable
fun ShoppingScreen(nav: ScreenNav)
{
Column(
modifier = Modifier.fillMaxWidth().fillMaxHeight(1f),
horizontalAlignment = Alignment.Start,
verticalArrangement = Arrangement.SpaceEvenly)
{
WallyBoldText(S.ShoppingWarning)
WallyDivider()
LazyColumn(modifier = Modifier.fillMaxWidth().fillMaxHeight(1f)) {
itemsIndexed(initialShopping) { index, it ->
// padding here adds a small gap between each entry that is not filled with the row color
Spacer(Modifier.fillMaxWidth().padding(0.dp, 1.dp))
// This padding adds a little margin between the content and the background color
Box(Modifier.fillMaxWidth().background(WallyShoppingRowColors[index % WallyShoppingRowColors.size]).padding(2.dp, 2.dp)) {
it.compose()
//Text(it.explain, Modifier.fillMaxWidth())
}
}
}
}
}
The test:
import androidx.compose.ui.test.*
import info.bitcoinunlimited.www.wally.S
import info.bitcoinunlimited.www.wally.i18n
import info.bitcoinunlimited.www.wally.ui.ScreenNav
import info.bitcoinunlimited.www.wally.ui.ShoppingScreen
import kotlin.test.Test
@OptIn(ExperimentalTestApi::class)
class ShoppingScreenTest
{
@Test
fun shoppingScreenTest() = runComposeUiTest {
val nav = ScreenNav()
setContent {
ShoppingScreen(nav)
}
onNodeWithText(i18n(S.ShoppingWarning)).isDisplayed()
onNodeWithText(i18n(S.NFTs)).isDisplayed()
onNodeWithText(i18n(S.ExplainBitmart)).isDisplayed()
onNodeWithText(i18n(S.ExplainMexc)).isDisplayed()
onNodeWithText(i18n(S.NFTs)).isDisplayed()
}
}
Full stack trace: https://wallywallet.gitlab.io/-/wallet/-/jobs/6960895143/artifacts/src/build/reports/tests/iosSimulatorArm64Test/classes/ui.ShoppingScreenTest.htmlIvan Matkov
05/28/2024, 4:34 PMrunComposeUiTest
test runner). Please file an issuejQrgen
05/28/2024, 4:35 PMIvan Matkov
05/28/2024, 4:36 PMIvan Matkov
05/28/2024, 7:35 PMAnd why isIt looks like it's not so "simple" and contains native view inside (interop). So the problem here is with interop view usage from testsrequired to run a simple view for this composable?UIKitINteropContainer
logosdeborah
07/31/2024, 1:57 PMjQrgen
07/31/2024, 3:15 PMIvan Matkov
07/31/2024, 3:17 PMCompose iOS is still untestableThis case is only about interop views. Not Compose in general.
Ivan Matkov
07/31/2024, 3:18 PMIs there any update on this issue?Could you please add a link to filed issue, so I'll bump this internally?
jQrgen
07/31/2024, 3:52 PM