Files
ltk/src/widget/separator/tests.rs
T
admin a7f953ca42
CI / build + test (push) Has been cancelled
CI / cargo audit (push) Has been cancelled
layout: adaptive grid and vertical flex; enforce the mechanical style rules
grid_min_cell( width ) adds the adaptive mode WrapGrid was missing: instead of a fixed column count, the count is derived at layout time from the available width so every cell is at least `width` wide (any Length, so a fluid threshold works; never fewer than one column), re-derived on every resize. Cells then share the width equally, and WrapGrid::max_columns( n ) caps the derived count so cells grow instead of multiplying on very wide surfaces — the cap only applies to the adaptive mode, grid( n ) keeps the fixed behaviour untouched. Four new layout tests cover width derivation, spacing accounting, the one-column floor and the cap; the row-wrap assertions check X positions rather than Y because zero-height spacer children produce zero-height rows.
flex( child ) now distributes leftover height inside a Column, mirroring its leftover-width behaviour in a Row: flex children join the weight pool alongside weight-only spacers and y-scrolls, draw their child inside the allocated share at full inner width, and contribute zero to the column's natural height exactly like a row counts flex width. This closes the documented "vertical flex is not yet implemented" gap; the Flex rustdoc and the widgets.md entry now describe both axes.
Add scripts/style-check.sh and a make stylecheck target, wired into CI: mechanical verification of the grep-checkable subset of code_style_guide.md — tab indentation and spaces inside attribute brackets — with comment lines skipped so prose may cite raw attribute syntax. To turn the check on green, the 82 unspaced attribute sites across 24 files (#[test], #[derive(...)], #[cfg(...)], #[allow(...)]) were normalized to the spaced form. CONTRIBUTING and the style guide reference the new target; brace placement and paren spacing remain review concerns.
2026-07-30 22:20:21 +02:00

34 lines
1.1 KiB
Rust

// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2026 Liberux Labs, S. L. <info@liberux.net>
use super::*;
#[ test ]
fn default_thickness_and_pad_follow_the_mode()
{
let s = separator();
assert_eq!( s.thickness, None ); // None → follows the widget-scaling mode
assert_eq!( s.pad_v, None );
}
#[ test ]
fn explicit_zero_pad_v_is_flush_not_the_mode_default()
{
// The Option repr lets `0.0` mean a real flush divider, distinct from
// the mode-following default.
let _g = crate::TEST_GLOBALS_LOCK.lock().unwrap_or_else( |e| e.into_inner() );
let s = separator().pad_v( 0.0 );
let canvas = crate::render::Canvas::new( 412, 900 );
assert_eq!( s.preferred_size( 200.0, &canvas ).1, canvas.geom_px( theme::THICKNESS ) );
}
#[ test ]
fn preferred_height_includes_padding()
{
let _g = crate::TEST_GLOBALS_LOCK.lock().unwrap_or_else( |e| e.into_inner() );
let s = separator();
let canvas = crate::render::Canvas::new( 412, 900 );
let ( _, h ) = s.preferred_size( 200.0, &canvas );
assert_eq!( h, canvas.geom_px( theme::THICKNESS ) + canvas.geom_px( theme::PAD_V ) * 2.0 );
}