-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added more comments + cleaned up strucutre of MP tests
- Loading branch information
1 parent
4a6e47b
commit ac87f48
Showing
4 changed files
with
90 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Source/OUUTestUtilities/Private/Multiplayer/OUUMultiplayerTestWaitForAll.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2024 Jonas Reich & Contributors | ||
|
||
#include "Multiplayer/OUUMultiplayerTestWaitForAll.h" | ||
|
||
#include "Multiplayer/OUUMultiplayerFunctionalTest.h" | ||
|
||
UOUUMultiplayerTestWaitForAll* UOUUMultiplayerTestWaitForAll::WaitForAll(AOUUMultiplayerFunctionalTest* InOwningTest) | ||
{ | ||
UOUUMultiplayerTestWaitForAll* Proxy = NewObject<UOUUMultiplayerTestWaitForAll>(); | ||
Proxy->OwningTest = InOwningTest; | ||
return Proxy; | ||
} | ||
|
||
void UOUUMultiplayerTestWaitForAll::Activate() | ||
{ | ||
OwningTest->OnSyncMarkerReached.AddUObject(this, &UOUUMultiplayerTestWaitForAll::HandleSyncMarkerReached); | ||
MarkerIdx = OwningTest->AdvanceLocalSyncMarker(); | ||
} | ||
|
||
void UOUUMultiplayerTestWaitForAll::HandleSyncMarkerReached(int32 Marker) const | ||
{ | ||
ensure(MarkerIdx == Marker); | ||
OwningTest->OnSyncMarkerReached.RemoveAll(this); | ||
OnComplete.Broadcast(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Source/OUUTestUtilities/Public/Multiplayer/OUUMultiplayerTestWaitForAll.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2024 Jonas Reich & Contributors | ||
|
||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
|
||
#include "Kismet/BlueprintAsyncActionBase.h" | ||
|
||
#include "OUUMultiplayerTestWaitForAll.generated.h" | ||
|
||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnOUUMultiplayerWaitForAll); | ||
|
||
// Helper node to wait for on all sides (host & clients) for everyone to reach the same execution point. | ||
// Only usable in the multiplayer functional tests. | ||
// Triggering the node on either side triggers a mechanism wherein all parties agree which "sync marker" they last | ||
// reached. OnComplete is called after server + clients completed this handshake (server initiated). | ||
UCLASS(MinimalAPI) | ||
class UOUUMultiplayerTestWaitForAll : public UBlueprintAsyncActionBase | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
UPROPERTY(BlueprintAssignable) | ||
FOnOUUMultiplayerWaitForAll OnComplete; | ||
|
||
UFUNCTION( | ||
BlueprintCallable, | ||
meta = (BlueprintInternalUseOnly = "true", DefaultToSelf = "InOwningTest"), | ||
Category = "OpenUnrealUtilities|Testing") | ||
static UOUUMultiplayerTestWaitForAll* WaitForAll(AOUUMultiplayerFunctionalTest* InOwningTest); | ||
|
||
// - UBlueprintAsyncActionBase | ||
void Activate() override; | ||
// -- | ||
private: | ||
UPROPERTY() | ||
AOUUMultiplayerFunctionalTest* OwningTest = nullptr; | ||
int32 MarkerIdx = -1; | ||
|
||
void HandleSyncMarkerReached(int32 Marker) const; | ||
}; |