tawasuyu

tawasuyu/llimphi

Sovereign retained-mode GPU UI framework in Rust (wgpu+vello+taffy+parley), Elm loop, 40+ widgets.

Rust 660Markdown 302TOML 157RON 312382 Definiciones

⎇ 168cd187519c0ad575d3ce63baee2f164c38d9d1 modules/mini-map/tests/smoke.rs Rust · 63 líneas · 1.9 KB Historia Quién tocó qué crudo

chore: refresco desde el monorepo — 128 miembros, los 76 widgets y los 11 módulos b3f12e136 · Sergio ·

1//! Smoke tests del minimap. Sin backend grafico — solo `apply`,
2//! `on_key`, `open_shortcut` y la conversion y->line.
3
4use llimphi_module_mini_map::{
5    self as minimap, MiniMapAction, MiniMapMsg, MiniMapState,
6};
7use llimphi_compositor::{Key, KeyEvent, KeyState, Modifiers};
8
9fn key_with(ctrl: bool, shift: bool, ch: &str) -> KeyEvent {
10    KeyEvent {
11        key: Key::Character(ch.into()),
12        state: KeyState::Pressed,
13        text: Some(ch.into()),
14        modifiers: Modifiers { ctrl, shift, ..Modifiers::default() },
15        repeat: false,
16    }
17}
18
19#[test]
20fn open_shortcut_es_ctrl_shift_m() {
21    assert!(minimap::open_shortcut(&key_with(true, true, "m")));
22    assert!(minimap::open_shortcut(&key_with(true, true, "M")));
23    assert!(!minimap::open_shortcut(&key_with(true, false, "m")));
24    assert!(!minimap::open_shortcut(&key_with(false, true, "m")));
25}
26
27#[test]
28fn jump_emite_jumpto() {
29    let mut s = MiniMapState::new();
30    let action = minimap::apply(&mut s, MiniMapMsg::Jump(42));
31    assert_eq!(action, MiniMapAction::JumpTo(42));
32}
33
34#[test]
35fn close_emite_close() {
36    let mut s = MiniMapState::new();
37    let action = minimap::apply(&mut s, MiniMapMsg::Close);
38    assert_eq!(action, MiniMapAction::Close);
39}
40
41#[test]
42fn y_to_line_proporcional() {
43    // 100 lineas, panel de 200 px → cada linea ocupa 2 px.
44    assert_eq!(minimap::y_to_line(0.0, 200.0, 100), 0);
45    assert_eq!(minimap::y_to_line(100.0, 200.0, 100), 50);
46    assert_eq!(minimap::y_to_line(200.0, 200.0, 100), 99);
47    // Clamping fuera de rango.
48    assert_eq!(minimap::y_to_line(-50.0, 200.0, 100), 0);
49    assert_eq!(minimap::y_to_line(500.0, 200.0, 100), 99);
50}
51
52#[test]
53fn y_to_line_buffer_vacio_no_paniquea() {
54    assert_eq!(minimap::y_to_line(0.0, 100.0, 0), 0);
55    assert_eq!(minimap::y_to_line(50.0, 100.0, 0), 0);
56}
57
58#[test]
59fn on_key_es_pasivo() {
60    let s = MiniMapState::new();
61    let ev = key_with(false, false, "a");
62    assert!(minimap::on_key(&s, &ev).is_none());
63}