// Debug/Tests/FT_DebugNavigation.ts import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts'; import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts'; import { AC_Movement } from '#root/Movement/Components/AC_Movement.ts'; import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts'; import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts'; import { FunctionalTest } from '#root/UE/FunctionalTest.ts'; import type { Integer } from '#root/UE/Integer.ts'; /** * Functional Test: Debug HUD Navigation System * Tests page navigation state management during NextPage/PreviousPage operations */ export class FT_DebugNavigation extends FunctionalTest { // ════════════════════════════════════════════════════════════════════════════════════════ // GRAPHS // ════════════════════════════════════════════════════════════════════════════════════════ // ──────────────────────────────────────────────────────────────────────────────────────── // EventGraph // ──────────────────────────────────────────────────────────────────────────────────────── /** * Test entry point - validates navigation state during page operations * Uses nested validation to ensure CurrentPageIndex stays valid */ EventStartTest(): void { this.DebugHUDComponent.InitializeDebugHUD( this.MovementComponent, this.ToastSystemComponent, this.InputDeviceComponent ); this.IfValid('Debug HUD: Navigation invalid initial state', () => { this.IfValid( 'Debug HUD: NextPage failed — Invalid state before NextPage', () => { this.DebugHUDComponent.NextPage(); this.IfValid( 'Debug HUD: NextPage failed — State became invalid after NextPage', () => { this.DebugHUDComponent.PreviousPage(); this.IfValid( 'Debug HUD: PrevPage failed — State became invalid after PreviousPage', () => { this.FinishTest(EFunctionalTestResult.Succeeded); } ); } ); } ); }); } // ════════════════════════════════════════════════════════════════════════════════════════ // MACROS // ════════════════════════════════════════════════════════════════════════════════════════ /** * Validates current page index and executes callback if state is valid * @param Message - Error message if validation fails * @param Out - Callback to execute if state is valid */ private IfValid(Message: string, Out: () => void): void { const IsPageIndexOutOfBounds = ( visiblePagesLength: Integer, currentPage: Integer ): boolean => visiblePagesLength > 0 && currentPage >= visiblePagesLength; const IsPageIndexNonNegative = (currentPage: Integer): boolean => currentPage >= 0; if ( !IsPageIndexOutOfBounds( this.DebugHUDComponent.GetVisiblePages().length, this.DebugHUDComponent.DebugSettings.CurrentPageIndex ) && IsPageIndexNonNegative( this.DebugHUDComponent.DebugSettings.CurrentPageIndex ) ) { Out(); } else { this.FinishTest(EFunctionalTestResult.Failed, Message); } } // ════════════════════════════════════════════════════════════════════════════════════════ // VARIABLES // ════════════════════════════════════════════════════════════════════════════════════════ /** * Movement system component - required for debug HUD initialization * @category Components */ MovementComponent = new AC_Movement(); /** * Debug HUD system - primary component under test * Tests page navigation state management * @category Components */ DebugHUDComponent = new AC_DebugHUD(); /** * Toast notification system - required for debug HUD initialization * @category Components */ ToastSystemComponent = new AC_ToastSystem(); /** * Input device detection system - used for input device debug page testing * @category Components */ InputDeviceComponent = new AC_InputDevice(); }