Files
ltk/tests/common/mod.rs
Pedro M. de Echanove Pasquin 4aa3480b64 refactor: split every monolithic module into focused submodules
Each source file that had grown beyond a single concern is replaced by an identically-named directory containing focused submodules. `src/event_loop/mod.rs` (878 lines) becomes a directory with clipboard, context_menu, cursor_shape, drag, focus, handlers, invalidation, overlays_reconcile, repeat, run, surface, text_editing, and tooltip. Every widget, input handler, and theme component follows the same split. Public interfaces are unchanged — only the internal file layout moves.
image bumped from 0.25.2 to 0.25.9.
2026-05-15 23:46:56 +02:00

67 lines
2.1 KiB
Rust

// Shared fixtures for the integration tests in this directory. Each test
// binary compiles its own copy of this module and only sees the helpers it
// actually uses as "live", so the rest trip the `dead_code` lint —
// `#![allow(dead_code)]` is the standard fix for shared `tests/common/`.
#![ allow( dead_code ) ]
use ltk::test_support::{ LaidOutWidget, WidgetHandlers };
use ltk::{ CursorShape, Rect };
/// Build a synthetic [`LaidOutWidget`] with no handlers. The `flat_idx` is
/// what most tree lookups key on; `rect` is what hit testing keys on.
/// Defaults to `keyboard_focusable = true` so existing Tab-navigation tests
/// keep their meaning — the entry behaves like a typical Button.
pub fn lw_none( flat_idx: usize, rect: Rect ) -> LaidOutWidget<()>
{
LaidOutWidget
{
rect,
flat_idx,
id: None,
paint_rect: rect,
handlers: WidgetHandlers::None,
keyboard_focusable: true,
cursor: CursorShape::Default,
tooltip: None,
}
}
/// Variant: synthetic Button entry that emits `()` on press.
pub fn lw_button( flat_idx: usize, rect: Rect ) -> LaidOutWidget<()>
{
LaidOutWidget
{
rect,
flat_idx,
id: None,
paint_rect: rect,
handlers: WidgetHandlers::Button { on_press: Some( () ), on_long_press: None, on_drag_start: None, on_escape: None, repeating: false },
keyboard_focusable: true,
cursor: CursorShape::Pointer,
tooltip: None,
}
}
/// Variant: synthetic interactive-but-not-focusable entry, modelling chrome
/// such as `WindowButton`. Used by the Tab-navigation tests that verify the
/// projection step skips these.
pub fn lw_chrome( flat_idx: usize, rect: Rect ) -> LaidOutWidget<()>
{
LaidOutWidget
{
rect,
flat_idx,
id: None,
paint_rect: rect,
handlers: WidgetHandlers::WindowButton { on_press: Some( () ) },
keyboard_focusable: false,
cursor: CursorShape::Pointer,
tooltip: None,
}
}
pub fn rect( x: f32, y: f32, w: f32, h: f32 ) -> Rect
{
Rect { x, y, width: w, height: h }
}