// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2026 Liberux Labs, S. L. <info@liberux.net>

use super::*;
use std::sync::Arc;

fn dummy_source() -> ExternalSource
{
	ExternalSource::Texture( Arc::new( | _gl, _rect | None ) )
}

#[ test ]
fn preferred_size_returns_constructed_dimensions()
{
	let w = External::new( 320.0, 200.0, dummy_source() );
	assert_eq!( w.preferred_size( 9999.0 ), ( 320.0, 200.0 ) );
}

#[ test ]
fn opacity_default_is_one()
{
	let w = External::new( 1.0, 1.0, dummy_source() );
	assert_eq!( w.opacity, 1.0 );
}

#[ test ]
fn opacity_setter_clamps_to_unit_range()
{
	let above = External::new( 1.0, 1.0, dummy_source() ).opacity( 1.7 );
	let below = External::new( 1.0, 1.0, dummy_source() ).opacity( -0.4 );
	let mid   = External::new( 1.0, 1.0, dummy_source() ).opacity( 0.5 );
	assert_eq!( above.opacity, 1.0 );
	assert_eq!( below.opacity, 0.0 );
	assert_eq!( mid.opacity,   0.5 );
}
