Navigation
API > API/Plugins > API/Plugins/NetcodeUnitTest
Inheritance Hierarchy
- UObject
- FUnitLogInterface
- UUnitTestBase
- UUnitTest
- UProcessUnitTest
- UClientUnitTest
- UFTextCrash
- UIPClient
- USteamClient
- UWebSocketClient
- UUTT61_DebugReplicateData
References
Module | NetcodeUnitTest |
Header | /Engine/Plugins/NetcodeUnitTest/NetcodeUnitTest/Source/NetcodeUnitTest/Classes/ClientUnitTest.h |
Include | #include "ClientUnitTest.h" |
Syntax
UCLASS (Abstract)
class UClientUnitTest : public UProcessUnitTest
Remarks
Base class for all unit tests depending upon a MinimalClient connecting to a server. The MinimalClient handles creation/cleanup of an entire new UWorld, UNetDriver and UNetConnection, for fast unit testing.
NOTE: See NUTEnum.h, for important flags for configuring unit tests and the minimal client.
In subclasses, implement the unit test within the ExecuteClientUnitTest function (remembering to call parent)
Variables
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
TArray< TObjectPtr< UClass > > | AllowedClientActors | Actors the server is allowed replicate to client (requires AllowActors flag). |
![]() |
TArray< FString > | AllowedClientRPCs | Clientside RPC's that should be allowed to execute (requires minimal client NotifyProcessNetEvent flag) |
![]() |
FString | BaseClientParameters | The (non-URL) commandline parameters clients should be launched with |
![]() |
FString | BaseClientURL | The base URL clients should start with |
![]() |
FString | BaseServerParameters | The (non-URL) commandline parameters the server should be launched with |
![]() |
FString | BaseServerURL | The base URL the server should start with |
![]() |
bool | bBlockingClientDelay | Whether or not there is a blocking event/process preventing setup of a client |
![]() |
bool | bBlockingMinClientDelay | Whether or not there is a blocking event/process preventing the minimal client from connecting |
![]() |
bool | bBlockingServerDelay | Whether or not there is a blocking event/process preventing setup of the server |
![]() |
FString | BeaconAddress | The address of the server beacon (if UnitTestFlags are set to connect to a beacon) |
![]() |
bool | bPendingNetworkFailure | An expected network failure occurred, which will be handled during the next tick instead of immediately |
![]() |
bool | bReceivedPong | If EUnitTestFlags::RequirePing is true, whether or not we have already received the pong |
![]() |
bool | bTriggerredInitialConnect | Whether or not the initial connect of the minimal client was triggered |
![]() |
bool | bUnitNUTActorSetup | Whether or not UnitNUTActor is fully setup, i.e. has replicated its Owner |
![]() |
bool | bUnitPawnSetup | Whether or not the UnitPC Pawn was fully setup (requires EUnitTestFlags::RequirePawn) |
![]() |
bool | bUnitPlayerStateSetup | Whether or not the UnitPC PlayerState was fully setup (requires EUnitTestFlags::RequirePlayerState) |
![]() |
TWeakPtr< FUnitTestProcess > | ClientHandle | Reference to the created client process handling struct (if enabled) |
![]() ![]() |
TObjectPtr< UMinimalClient > | MinClient | The object which handles implementation of the minimal client |
![]() |
TSubclassOf< UMinimalClient > | MinClientClass | The class to use for the MinimalClient |
![]() |
EMinClientFlags | MinClientFlags | Flags for configuring the minimal client - lots of interdependencies between these and UnitTestFlags |
![]() |
double | NextBlockingTimeout | When a server is launched after a blocking event/process, this delays the launch of any clients, in case of more blockages |
![]() |
FString | ServerAddress | The address of the launched server |
![]() |
FString | ServerBeaconType | If connecting to a beacon, the beacon type name we are connecting to |
![]() |
TWeakPtr< FUnitTestProcess > | ServerHandle | Runtime variables Reference to the created server process handling struct |
![]() ![]() |
TWeakObjectPtr< AActor > | UnitBeacon | If EUnitTestFlags::RequireBeacon is set, stores a reference to the replicated beacon |
![]() ![]() |
TWeakObjectPtr< ANUTActor > | UnitNUTActor | If EUnitTestFlags::RequireNUTActor is set, stores a reference to the replicated NUTActor |
![]() ![]() |
TWeakObjectPtr< APlayerController > | UnitPC | Client state variables Stores a reference to the replicated PlayerController (if set to wait for this), after NotifyHandleClientPlayer |
![]() |
EUnitTestFlags | UnitTestFlags | Variables which should be specified by every subclass (some depending upon flags) All of the internal unit test parameters/flags, for controlling state and execution |
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
UClientUnitTest
(
const FObjectInitializer& ObjectInitializer |
UClientUnitTest |
Functions
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
void | Cleans up the minimal client | |
![]() ![]() |
bool | ConnectMinimalClient
(
const TCHAR* InNetID |
Connects a minimal client, to the launched/launching server |
![]() ![]() |
FString | ConstructClientParameters
(
FString ConnectIP |
Puts together the commandline parameters clients should use, based upon the unit test settings |
![]() ![]() |
FString | Puts together the commandline parameters the server should use, based upon the unit test settings | |
![]() ![]() |
void | Interface and hooked events for client unit tests Override this, to implement the client unit test NOTE: Should be called last, in overridden functions IMPORTANT: EndUnitTest should be triggered, upon completion of the unit test (which may be delayed, for many unit tests) | |
![]() ![]() |
FString | Accessor for BeaconAddress | |
![]() ![]() |
const TCHAR * | Gets the generic log message that is used to indicate unit test failure | |
![]() |
EUnitTestFlags | Returns the requirements flags, that this unit test currently meets | |
![]() ![]() |
void | GetNextServerPorts
(
int32& OutServerPort, |
Determine the next unique server ports to use - incremented to a new unique number, internally |
![]() |
TWeakPtr< FUnitTestProcess > | Accessor for ServerHandle | |
![]() |
EUnitTestFlags | Accessor for UnitTestFlags | |
![]() ![]() |
bool | Optionally, if the 'RequireCustom' flag is set, this returns whether custom conditions have been met. | |
![]() |
bool | HasAllRequirements
(
bool bIgnoreCustom |
Whether or not all 'requirements' flag conditions have been met |
![]() ![]() |
void | NotifyAllowNetActor
(
UClass* ActorClass, |
Notification triggered BEFORE a replicated actor has been created (allowing you to block creation, based on class) |
![]() ![]() |
void | NotifyAlterMinClient
(
FMinClientParms& Parms |
Gives subclass UnitTest's an opportunity to alter the MinimalClient setup parameters |
![]() ![]() |
void | NotifyControlMessage
(
FInBunch& Bunch, |
Override this, to receive notification of all other non-NMT_NUTControl control messages |
![]() ![]() |
void | NotifyHandleClientPlayer
(
APlayerController* PC, |
Notification that the local net connections PlayerController has been replicated and is being setup |
![]() ![]() |
void | Notification from the minimal client, that it has fully connected | |
![]() ![]() |
void | NotifyNetActor
(
UActorChannel* ActorChannel, |
Override this, to receive notification AFTER an actor channel actor has been created |
![]() ![]() |
void | NotifyNetworkFailure
(
ENetworkFailure::Type FailureType, |
Triggered upon a network connection failure |
![]() ![]() |
void | NotifyNUTControl
(
ENUTControlCommand CmdType, |
Override this, to receive notification of NMT_NUTControl messages, from the server |
![]() ![]() |
void | NotifyProcessEvent
(
AActor* Actor, |
Overridable in subclasses - can be used to control/block any script events, other than receiving of RPC's (see NotifyReceiveRPC) |
![]() ![]() |
void | NotifyReceivedRawPacket
(
void* Data, |
If EUnitTestFlags::CaptureReceiveRaw is set, this is triggered for every packet received from the server NOTE: Data is a uint8 array, of size 'NETWORK_MAX_PACKET', and elements can safely be modified |
![]() ![]() |
void | NotifyReceiveRPC
(
AActor* Actor, |
Overridable in subclasses - can be used to control/block receiving of RPC's |
![]() ![]() |
void | NotifySendRPC
(
AActor* Actor, |
Overridable in subclasses - can be used to control/block sending of RPC's |
![]() ![]() |
void | NotifySocketSendRawPacket
(
void* Data, |
Triggered for every packet sent to the server, when LowLevelSend is called. |
![]() |
void | OnRPCFailure () |
Callback for when an RPC send fails on the minimal client |
![]() ![]() |
void | ReceivedControlBunch
(
FInBunch& Bunch |
Bunches received on the control channel. |
![]() |
void | Sends a generic log message to the server, which (if successfully logged) indicates unit test failure. | |
![]() |
bool | SendNUTControl
(
ENUTControlCommand CommandType, |
Utility functions for use by subclasses Sends an NMT_NUTControl control channel message, for the server NUTActor. |
![]() |
bool | SendRPCChecked
(
UObject* Target, |
See UMinimalClient |
![]() |
bool | SendRPCChecked
(
UObject* Target, |
See UMinimalClient |
![]() |
bool | SendUnitRPCChecked
(
FString RPCName |
As above, except executes a static UFunction in the unit test (must be prefixed with UnitTestServer_), on the unit test server, allowing unit tests to define and contain their own 'pseudo'-RPC's. |
![]() |
bool | SendUnitRPCChecked
(
FString RPCName |
As above, except allows 'UnitTestServer' RPC's to be located in an arbitrary class (e.g. if shared between unit tests), specified as the delegate parameter. |
![]() |
void | SetFlags () |
Sets and validates at compile time, that the specified flags are valid. |
![]() ![]() |
TWeakPtr< FUnitTestProcess > | StartUnitTestClient
(
FString ConnectIP, |
Starts a client process tied to the unit test, and connects to the specified server address |
![]() ![]() |
void | Starts the server process for a particular unit test | |
![]() |
void | Triggers an auto-reconnect (disconnect/reconnect) of the minimal client | |
![]() |
void | ValidateUnitFlags
(
EUnitTestFlags RuntimeUnitFlags, |
Internal base implementation and utility functions for client unit tests Validates, both at compile time (template params) or at runtime (function params), that the specified flags are valid. |
Overridden from UProcessUnitTest
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
void | NotifyProcessFinished
(
TWeakPtr< FUnitTestProcess > InProcess |
Notifies when a running process is detected as having finished/closed NOTE: This will not get called, when ShutdownUnitTestProcess is used, only when a program ends by itself |
![]() ![]() |
void | NotifyProcessLog
(
TWeakPtr< FUnitTestProcess > InProcess, |
Interface for process unit tests For implementation in subclasses, for helping to verify success/fail upon completion of unit tests NOTE: Not called again once VerificationState is set WARNING: Be careful when iterating InLogLines in multiple different for loops, if the sequence of detected logs is important |
![]() ![]() |
void | NotifyProcessSuspendState
(
TWeakPtr< FUnitTestProcess > InProcess, |
Notifies when the suspend state of a process changes |
![]() ![]() |
void | Notifies that there was a request to suspend/resume the unit test | |
![]() ![]() |
void | PrintUnitTestProcessErrors
(
TSharedPtr< FUnitTestProcess > InHandle |
If any errors logs were detected upon ShutdownUnitTestProcess, this is called to print them out |
Overridden from UUnitTest
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
void | CleanupUnitTest
(
EUnitTestResetStage ResetStage |
Cleans up all items needing destruction, and removes the unit test from tracking, before deleting the unit test itself |
![]() ![]() |
bool | Executes the main unit test | |
![]() ![]() |
void | GetCommandContextList
(
TArray< TSharedPtr< FString > >& OutList, |
Outputs the list of console command contexts, that this unit test supports (which can include custom contexts in subclasses) |
![]() ![]() |
ELogType | Returns the type of log entries that this unit expects to output, for setting up log window filters (only needs to return values which affect what tabs are shown) | |
![]() ![]() |
void | LogComplete () |
Triggered upon unit test completion, for outputting that the unit test has completed - plus other unit test state information |
![]() ![]() |
bool | NotifyConsoleCommandRequest
(
FString CommandContext, |
Notifies that there was a request to execute a console command for the unit test, which can occur in a specific context, e.g. for a unit test server, for a local minimal-client (within the unit test), or for a separate unit test client process |
![]() ![]() |
void | ResetTimeout
(
FString ResetReason, |
Resets the unit test timeout code - should be used liberally, within every unit test, when progress is made during execution |
![]() ![]() |
void | UnblockEvents
(
EUnitTaskFlags ReadyEvents |
When events that were pending but blocked by a UnitTask, are unblocked, this function triggers them. |
![]() ![]() |
bool | ValidateUnitTestSettings
(
bool bCDOCheck |
Validate that the unit test settings/flags specified for this unit test, are compatible with one another, and that the engine settings/environment, support running the unit test. |
Overridden from UUnitTestBase
Type | Name | Description | |
---|---|---|---|
![]() ![]() ![]() |
bool | IsTickable () |
Must override in subclasses, that need ticking. |
![]() ![]() |
void | UnitTick
(
float DeltaTime |
Main tick function for the unit test |
Overridden from FUnitLogInterface
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
bool | IsConnectionLogSource
(
UNetConnection* InConnection |
Whether or not this log interface is the source of a UNetConnection - used for deciding where to direct, UNetConnection log hooks |