// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseIETransitionLegibilityTest,
	"HyperTwist.FirstParty.Immersive.PhaseIE.TransitionAndLegibility",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseIETransitionLegibilityTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveTransitionSafetyBoundary TransitionBoundary;
	TestTrue(
		TEXT("The immersive transition-safety boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveTransitionSafetyBoundary(
			TEXT("immersive-training-transition-safety-boundary"),
			TransitionBoundary
		)
	);
	TestTrue(
		TEXT("The immersive transition-safety boundary must preserve no-snap teleport shift."),
		TransitionBoundary.ComfortTransitionIds.Contains(TEXT("transition-safety/no-snap-teleport-shift"))
	);
	TestTrue(
		TEXT("The immersive transition-safety boundary must preserve the no-flash-pulse transition guard."),
		TransitionBoundary.GuardSurfaceTags.Contains(TEXT("no-flash-pulse transition guard"))
	);
	TestTrue(
		TEXT("The immersive transition-safety boundary must keep broad camera-system ownership excluded."),
		TransitionBoundary.ExplicitExclusions.Contains(TEXT("broad camera-system ownership"))
	);

	FHyperTwistTrainingImmersiveAccessibilityLegibilityContract AccessibilityContract;
	TestTrue(
		TEXT("The immersive accessibility-legibility contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveAccessibilityLegibilityContract(
			TEXT("immersive-training-accessibility-legibility-contract"),
			AccessibilityContract
		)
	);
	TestEqual(
		TEXT("The immersive accessibility-legibility contract id must stay stable."),
		AccessibilityContract.ContractId,
		TEXT("immersive-training-accessibility-legibility-contract")
	);
	TestTrue(
		TEXT("The immersive accessibility-legibility contract must preserve high-contrast puzzle focus."),
		AccessibilityContract.AccessibilityModeIds.Contains(TEXT("accessibility/high-contrast-puzzle-focus"))
	);
	TestTrue(
		TEXT("The immersive accessibility-legibility contract must preserve reduced bloom scenic path."),
		AccessibilityContract.ReducedEffectsSurfaceTags.Contains(TEXT("reduced-bloom scenic path"))
	);
	TestTrue(
		TEXT("The immersive accessibility-legibility contract must keep platform-global accessibility profile ownership excluded."),
		AccessibilityContract.ExplicitExclusions.Contains(TEXT("platform-global accessibility profile ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseIEPerformanceBudgetTest,
	"HyperTwist.FirstParty.Immersive.PhaseIE.PerformanceBudget",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseIEPerformanceBudgetTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersivePerformanceBudgetBoundary Boundary;
	TestTrue(
		TEXT("The immersive performance-budget boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersivePerformanceBudgetBoundary(
			TEXT("immersive-training-performance-budget-boundary"),
			Boundary
		)
	);
	TestTrue(
		TEXT("The immersive performance-budget boundary must preserve the reduced-effects-safe budget profile."),
		Boundary.BudgetProfileIds.Contains(TEXT("performance-budget/reduced-effects-safe"))
	);
	TestTrue(
		TEXT("The immersive performance-budget boundary must preserve coach-and-puzzle first render budget."),
		Boundary.PerformanceSurfaceTags.Contains(TEXT("coach-and-puzzle first render budget"))
	);
	TestTrue(
		TEXT("The immersive performance-budget boundary must preserve the frame-time regression trigger."),
		Boundary.FallbackTriggerTags.Contains(TEXT("frame-time regression trigger"))
	);
	TestTrue(
		TEXT("The immersive performance-budget boundary must keep renderer feature-matrix ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("renderer feature-matrix ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseIEFallbackModeTest,
	"HyperTwist.FirstParty.Immersive.PhaseIE.FallbackModes",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseIEFallbackModeTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveFallbackModeContract Contract;
	TestTrue(
		TEXT("The immersive fallback-mode contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveFallbackModeContract(
			TEXT("immersive-training-fallback-mode-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The immersive fallback-mode contract id must stay stable."),
		Contract.ContractId,
		TEXT("immersive-training-fallback-mode-contract")
	);
	TestTrue(
		TEXT("The immersive fallback-mode contract must preserve reduced-effects scenic fallback."),
		Contract.FallbackModeIds.Contains(TEXT("fallback-mode/reduced-effects-scenic"))
	);
	TestTrue(
		TEXT("The immersive fallback-mode contract must preserve reduced-effects fallback path."),
		Contract.ReducedEffectsPathTags.Contains(TEXT("reduced-effects fallback path"))
	);
	TestTrue(
		TEXT("The immersive fallback-mode contract must preserve puzzle-and-coach continuity guarantee."),
		Contract.CompatibilitySurfaceTags.Contains(TEXT("puzzle-and-coach continuity guarantee"))
	);
	TestTrue(
		TEXT("The immersive fallback-mode contract must keep generic graphics settings menu ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic graphics settings menu ownership"))
	);
	return true;
}

#endif
