Engine Latent Commands

I’m trying to write some custom automated test for our game and editor. There area lot of handy LatentCommands such as FWaitLatentCommand(), but when I try to access these in editor tests I get linker errors. Compiling the game works just fine. What am I missing?

Hi there!

Which latent commands are you trying to use? You might be running into an issue that’s actually burned me a couple of times - some commands are defined as engine latent commands, and some aren’t! The engine ones are available globally, but the other ones will be something you’ll need to give yourself access to via either include.

Thanks!
Ben

Hey again -

Change the define macros of the functions you’d like to use from DEFINE_LATENT_AUTOMATION_COMMAND to DEFINE_ENGINE_LATENT_AUTOMATION_COMMAND (this works with the ONE PARAMETER versions as well)

Or you can copy the functionality of those latent commands over to a local latent command.

Either of those should work - I hope this helps!

Here’s a few examples of the commands / methods I’m trying to reference. In my editor tests i’m including #include “Tests/AutomationEditorCommon.h” where those are defined.

FLoadGameMapCommand
FStartPIECommand
FEndPlayMapCommand()
Methods:
FEditorAutomationTestUtilities::RunPIE();

Great, thanks!

Hi,
I am trying to use the DEFINE_ENGINE_LATENT_AUTOMATION_COMMAND Macro as well. I can use the DEFINE_LATENT_AUTOMATION_COMMAND and for example change the resolution of the screen. But when I use the
FWaitLatentCommand nothing happens. Everthing compiles fine but the test does not wait.
This is my test so far:

IMPLEMENT_SIMPLE_AUTOMATION_TEST(FYourTestClass, "Name.To.Your.Test", EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext | EAutomationTestFlags::EngineFilter)
bool FYourTestClass::RunTest(const FString& Parameters)
{
	UE_LOG(LogTemp, Log, TEXT("Start Test"));
	ADD_LATENT_AUTOMATION_COMMAND(FExecWorldStringLatentCommandMyOwn(TEXT("StartFPSChart")));
	ADD_LATENT_AUTOMATION_COMMAND(FWaitLatentCommand(1.0));
	ADD_LATENT_AUTOMATION_COMMAND(FExecStringLatentCommandMyOwn(TEXT("setres 640x480")));
	ADD_LATENT_AUTOMATION_COMMAND(FWaitLatentCommand(2000.0));
	ADD_LATENT_AUTOMATION_COMMAND(FExecWorldStringLatentCommandMyOwn(TEXT("StopFPSChart")));
	return true;
}

The test runs and changes the resolution but does not wait.
Any Ideas

So I tried to write a local version of the FWaitLatentCommand which looks like this:

/**
* Wait for the given amount of time
*/
DEFINE_ENGINE_LATENT_AUTOMATION_COMMAND_ONE_PARAMETER(FWaitLatentCommandMyOwn, float, Duration);

In my header. In the cpp I use the exact same code as in the original function:

bool FWaitLatentCommandMyOwn::Update()
{
	float NewTime = FPlatformTime::Seconds();
	UE_LOG(LogTemp, Log, TEXT("Running Wait Command with wait duration: '%f'"), Duration);
	if (NewTime - StartTime >= Duration)
	{
		return true;
	}
	return false;
}

Except that I added a UE_LOG command. But then I can’t compile due to the following error:

: error C4273: 'FWaitLatentCommandMyOwn::Update': inconsistent dll linkage

and

note: see previous definition of 'Update'

So it seem Update is already defined??
Getting more and more confused here. Any ideas?