Comments (6)
Does it work without Koin? Without resources?
from compose-multiplatform.
That's a very good question... No, it also fails with the exact same error. However, in Android it crashes because at some point the Koin Graph is needed to get the injections. Which leads me to think that something else is happening and my iOS' MainViewController
is not being rendered.
$ gradle shared:connectedAndroidTest
java.lang.IllegalStateException: KoinApplication has not been started
at org.koin.core.context.GlobalContext.get(GlobalContext.kt:36)
at org.koin.compose.KoinApplicationKt.getKoinContext(KoinApplication.kt:52)
at org.koin.compose.KoinApplicationKt.access$getKoinContext(KoinApplication.kt:1)
The sample code runs fine even with Koin and resources, though:
@BeforeTest
fun setup() {
initKoin(appModule = module)
}
@AfterTest
fun tearDown() {
stopKoin()
}
@Test
fun test_titleChangesWhenBottomIconIsSelected() = uiTest {
val title = resourcesProvider.getString(HomeSection.Tasks.title.desc())
setContent {
var text by remember { mutableStateOf(title) }
Text(
text = text,
modifier = Modifier.testTag("text")
)
Button(
onClick = { text = "Compose" },
modifier = Modifier.testTag("button")
) {
Text("Click me")
}
}
onNodeWithTag("text").assertTextEquals(title)
onNodeWithTag("button").performClick()
onNodeWithTag("text").assertTextEquals("Compose")
}
from compose-multiplatform.
Wait, the testing framework only works with Compose UI. It won't work with native elements such as UIViewController.
from compose-multiplatform.
But if I update the coding to directly call the AlkaaMultiplatformApp()
directly in iOS, I face the following issue:
kotlin.IllegalStateException: CompositionLocal UIViewController not provided
That's my iOS's MainViewController
:
@OptIn(ExperimentalComposeApi::class)
@Suppress("Unused", "FunctionName")
fun MainViewController(): UIViewController = ComposeUIViewController(
configure = {
accessibilitySyncOptions = AccessibilitySyncOptions.Always(AccessibilityDebugLoggerImpl())
},
) {
AlkaaMultiplatformApp()
}
Is there a way to use it directly and provide this custom CompositionLocal
?
from compose-multiplatform.
You need to remove the direct dependency on UIViewController from the code you're trying to test.
from compose-multiplatform.
Got it. The reason was the WindowSizeClass
inside my AppState
class. Removing caused another problems with UNUserNotificationCenter.currentNotificationCenter()
but definitely not related to ComposeUIViewController
as I reported. Thank you for the help!
from compose-multiplatform.
Related Issues (20)
- Reduce variety of Preview annotations HOT 3
- Being able to create a ComposePanel with vsync disabled
- Need to tap the touchpad thrice for double click action when using combined clickable. However, Button clicks are only required to clicked twice. HOT 2
- ImageVector is blurry when used with `Image()` + `Modifier.scale()` HOT 2
- [Compose Resources] commonMainResourceAccessors is not generated in multi-module architecture using Kotlin 2.0.0 HOT 4
- `Dialogs` are not rendered as expected when used inside a `ImageComposeScene`
- Unable to compile kotlinjs
- "No such file or directory" when using `Res.getUri()` HOT 5
- FocusRequester is not working on web both js(IR) and WASM the same as in JVM HOT 1
- Support getting resources by key
- Failed to use common source set to manage compose multi-language string resources HOT 2
- PointerInputChange onDrag events always emit ID of 0 on desktop HOT 3
- Default Proguard rules cause task failure when using Material 3 instead of 2
- Jetsnack images are not loading HOT 1
- syncPodComposeResourcesForIos: Cannot query the value of this provider because it has no value available.
- [Gradle] tryGetSkikoRuntimeIfNeeded() eagerly resolves KMP runtime configuration on task creation HOT 1
- [Compose Resources] `MissingResourceException` in Auto-Updater application with different folders HOT 1
- Cannot change preferredStatusBarStyle on ComposeUIViewController HOT 1
- Buuld release not working with kotlin 2 HOT 1
- Use browser sessionStorage API to back rememberSaveable on web HOT 4
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 compose-multiplatform.