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.
This commit is contained in:
75
src/widget/viewport/tests.rs
Normal file
75
src/widget/viewport/tests.rs
Normal file
@@ -0,0 +1,75 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-only
|
||||
// Copyright (C) 2026 Liberux Labs, S. L. <info@liberux.net>
|
||||
|
||||
use super::*;
|
||||
use crate::layout::spacer::spacer;
|
||||
use crate::render::Canvas;
|
||||
|
||||
fn make_canvas() -> Canvas { Canvas::new( 800, 600 ) }
|
||||
|
||||
#[ test ]
|
||||
fn new_defaults_are_unset_dimensions_and_no_fade()
|
||||
{
|
||||
let v = Viewport::<()>::new( spacer() );
|
||||
assert!( v.width.is_none() );
|
||||
assert!( v.height.is_none() );
|
||||
assert_eq!( v.fade_bottom, 0.0 );
|
||||
}
|
||||
|
||||
#[ test ]
|
||||
fn width_builder_clamps_negative_to_zero()
|
||||
{
|
||||
let v = Viewport::<()>::new( spacer() ).width( -50.0 );
|
||||
assert_eq!( v.width, Some( 0.0 ) );
|
||||
}
|
||||
|
||||
#[ test ]
|
||||
fn height_builder_clamps_negative_to_zero()
|
||||
{
|
||||
let v = Viewport::<()>::new( spacer() ).height( -10.0 );
|
||||
assert_eq!( v.height, Some( 0.0 ) );
|
||||
}
|
||||
|
||||
#[ test ]
|
||||
fn fade_bottom_clamps_negative_to_zero()
|
||||
{
|
||||
let v = Viewport::<()>::new( spacer() ).fade_bottom( -1.0 );
|
||||
assert_eq!( v.fade_bottom, 0.0 );
|
||||
}
|
||||
|
||||
#[ test ]
|
||||
fn fade_bottom_accepts_positive_pixel_count()
|
||||
{
|
||||
let v = Viewport::<()>::new( spacer() ).fade_bottom( 16.0 );
|
||||
assert_eq!( v.fade_bottom, 16.0 );
|
||||
}
|
||||
|
||||
#[ test ]
|
||||
fn explicit_dimensions_override_child_intrinsic_size()
|
||||
{
|
||||
let v = Viewport::<()>::new( spacer().width( 99.0 ).height( 99.0 ) )
|
||||
.width( 200.0 )
|
||||
.height( 80.0 );
|
||||
let canvas = make_canvas();
|
||||
let ( w, h ) = v.preferred_size( 600.0, &canvas );
|
||||
assert_eq!( w, 200.0 );
|
||||
assert_eq!( h, 80.0 );
|
||||
}
|
||||
|
||||
#[ test ]
|
||||
fn unset_width_falls_through_to_max_width()
|
||||
{
|
||||
let v = Viewport::<()>::new( spacer().height( 40.0 ) );
|
||||
let canvas = make_canvas();
|
||||
let ( w, _ ) = v.preferred_size( 400.0, &canvas );
|
||||
assert_eq!( w, 400.0 );
|
||||
}
|
||||
|
||||
#[ test ]
|
||||
fn unset_height_falls_through_to_child_intrinsic_height()
|
||||
{
|
||||
let v = Viewport::<()>::new( spacer().height( 75.0 ) );
|
||||
let canvas = make_canvas();
|
||||
let ( _, h ) = v.preferred_size( 400.0, &canvas );
|
||||
assert_eq!( h, 75.0 );
|
||||
}
|
||||
Reference in New Issue
Block a user