iOS UIKit simulator ARM64 utilities for Compose Multiplatform UI framework providing testing, interoperability, and platform-specific implementations.
—
Comprehensive testing infrastructure for iOS UIKit applications with Compose integration, providing test setup, content management, and UI synchronization capabilities.
Creates and manages the iOS UIKit testing environment with proper app delegate setup and window management.
/**
* Runs a UIKit instrumented test with proper setup and teardown
* @param testBlock - Test code block to execute within UIKitInstrumentedTest context
*/
internal fun runUIKitInstrumentedTest(testBlock: UIKitInstrumentedTest.() -> Unit)Usage Example:
runUIKitInstrumentedTest {
setContent {
Column {
Text("Welcome to iOS!")
Button(onClick = { /* action */ }) {
Text("Click me")
}
}
}
waitForIdle()
tap(DpOffset(100.dp, 200.dp))
}Functions for setting and managing Compose content within the iOS UIKit test environment.
/**
* Sets Compose content in the test environment
* @param configure - Configuration block for ComposeUIViewController setup
* @param content - Composable content to display
*/
fun UIKitInstrumentedTest.setContent(
configure: ComposeUIViewControllerConfiguration.() -> Unit = {},
content: @Composable () -> Unit
)
/**
* Sets content with accessibility synchronization enabled
* @param content - Composable content to display with accessibility support
*/
fun UIKitInstrumentedTest.setContentWithAccessibilityEnabled(content: @Composable () -> Unit)Synchronization utilities for waiting on UI state changes and ensuring test stability.
/**
* Waits for the UI to become idle (no pending animations or state changes)
* @param timeoutMillis - Maximum time to wait in milliseconds (default: 500)
* @throws AssertionError if UI doesn't become idle within timeout
*/
fun UIKitInstrumentedTest.waitForIdle(timeoutMillis: Long = 500)
/**
* Waits until a specific condition is met
* @param conditionDescription - Description of what condition is being waited for
* @param timeoutMillis - Maximum time to wait in milliseconds (default: 5,000)
* @param condition - Function that returns true when condition is satisfied
* @throws AssertionError if condition is not met within timeout
*/
fun UIKitInstrumentedTest.waitUntil(
conditionDescription: String? = null,
timeoutMillis: Long = 5_000,
condition: () -> Boolean
)
/**
* Introduces a delay using NSRunLoop for precise timing control
* @param timeoutMillis - Duration to delay in milliseconds
*/
fun UIKitInstrumentedTest.delay(timeoutMillis: Long)
/**
* Tears down the test environment and cleans up resources
*/
fun UIKitInstrumentedTest.tearDown()Usage Examples:
// Wait for animations to complete
waitForIdle()
// Wait for specific condition
waitUntil {
findNodeWithLabel("Loading...") == null
}
// Introduce controlled delay
delay(500)Properties providing information about the test environment and device characteristics.
/**
* Screen density for coordinate conversion between dp and pixels
*/
val UIKitInstrumentedTest.density: Density
/**
* Screen size in density-independent pixels
*/
val UIKitInstrumentedTest.screenSize: DpSizeUsage Example:
runUIKitInstrumentedTest {
val centerX = screenSize.width / 2
val centerY = screenSize.height / 2
val centerPosition = DpOffset(centerX, centerY)
tap(centerPosition)
}Mock app delegate implementation for test environment setup and window management.
/**
* Mock app delegate for iOS testing environment
* Handles window creation and app lifecycle events
*/
class MockAppDelegate {
val window: UIWindow?
fun application(
application: UIApplication,
didFinishLaunchingWithOptions: Map<UIApplicationLaunchOptionsKey, Any>?
): Boolean
}The testing framework includes comprehensive error handling:
waitForIdle() or waitUntil() operations exceed specified timeoutExample Error Handling:
runUIKitInstrumentedTest {
setContent { Text("Test") }
try {
waitUntil(timeoutMillis = 1000) {
findNodeWithLabel("NonExistent") != null
}
} catch (e: TimeoutException) {
// Handle timeout gracefully
println("Expected element not found within timeout")
}
}Install with Tessl CLI
npx tessl i tessl/maven-org-jetbrains-compose-ui--ui-util-uikitsimarm64