// SPDX-License-Identifier: LGPL-2.1-only // Copyright (C) 2026 Liberux Labs, S. L. use super::*; use crate::render::Canvas; #[ test ] fn default_size_follows_widget_scaling() { let _g = crate::TEST_GLOBALS_LOCK.lock().unwrap_or_else( |e| e.into_inner() ); let canvas = Canvas::new( 412, 412 ); let b = window_button::<()>( WindowButtonKind::Close ); let s = canvas.geom_px( theme::SIZE ); assert_eq!( b.preferred_size( 1000.0, &canvas ), ( s, s ) ); } #[ test ] fn controls_has_three_children() { let controls = window_controls::<()>( Some( () ), WindowButtonKind::Maximize, Some( () ), Some( () ), ); assert_eq!( controls.children.len(), 3 ); } #[ test ] fn icon_names_resolve_each_kind_to_the_window_catalogue() { // Lock the catalogue paths so a future rename of the on-disk // SVG (e.g. close.svg → x.svg) breaks this test instead of // silently falling back to the programmatic glyph at runtime. assert_eq!( icon_name( WindowButtonKind::Minimize ), "window/minimize" ); assert_eq!( icon_name( WindowButtonKind::Maximize ), "window/maximize" ); assert_eq!( icon_name( WindowButtonKind::Restore ), "window/restore" ); assert_eq!( icon_name( WindowButtonKind::Close ), "window/close" ); } #[ test ] fn paint_bounds_unchanged_after_glyph_refactor() { // The SVG glyph paints inside the button rect just like the // programmatic one did, so paint_bounds must stay equal to // the previous value (rect expanded by the focus-ring slack). let b = window_button::<()>( WindowButtonKind::Close ); let rect = Rect { x: 10.0, y: 10.0, width: 36.0, height: 36.0 }; let bounds = b.paint_bounds( rect ); let slack = theme::FOCUS_W * 1.5 + 2.0; assert!( ( bounds.x - ( rect.x - slack ) ).abs() < 0.01 ); assert!( ( bounds.y - ( rect.y - slack ) ).abs() < 0.01 ); assert!( ( bounds.width - ( rect.width + slack * 2.0 ) ).abs() < 0.01 ); assert!( ( bounds.height - ( rect.height + slack * 2.0 ) ).abs() < 0.01 ); }