#include "IronsPerformanceOverlay.h" #include "Misc/AutomationTest.h" #if WITH_DEV_AUTOMATION_TESTS IMPLEMENT_SIMPLE_AUTOMATION_TEST(FIronsPerformanceLayoutTest,"IRONSPORE.Performance.ViewportLayout",EAutomationTestFlags::EditorContext|EAutomationTestFlags::EngineFilter) bool FIronsPerformanceLayoutTest::RunTest(const FString& Parameters) { for(const auto Size:{FVector2D(1280,720),FVector2D(1920,1080),FVector2D(2560,1440),FVector2D(3440,1440)})for(int32 Corner=0;Corner<4;++Corner){ const auto L=FIronsPerformanceLayout::Make(Size,true,Corner); const FSlateRect Content(L.ContentOrigin.X,L.ContentOrigin.Y,L.ContentOrigin.X+1920*L.ContentScale,L.ContentOrigin.Y+1080*L.ContentScale); TestTrue(TEXT("Panel remains in the actual viewport"),L.Panel.Left>=0&&L.Panel.Top>=0&&L.Panel.Right<=Size.X&&L.Panel.Bottom<=Size.Y); TestTrue(TEXT("Existing content never intersects the panel band"),Content.Bottom<=L.Panel.Top||Content.Top>=L.Panel.Bottom); const FVector2D Source(1730,610),Screen=Source*L.ContentScale+L.ContentOrigin; TestTrue(TEXT("Grid pointer coordinates survive safe-band projection"),((Screen-L.ContentOrigin)/L.ContentScale).Equals(Source,.001)); const FVector2D Aim=(Size*.5-L.ContentOrigin)/L.ContentScale; TestTrue(TEXT("Crosshair remains at actual viewport center"),(Aim*L.ContentScale+L.ContentOrigin).Equals(Size*.5,.001)); const float Margin=16*L.PanelScale; TestTrue(TEXT("Wide-screen right anchor uses real viewport edge"),Corner==1||Corner==3||FMath::IsNearlyEqual(L.Panel.Right,static_cast(Size.X)-Margin,.01f)); } const auto Hidden=FIronsPerformanceLayout::Make(FVector2D(1920,1080),false,0); TestTrue(TEXT("Hidden panel releases the reserved band"),Hidden.ContentOrigin.IsNearlyZero()&&FMath::IsNearlyEqual(Hidden.ContentScale,1.f)); return true; } #endif