CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-jetbrains-compose-ui--ui-util-uikitsimarm64

iOS UIKit simulator ARM64 utilities for Compose Multiplatform UI framework providing testing, interoperability, and platform-specific implementations.

Pending
Overview
Eval results
Files

ios-uikit-testing.mddocs/

iOS UIKit Testing

Comprehensive testing infrastructure for iOS UIKit applications with Compose integration, providing test setup, content management, and UI synchronization capabilities.

Capabilities

Test Environment Setup

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))
}

Content Management

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)

UI Synchronization

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)

Test Environment Properties

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: DpSize

Usage Example:

runUIKitInstrumentedTest {
    val centerX = screenSize.width / 2
    val centerY = screenSize.height / 2
    val centerPosition = DpOffset(centerX, centerY)
    
    tap(centerPosition)
}

Mock App Delegate

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
}

Error Handling

The testing framework includes comprehensive error handling:

  • TimeoutException: Thrown when waitForIdle() or waitUntil() operations exceed specified timeout
  • IllegalStateException: Thrown when attempting to interact with UI before content is set
  • Test Assertion Failures: Standard test framework assertion failures for accessibility tree validation

Example 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")
    }
}

Integration Notes

  • UIKit Integration: Seamlessly integrates with UIKit's touch event system and accessibility framework
  • Compose Runtime: Fully compatible with Compose runtime and state management
  • iOS Simulator: Optimized for ARM64 iOS simulator environment
  • Thread Safety: All operations are designed to work with iOS main thread requirements

Install with Tessl CLI

npx tessl i tessl/maven-org-jetbrains-compose-ui--ui-util-uikitsimarm64

docs

accessibility-testing.md

coordinate-utilities.md

index.md

ios-uikit-testing.md

touch-simulation.md

tile.json