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

touch-simulation.mddocs/

Touch Simulation

Touch event simulation system for iOS devices, providing hardware-level touch event generation, drag gesture support, and precise touch interaction capabilities.

Capabilities

Basic Touch Events

Core touch event functions for simulating finger interactions on iOS devices.

/**
 * Simulates a touch-down event at the specified position
 * @param position - Location to touch in density-independent pixels
 * @return UITouch instance for further gesture operations
 */
fun UIKitInstrumentedTest.touchDown(position: DpOffset): UITouch

/**
 * Simulates a complete tap gesture (touch down + touch up) at specified position
 * @param position - Location to tap in density-independent pixels
 * @return UITouch instance after completing the tap
 */
fun UIKitInstrumentedTest.tap(position: DpOffset): UITouch

Usage Examples:

runUIKitInstrumentedTest {
    setContent {
        Button(onClick = { /* action */ }) {
            Text("Tap me!")
        }
    }
    
    // Simple tap
    tap(DpOffset(100.dp, 200.dp))
    
    // Touch down for complex gestures
    val touch = touchDown(DpOffset(50.dp, 50.dp))
    // ... perform drag operations with touch
    touch.up()
}

Drag Gestures

Advanced drag gesture simulation with duration control and precise positioning.

/**
 * Drags touch to target location over specified duration
 * @param location - Target location in density-independent pixels
 * @param duration - Duration of drag operation (default: 0.5.seconds)
 * @return UITouch instance after completing the drag
 */
fun UITouch.dragTo(location: DpOffset, duration: Duration = 0.5.seconds): UITouch

/**
 * Drags touch by specified offset from current position over specified duration
 * @param offset - Offset to drag by in density-independent pixels
 * @param duration - Duration of drag operation (default: 0.5.seconds)
 * @return UITouch instance after completing the drag
 */
fun UITouch.dragBy(offset: DpOffset, duration: Duration = 0.5.seconds): UITouch

/**
 * Drags touch by specified x and y components over specified duration
 * @param dx - Horizontal offset in density-independent pixels (default: 0.dp)
 * @param dy - Vertical offset in density-independent pixels (default: 0.dp)
 * @param duration - Duration of drag operation (default: 0.5.seconds)
 * @return UITouch instance after completing the drag
 */
fun UITouch.dragBy(dx: Dp = 0.dp, dy: Dp = 0.dp, duration: Duration = 0.5.seconds): UITouch

Usage Examples:

runUIKitInstrumentedTest {
    setContent {
        LazyColumn {
            items(100) { index ->
                Text("Item $index")
            }
        }
    }
    
    // Drag to scroll list
    val touch = touchDown(DpOffset(200.dp, 400.dp))
    touch.dragTo(DpOffset(200.dp, 100.dp), durationMillis = 500)
    touch.up()
    
    // Drag by offset for precise movements
    val touch2 = touchDown(DpOffset(100.dp, 100.dp))
    touch2.dragBy(DpOffset(50.dp, 100.dp))
    touch2.up()
}

Touch State Management

Low-level touch state management functions for complex gesture sequences.

/**
 * Moves touch to new location in window coordinates
 * @param location - New location in density-independent pixels
 */
fun UITouch.moveToLocationOnWindow(location: DpOffset)

/**
 * Holds touch in stationary phase
 * @return UITouch instance after holding
 */
fun UITouch.hold(): UITouch

/**
 * Lifts touch, ending the touch interaction
 * @return UITouch instance after lifting
 */
fun UITouch.up(): UITouch

Window-Level Touch Operations

Window-level touch operations for precise control over touch event generation.

/**
 * Creates a touch event at specified point in window
 * @param location - Location in window coordinates as DpOffset
 * @return UITouch instance for gesture operations
 */
internal fun UIWindow.touchDown(location: DpOffset): UITouch

Touch Properties

Properties for accessing touch state and location information.

/**
 * Current touch location in hosting view coordinates
 */
val UITouch.location: DpOffset

Usage Example:

runUIKitInstrumentedTest {
    val touch = touchDown(DpOffset(100.dp, 100.dp))
    
    println("Touch started at: ${touch.location}")
    
    touch.moveToLocationOnWindow(DpOffset(200.dp, 200.dp))
    println("Touch moved to: ${touch.location}")
    
    touch.hold(500) // Hold for half a second
    touch.up()
}

Advanced Gesture Patterns

Multi-Touch Gestures

// Simulate pinch gesture
val touch1 = touchDown(DpOffset(100.dp, 100.dp))
val touch2 = touchDown(DpOffset(200.dp, 200.dp))

// Move touches apart (zoom out)
touch1.dragTo(DpOffset(50.dp, 50.dp))
touch2.dragTo(DpOffset(250.dp, 250.dp))

touch1.up()
touch2.up()

Complex Scroll Gestures

// Simulate fling scroll
val touch = touchDown(DpOffset(200.dp, 400.dp))
touch.dragTo(DpOffset(200.dp, 100.dp), durationMillis = 100) // Fast drag
touch.up()

Long Press Gestures

// Simulate long press
val touch = touchDown(DpOffset(150.dp, 150.dp))
touch.hold(1000) // Hold for 1 second
touch.up()

Platform Integration

  • UIKit Touch System: Direct integration with iOS UIKit touch event handling
  • Hardware Simulation: Accurately simulates hardware-level touch events
  • Coordinate Systems: Seamless conversion between Compose and UIKit coordinate systems
  • Event Timing: Precise timing control for realistic gesture simulation
  • Multi-Touch Support: Full support for multi-finger gestures and complex interactions

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