Expand description
Testing utilities for Floem UI applications.
This crate provides a headless harness for testing Floem views without creating an actual window.
§Example
ⓘ
use floem_test::prelude::*;
#[test]
fn test_button_click() {
let tracker = ClickTracker::new();
let view = tracker.track(
Empty::new().style(|s| s.size(100.0, 100.0))
);
let mut harness = HeadlessHarness::new_with_size(view, 100.0, 100.0);
harness.click(50.0, 50.0);
assert!(tracker.was_clicked());
}§Testing Z-Index / Layered Views
ⓘ
use floem_test::prelude::*;
#[test]
fn test_z_index_click_order() {
let tracker = ClickTracker::new();
// Create overlapping views with different z-indices
let view = layers((
tracker.track_named("back", Empty::new().z_index(1)),
tracker.track_named("front", Empty::new().z_index(10)),
));
let mut harness = HeadlessHarness::new_with_size(view, 100.0, 100.0);
harness.click(50.0, 50.0);
// Front (z-index 10) should receive the click
assert_eq!(tracker.clicked_names(), vec!["front"]);
}Modules§
- prelude
- Prelude module for convenient imports in tests.
Structs§
- Click
Tracker - Tracks click events on views for testing.
- Event
Result - Result of an event dispatch operation.
- Headless
Harness - A headless harness for UI testing and benchmarking.
- Point
- Tracks scroll events on Scroll views for testing.
- Pointer
Capture Tracker - Tracks pointer capture events on views for testing.
- Rect
- Tracks scroll events on Scroll views for testing.
- Scroll
Tracker - Test
Root - A test root that owns a root ViewId and sets it as the current view.
- ViewId
- A small unique identifier, and handle, for an instance of a View.