First commit. Version 0.1.0
This commit is contained in:
63
tests/common/mod.rs
Normal file
63
tests/common/mod.rs
Normal file
@@ -0,0 +1,63 @@
|
||||
// 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,
|
||||
}
|
||||
}
|
||||
|
||||
/// 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,
|
||||
}
|
||||
}
|
||||
|
||||
/// 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,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rect( x: f32, y: f32, w: f32, h: f32 ) -> Rect
|
||||
{
|
||||
Rect { x, y, width: w, height: h }
|
||||
}
|
||||
Reference in New Issue
Block a user