// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseIDSessionStateCueTest,
	"HyperTwist.FirstParty.Immersive.PhaseID.SessionStateCues",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseIDSessionStateCueTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveSessionStateCueContract Contract;
	TestTrue(
		TEXT("The immersive session-state cue contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveSessionStateCueContract(
			TEXT("immersive-training-session-state-cue-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The immersive session-state cue id must stay stable."),
		Contract.ContractId,
		TEXT("immersive-training-session-state-cue-contract")
	);
	TestTrue(
		TEXT("The immersive session-state cue contract must preserve mastery state."),
		Contract.SessionStateIds.Contains(TEXT("session-state/mastery"))
	);
	TestTrue(
		TEXT("The immersive session-state cue contract must preserve mastery settle glow transition."),
		Contract.TransitionCueIds.Contains(TEXT("transition-cue/mastery-settle-glow"))
	);
	TestTrue(
		TEXT("The immersive session-state cue contract must preserve review-safe environmental fade."),
		Contract.TransitionSurfaceTags.Contains(TEXT("review-safe environmental fade"))
	);
	TestTrue(
		TEXT("The immersive session-state cue contract must keep spectacle transitions excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("theatrical spectacle transition ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseIDLightingAndAudioPacingTest,
	"HyperTwist.FirstParty.Immersive.PhaseID.LightingAndAudioPacing",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseIDLightingAndAudioPacingTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveLightingReactionBoundary LightingBoundary;
	TestTrue(
		TEXT("The immersive lighting reaction boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveLightingReactionBoundary(
			TEXT("immersive-training-lighting-reaction-boundary"),
			LightingBoundary
		)
	);
	TestTrue(
		TEXT("The immersive lighting reaction boundary must preserve challenge-mode contrast push."),
		LightingBoundary.LightingSurfaceTags.Contains(TEXT("challenge-mode contrast push"))
	);
	TestTrue(
		TEXT("The immersive lighting reaction boundary must preserve puzzle-face visibility clamp."),
		LightingBoundary.LegibilityGuardTags.Contains(TEXT("puzzle-face visibility clamp"))
	);
	TestTrue(
		TEXT("The immersive lighting reaction boundary must keep shader FX ownership excluded."),
		LightingBoundary.ExplicitExclusions.Contains(TEXT("generic shader FX ownership"))
	);

	FHyperTwistTrainingImmersiveAudioPacingBoundary AudioBoundary;
	TestTrue(
		TEXT("The immersive audio pacing boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveAudioPacingBoundary(
			TEXT("immersive-training-audio-pacing-boundary"),
			AudioBoundary
		)
	);
	TestTrue(
		TEXT("The immersive audio pacing boundary must preserve mastery release rise."),
		AudioBoundary.AudioPacingModeIds.Contains(TEXT("audio-pacing/mastery-release-rise"))
	);
	TestTrue(
		TEXT("The immersive audio pacing boundary must preserve correction-state ducking."),
		AudioBoundary.AudioSurfaceTags.Contains(TEXT("correction-state ducking"))
	);
	TestTrue(
		TEXT("The immersive audio pacing boundary must preserve challenge-mode tightened pacing."),
		AudioBoundary.PacingSurfaceTags.Contains(TEXT("challenge-mode tightened pacing"))
	);
	TestTrue(
		TEXT("The immersive audio pacing boundary must keep soundtrack scoring ownership excluded."),
		AudioBoundary.ExplicitExclusions.Contains(TEXT("full soundtrack scoring ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseIDModeDifferentiationTest,
	"HyperTwist.FirstParty.Immersive.PhaseID.ModeDifferentiation",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseIDModeDifferentiationTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveModeDifferentiationContract Contract;
	TestTrue(
		TEXT("The immersive mode-differentiation contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveModeDifferentiationContract(
			TEXT("immersive-training-mode-differentiation-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The immersive mode-differentiation id must stay stable."),
		Contract.ContractId,
		TEXT("immersive-training-mode-differentiation-contract")
	);
	TestTrue(
		TEXT("The immersive mode-differentiation contract must preserve challenge mode."),
		Contract.ModeIds.Contains(TEXT("mode/challenge"))
	);
	TestTrue(
		TEXT("The immersive mode-differentiation contract must preserve study-mode atmospheric softness."),
		Contract.DifferentiationSurfaceTags.Contains(TEXT("study-mode atmospheric softness"))
	);
	TestTrue(
		TEXT("The immersive mode-differentiation contract must preserve no-theatrical-overreaction guard."),
		Contract.GuardSurfaceTags.Contains(TEXT("no-theatrical-overreaction guard"))
	);
	TestTrue(
		TEXT("The immersive mode-differentiation contract must keep narrative mode ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("broad narrative mode ownership"))
	);
	return true;
}

#endif
