// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#include "Tests/AutomationCommon.h"
#include "Tests/AutomationEditorCommon.h"

#include "SimplygonPluginMeshReductionModule.h"

/* General Plugin Tests*/
BEGIN_DEFINE_SPEC(FSimplygonGeneral, "Simplygon.General", EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
	// Add shared members and methods here
	// For example:
	//int32 UsefulInteger = 0;
	//void UtilityMethodForTest();
END_DEFINE_SPEC(FSimplygonGeneral)

void FSimplygonGeneral::Define() {
	It("Verify that simplygon interfaces are selected for native reduction tools", [this]()
	{
		// Note: Fetching console variables like this assumes editor is loaded and running
		IConsoleVariable* CVarMeshMerging = IConsoleManager::Get().FindConsoleVariable(TEXT("r.ProxyLODMeshReductionModule"));
		IConsoleVariable* CVarSkeletalMeshReduction = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SkeletalMeshReductionModule"));
		IConsoleVariable* CVarStaticMeshReduction = IConsoleManager::Get().FindConsoleVariable(TEXT("r.MeshReductionModule"));

		FString MeshMergingModuleName = CVarMeshMerging->GetString();
		FString SkeletalMeshReductionModuleName = CVarSkeletalMeshReduction->GetString();
		FString StaticMeshReductionModuleName = CVarStaticMeshReduction->GetString();

		ISimplygonPluginMeshReductionModule& SimplygonModule = FModuleManager::GetModuleChecked<ISimplygonPluginMeshReductionModule>("SimplygonPluginMeshReduction");

		TestEqual("Mesh merging interface (r.ProxyLODMeshReductionModule)", MeshMergingModuleName, SimplygonModule.GetName());
		TestEqual("Skeletal Mesh reduction interface (r.SkeletalMeshReductionModule)", SkeletalMeshReductionModuleName, SimplygonModule.GetName());
		TestEqual("Static Mesh reduction interface (r.MeshReductionModule)", StaticMeshReductionModuleName, SimplygonModule.GetName());
	});
}