ue-mcp 1.4.13 → 1.4.14-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/bridge/bridge-timeouts.js +4 -0
- package/dist/bridge/bridge-timeouts.js.map +1 -1
- package/dist/cli/cli-commands.js +1 -0
- package/dist/cli/cli-commands.js.map +1 -1
- package/dist/cli/doctor.js +2 -1
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/init.js +1 -1
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/projects-cli.d.ts +3 -0
- package/dist/cli/projects-cli.js +72 -0
- package/dist/cli/projects-cli.js.map +1 -0
- package/dist/config/user-state.d.ts +10 -0
- package/dist/config/user-state.js +21 -0
- package/dist/config/user-state.js.map +1 -1
- package/dist/core/env.d.ts +2 -0
- package/dist/core/env.js +2 -0
- package/dist/core/env.js.map +1 -1
- package/dist/core/types.d.ts +27 -0
- package/dist/daemon/daemon.js +44 -5
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/extension-api.d.ts +8 -5
- package/dist/daemon-api.d.ts +2 -1
- package/dist/daemon-api.js +1 -0
- package/dist/daemon-api.js.map +1 -1
- package/dist/dispatch/offline.js +1 -0
- package/dist/dispatch/offline.js.map +1 -1
- package/dist/editor/dialog-guard.d.ts +12 -2
- package/dist/editor/dialog-guard.js +68 -2
- package/dist/editor/dialog-guard.js.map +1 -1
- package/dist/editor/editor-control.js +1 -1
- package/dist/editor/editor-control.js.map +1 -1
- package/dist/flow/write-methods.js +1 -1
- package/dist/flow/write-methods.js.map +1 -1
- package/dist/machine/projects.d.ts +85 -0
- package/dist/machine/projects.js +286 -0
- package/dist/machine/projects.js.map +1 -0
- package/dist/pie/script-events.d.ts +4 -1
- package/dist/pie/script-events.js.map +1 -1
- package/dist/surface/context/instructions.js +20 -0
- package/dist/surface/context/instructions.js.map +1 -1
- package/dist/tool-counts.json +12 -12
- package/dist/tools/asset.js +2 -1
- package/dist/tools/asset.js.map +1 -1
- package/dist/tools/editor.js +1 -1
- package/dist/tools/editor.js.map +1 -1
- package/dist/tools/epic/effects.js +11 -0
- package/dist/tools/epic/effects.js.map +1 -1
- package/dist/tools/epic/fab.generated.d.ts +6 -0
- package/dist/tools/epic/fab.generated.js +67 -0
- package/dist/tools/epic/fab.generated.js.map +1 -0
- package/dist/tools/epic/index.d.ts +2 -0
- package/dist/tools/epic/index.js +2 -0
- package/dist/tools/epic/index.js.map +1 -1
- package/dist/tools/epic/toolset-routes.js +2 -0
- package/dist/tools/epic/toolset-routes.js.map +1 -1
- package/dist/tools/epic.js +4 -4
- package/dist/tools/epic.js.map +1 -1
- package/dist/tools/fab-epic.d.ts +23 -0
- package/dist/tools/fab-epic.js +109 -0
- package/dist/tools/fab-epic.js.map +1 -0
- package/dist/tools/fab.js +27 -18
- package/dist/tools/fab.js.map +1 -1
- package/dist/tools/level.js +9 -2
- package/dist/tools/level.js.map +1 -1
- package/dist/tools/material.js +1 -1
- package/dist/tools/material.js.map +1 -1
- package/dist/tools/pie.js +1 -1
- package/dist/tools/pie.js.map +1 -1
- package/dist/tools/specs/asset.generated.js +92 -3
- package/dist/tools/specs/asset.generated.js.map +1 -1
- package/dist/tools/specs/fab.generated.js +143 -3
- package/dist/tools/specs/fab.generated.js.map +1 -1
- package/dist/tools/specs/level.generated.js +183 -9
- package/dist/tools/specs/level.generated.js.map +1 -1
- package/dist/tools/specs/pie.generated.js +28 -8
- package/dist/tools/specs/pie.generated.js.map +1 -1
- package/dist/tools/specs/widget.generated.js +8 -1
- package/dist/tools/specs/widget.generated.js.map +1 -1
- package/dist/ue-mcp.default.yml +522 -76
- package/package.json +2 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgeServer.cpp +26 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.cpp +24 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.h +7 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers_Mesh.cpp +483 -10
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Dialog/DialogHandlers.cpp +345 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_AIAssistant.cpp +34 -6
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabDownloads.cpp +766 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabDownloads.h +26 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabHandlers.cpp +159 -55
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabHandlers.h +23 -12
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabLibrary.cpp +306 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabLibrary.h +55 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.cpp +34 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.h +9 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Blockout.cpp +12 -8
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_PerfAudit.cpp +3 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Refresh.cpp +479 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_ReplaceActors.cpp +2 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_WorldPartition.cpp +824 -12
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Material/MaterialHandlers.cpp +95 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers.cpp +13 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/MCPPIETestScript.h +8 -3
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers.cpp +2 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Record.cpp +6 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Replay.cpp +1 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Script.cpp +2 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputRecorder.cpp +52 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputRecorder.h +16 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputReplayer.cpp +65 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputReplayer.h +15 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEReplayInputLock.cpp +146 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEReplayInputLock.h +53 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptRunner.cpp +351 -14
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptRunner.h +55 -6
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptValidation.cpp +8 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIESequenceFormat.cpp +59 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIESequenceFormat.h +15 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEUIPointer.cpp +567 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEUIPointer.h +173 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/SMCPPIEStudioPanel.cpp +41 -6
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers.cpp +92 -32
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabDownloadTests.cpp +140 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabEndToEndTests.cpp +365 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabLibraryTests.cpp +52 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PCGGraphAuthoringTests.cpp +5 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEReplayInputLockTests.cpp +77 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEScriptTests.cpp +256 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEScriptValidationTests.cpp +18 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEUIPointerTests.cpp +246 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/UE_MCP_Bridge.cpp +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/UE_MCP_Bridge.Build.cs +85 -13
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Private/MCPPIEActionTrigger.cpp +48 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Private/MCPPIERemoteControl.cpp +93 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Public/MCPPIEActionTrigger.h +52 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Public/MCPPIERemoteControl.h +54 -0
- package/plugin/ue_mcp_bridge/UE_MCP_Bridge.uplugin +2 -2
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#include "Handlers/PIE/PIEScriptRunner.h"
|
|
9
9
|
#include "Handlers/PIE/PIEObserver.h"
|
|
10
|
+
#include "MCPPIEActionTrigger.h"
|
|
10
11
|
#include "Dom/JsonObject.h"
|
|
11
12
|
#include "Serialization/JsonReader.h"
|
|
12
13
|
#include "Serialization/JsonSerializer.h"
|
|
@@ -850,4 +851,259 @@ bool FPIEScriptPawnChannelTest::RunTest(const FString& /*Parameters*/)
|
|
|
850
851
|
return true;
|
|
851
852
|
}
|
|
852
853
|
|
|
854
|
+
namespace MCPPIEScriptTests
|
|
855
|
+
{
|
|
856
|
+
// Stands in for the editor's trigger source: each step reads whatever the test set for it.
|
|
857
|
+
class FFakeTriggerSource : public IScriptTriggerSource
|
|
858
|
+
{
|
|
859
|
+
public:
|
|
860
|
+
struct FEntry
|
|
861
|
+
{
|
|
862
|
+
EScriptTriggerRead Read = EScriptTriggerRead::Watching;
|
|
863
|
+
FScriptTrigger Trigger;
|
|
864
|
+
FString Why;
|
|
865
|
+
};
|
|
866
|
+
TMap<int32, FEntry> Entries;
|
|
867
|
+
TMap<int32, int32> Asked;
|
|
868
|
+
TMap<int32, double> FromMs;
|
|
869
|
+
TArray<int32> Ended;
|
|
870
|
+
|
|
871
|
+
virtual EScriptTriggerRead ReadTrigger(int32 Index, const FScriptExpect& Expect, double InFromMs,
|
|
872
|
+
FScriptTrigger& OutTrigger, FString& OutWhy) override
|
|
873
|
+
{
|
|
874
|
+
Asked.FindOrAdd(Index)++;
|
|
875
|
+
FromMs.Add(Index, InFromMs);
|
|
876
|
+
const FEntry* E = Entries.Find(Index);
|
|
877
|
+
if (!E) return EScriptTriggerRead::Watching;
|
|
878
|
+
OutTrigger = E->Trigger;
|
|
879
|
+
OutWhy = E->Why;
|
|
880
|
+
return E->Read;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
virtual void EndWatch(int32 Index) override { Ended.Add(Index); }
|
|
884
|
+
|
|
885
|
+
void Fire(int32 Index, double AtMs, const FVector& Value, const FString& Type)
|
|
886
|
+
{
|
|
887
|
+
FEntry& E = Entries.FindOrAdd(Index);
|
|
888
|
+
E.Read = EScriptTriggerRead::Triggered;
|
|
889
|
+
E.Trigger.AtMs = AtMs;
|
|
890
|
+
E.Trigger.Value = Value;
|
|
891
|
+
E.Trigger.ValueType = Type;
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
FScriptStepDef TriggeredStep(int32 WithinMs = 0, int32 Client = 0)
|
|
896
|
+
{
|
|
897
|
+
FScriptExpect E = MakeExpect(EScriptExpectOp::Triggered, TEXT("/Game/Input/IA_Interact.IA_Interact"), false, 0.0, WithinMs);
|
|
898
|
+
E.Client = Client;
|
|
899
|
+
FScriptStepDef S = AutoStep(E);
|
|
900
|
+
S.Instruction = TEXT("Press Interact");
|
|
901
|
+
return S;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
|
|
906
|
+
FPIEScriptTriggeredParseTest,
|
|
907
|
+
"UE.MCP.PIE.Script.Triggered.Parse",
|
|
908
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
909
|
+
|
|
910
|
+
bool FPIEScriptTriggeredParseTest::RunTest(const FString& /*Parameters*/)
|
|
911
|
+
{
|
|
912
|
+
using namespace MCPPIEScriptTests;
|
|
913
|
+
|
|
914
|
+
FScriptStepDef Def;
|
|
915
|
+
FString Err, Field;
|
|
916
|
+
TestTrue(TEXT("triggered step parses"), ParseScriptStepJson(ParseJsonValue(TEXT(
|
|
917
|
+
"{\"instruction\":\"Press Interact\",\"expect\":{\"op\":\"triggered\",\"value\":\"/Game/Input/IA_Interact\",\"client\":1,\"within_ms\":600000}}")), 0, Def, Err, &Field));
|
|
918
|
+
TestTrue(TEXT("op is triggered"), Def.Expect.Op == EScriptExpectOp::Triggered && IsScriptTriggerOp(Def.Expect.Op));
|
|
919
|
+
TestEqual(TEXT("a package path becomes the object path"), Def.Expect.Value, FString(TEXT("/Game/Input/IA_Interact.IA_Interact")));
|
|
920
|
+
TestEqual(TEXT("client read"), Def.Expect.Client, 1);
|
|
921
|
+
TestEqual(TEXT("a long window is kept"), Def.Expect.WithinMs, 600000);
|
|
922
|
+
TestEqual(TEXT("an object path is kept"), NormalizeScriptInputActionPath(TEXT("/Game/Input/IA_Jump.IA_Jump")), FString(TEXT("/Game/Input/IA_Jump.IA_Jump")));
|
|
923
|
+
|
|
924
|
+
const TSharedRef<FJsonObject> Back = ScriptStepDefToJson(Def);
|
|
925
|
+
const TSharedPtr<FJsonObject> BackExpect = Back->GetObjectField(TEXT("expect"));
|
|
926
|
+
TestEqual(TEXT("client written"), static_cast<int32>(BackExpect->GetNumberField(TEXT("client"))), 1);
|
|
927
|
+
FScriptStepDef Again;
|
|
928
|
+
TestTrue(TEXT("written step parses again"), ParseScriptStepJson(MakeShared<FJsonValueObject>(Back), 0, Again, Err));
|
|
929
|
+
TestTrue(TEXT("round trip keeps op and client"), Again.Expect.Op == EScriptExpectOp::Triggered && Again.Expect.Client == 1);
|
|
930
|
+
|
|
931
|
+
TestFalse(TEXT("client on another op refused"), ParseScriptStepJson(ParseJsonValue(TEXT(
|
|
932
|
+
"{\"instruction\":\"x\",\"expect\":{\"op\":\"gt\",\"value\":\"H\",\"target\":1,\"client\":1}}")), 0, Def, Err, &Field));
|
|
933
|
+
TestEqual(TEXT("names expect.client"), Field, FString(TEXT("expect.client")));
|
|
934
|
+
TestFalse(TEXT("negative client refused"), ParseScriptStepJson(ParseJsonValue(TEXT(
|
|
935
|
+
"{\"instruction\":\"x\",\"expect\":{\"op\":\"triggered\",\"value\":\"/Game/Input/IA_Interact\",\"client\":-1}}")), 0, Def, Err, &Field));
|
|
936
|
+
TestFalse(TEXT("a target on triggered refused"), ParseScriptStepJson(ParseJsonValue(TEXT(
|
|
937
|
+
"{\"instruction\":\"x\",\"expect\":{\"op\":\"triggered\",\"value\":\"/Game/Input/IA_Interact\",\"target\":true}}")), 0, Def, Err, &Field));
|
|
938
|
+
TestEqual(TEXT("names expect.target"), Field, FString(TEXT("expect.target")));
|
|
939
|
+
TestFalse(TEXT("triggered needs a value"), ParseScriptStepJson(ParseJsonValue(TEXT(
|
|
940
|
+
"{\"instruction\":\"x\",\"expect\":{\"op\":\"triggered\"}}")), 0, Def, Err, &Field));
|
|
941
|
+
TestTrue(TEXT("the error asks for an Input Action"), Err.Contains(TEXT("Input Action")));
|
|
942
|
+
|
|
943
|
+
// Without within_ms a triggered step has no timeout; every other op takes the run's default.
|
|
944
|
+
FScriptRun Run;
|
|
945
|
+
Run.DefaultWithinMs = 5000;
|
|
946
|
+
InitScriptRun(Run, { TriggeredStep(), AutoStep(MakeExpect(EScriptExpectOp::Gt, TEXT("H"), true, 1.0)) });
|
|
947
|
+
TestEqual(TEXT("triggered without within_ms waits with no timeout"), Run.Steps[0].WithinMs, 0);
|
|
948
|
+
TestEqual(TEXT("gt takes the default"), Run.Steps[1].WithinMs, 5000);
|
|
949
|
+
|
|
950
|
+
// The observer is not asked to track the action path as a value.
|
|
951
|
+
TArray<FString> Values, Actors, Widgets;
|
|
952
|
+
CollectScriptObservedNames({ TriggeredStep() }, {}, Values, Actors, Widgets);
|
|
953
|
+
TestEqual(TEXT("nothing observed for triggered"), Values.Num() + Actors.Num() + Widgets.Num(), 0);
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
|
|
958
|
+
FPIEScriptTriggeredRunTest,
|
|
959
|
+
"UE.MCP.PIE.Script.Triggered.Run",
|
|
960
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
961
|
+
|
|
962
|
+
bool FPIEScriptTriggeredRunTest::RunTest(const FString& /*Parameters*/)
|
|
963
|
+
{
|
|
964
|
+
using namespace MCPPIEScriptTests;
|
|
965
|
+
auto Reader = [](const FScriptExpect&, double&) { return false; };
|
|
966
|
+
|
|
967
|
+
// Passes on a trigger inside the window, with the trigger time and value as evidence. The window opens when act ends.
|
|
968
|
+
{
|
|
969
|
+
FScriptRun Run;
|
|
970
|
+
Run.RunId = TEXT("script_triggered");
|
|
971
|
+
InitScriptRun(Run, { WithAct(TriggeredStep(2000)), ManualStep(TEXT("Then?")) });
|
|
972
|
+
Run.State = EScriptRunState::Running;
|
|
973
|
+
FFakeStepDriver Driver;
|
|
974
|
+
Driver.TicksToRun = 1;
|
|
975
|
+
FFakeTriggerSource Triggers;
|
|
976
|
+
AdvanceScriptRun(Run, 0.0, 0, Reader, &Driver, &Triggers);
|
|
977
|
+
TestEqual(TEXT("not watched while act runs"), Triggers.Asked.FindRef(0), 0);
|
|
978
|
+
AdvanceScriptRun(Run, 100.0, 1, Reader, &Driver, &Triggers);
|
|
979
|
+
TestTrue(TEXT("act done"), Run.Steps[0].Act.State == EScriptActState::Done);
|
|
980
|
+
TestEqual(TEXT("watched from the end of act"), Triggers.FromMs.FindRef(0), 100.0);
|
|
981
|
+
TestTrue(TEXT("waits for the person"), Run.Steps[0].Status == EScriptStepStatus::Running);
|
|
982
|
+
TestTrue(TEXT("the run holds on the step"), Run.Steps[1].Status == EScriptStepStatus::Pending);
|
|
983
|
+
|
|
984
|
+
// A trigger stamped before the window (the act's own input) does not count.
|
|
985
|
+
Triggers.Fire(0, 90.0, FVector(1, 0, 0), TEXT("bool"));
|
|
986
|
+
AdvanceScriptRun(Run, 200.0, 2, Reader, &Driver, &Triggers);
|
|
987
|
+
TestTrue(TEXT("a trigger before the window is ignored"), Run.Steps[0].Status == EScriptStepStatus::Running);
|
|
988
|
+
|
|
989
|
+
Triggers.Fire(0, 1450.0, FVector(1, 0, 0), TEXT("bool"));
|
|
990
|
+
AdvanceScriptRun(Run, 1466.0, 3, Reader, &Driver, &Triggers);
|
|
991
|
+
TestTrue(TEXT("passes on the trigger"), Run.Steps[0].Status == EScriptStepStatus::Passed);
|
|
992
|
+
TestTrue(TEXT("evidence: triggered"), Run.Steps[0].Evidence.bTriggered);
|
|
993
|
+
TestEqual(TEXT("evidence: trigger time in run ms"), Run.Steps[0].Evidence.TriggeredAtMs, 1450.0);
|
|
994
|
+
TestTrue(TEXT("evidence: watched"), Run.Steps[0].Evidence.bObserved);
|
|
995
|
+
TestEqual(TEXT("the watch ended"), Triggers.Ended.Num(), 1);
|
|
996
|
+
TestTrue(TEXT("the run moves on"), Run.Steps[1].Status == EScriptStepStatus::AwaitingVerdict);
|
|
997
|
+
|
|
998
|
+
const TSharedRef<FJsonObject> StepJson = ScriptStepRunToJson(Run.Steps[0], 0);
|
|
999
|
+
const TSharedPtr<FJsonObject> Evidence = StepJson->GetObjectField(TEXT("evidence"));
|
|
1000
|
+
TestEqual(TEXT("json: triggered_at_ms"), Evidence->GetNumberField(TEXT("triggered_at_ms")), 1450.0);
|
|
1001
|
+
TestTrue(TEXT("json: a bool action value is a boolean"), Evidence->GetBoolField(TEXT("action_value")));
|
|
1002
|
+
TestEqual(TEXT("json: value_type"), Evidence->GetStringField(TEXT("value_type")), FString(TEXT("bool")));
|
|
1003
|
+
|
|
1004
|
+
FScriptRun Back;
|
|
1005
|
+
FString Err;
|
|
1006
|
+
TestTrue(TEXT("results.json reads back"), ScriptRunFromResultsJson(ScriptRunToResultsJson(Run), Back, Err));
|
|
1007
|
+
TestTrue(TEXT("trigger read back"), Back.Steps[0].Evidence.bTriggered && Back.Steps[0].Evidence.TriggeredAtMs == 1450.0);
|
|
1008
|
+
TestTrue(TEXT("op read back"), Back.Steps[0].Def.Expect.Op == EScriptExpectOp::Triggered);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// Fails at its timeout when nothing triggers; a 2D value reads back as [x, y].
|
|
1012
|
+
{
|
|
1013
|
+
FScriptRun Run;
|
|
1014
|
+
InitScriptRun(Run, { TriggeredStep(500), TriggeredStep(0) });
|
|
1015
|
+
Run.State = EScriptRunState::Running;
|
|
1016
|
+
FFakeTriggerSource Triggers;
|
|
1017
|
+
AdvanceScriptRun(Run, 0.0, 0, Reader, nullptr, &Triggers);
|
|
1018
|
+
AdvanceScriptRun(Run, 499.0, 1, Reader, nullptr, &Triggers);
|
|
1019
|
+
TestTrue(TEXT("still waiting just before the timeout"), Run.Steps[0].Status == EScriptStepStatus::Running);
|
|
1020
|
+
AdvanceScriptRun(Run, 500.0, 2, Reader, nullptr, &Triggers);
|
|
1021
|
+
TestTrue(TEXT("fails at the timeout"), Run.Steps[0].Status == EScriptStepStatus::Failed);
|
|
1022
|
+
TestTrue(TEXT("the reason says it was not triggered"), Run.Steps[0].Evidence.Reason.Contains(TEXT("was not triggered")));
|
|
1023
|
+
TestFalse(TEXT("no trigger recorded"), Run.Steps[0].Evidence.bTriggered);
|
|
1024
|
+
|
|
1025
|
+
// within_ms 0: no timeout, however long the person takes.
|
|
1026
|
+
AdvanceScriptRun(Run, 3600000.0, 3, Reader, nullptr, &Triggers);
|
|
1027
|
+
TestTrue(TEXT("an hour later it still waits"), Run.Steps[1].Status == EScriptStepStatus::Running);
|
|
1028
|
+
Triggers.Fire(1, 3600010.0, FVector(0.5, -1, 0), TEXT("axis2d"));
|
|
1029
|
+
AdvanceScriptRun(Run, 3600016.0, 4, Reader, nullptr, &Triggers);
|
|
1030
|
+
TestTrue(TEXT("passes when it finally fires"), Run.Steps[1].Status == EScriptStepStatus::Passed);
|
|
1031
|
+
const TSharedPtr<FJsonObject> Evidence = ScriptStepRunToJson(Run.Steps[1], 1)->GetObjectField(TEXT("evidence"));
|
|
1032
|
+
const TArray<TSharedPtr<FJsonValue>> Value = Evidence->GetArrayField(TEXT("action_value"));
|
|
1033
|
+
TestTrue(TEXT("a 2D value is [x, y]"), Value.Num() == 2 && Value[0]->AsNumber() == 0.5 && Value[1]->AsNumber() == -1.0);
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
// No timeout and never triggered: script_stop fails it, saying so.
|
|
1037
|
+
{
|
|
1038
|
+
FScriptRun Run;
|
|
1039
|
+
InitScriptRun(Run, { TriggeredStep() });
|
|
1040
|
+
Run.State = EScriptRunState::Running;
|
|
1041
|
+
FFakeTriggerSource Triggers;
|
|
1042
|
+
AdvanceScriptRun(Run, 0.0, 0, Reader, nullptr, &Triggers);
|
|
1043
|
+
SettleUnfinishedScriptSteps(Run, TEXT("stopped"));
|
|
1044
|
+
TestTrue(TEXT("stop fails the waiting step"), Run.Steps[0].Status == EScriptStepStatus::Failed);
|
|
1045
|
+
TestTrue(TEXT("with the reason"), Run.Steps[0].Evidence.Reason.Contains(TEXT("was not triggered")));
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// A player that cannot be watched fails at the timeout with why.
|
|
1049
|
+
{
|
|
1050
|
+
FScriptRun Run;
|
|
1051
|
+
InitScriptRun(Run, { TriggeredStep(100, 2) });
|
|
1052
|
+
Run.State = EScriptRunState::Running;
|
|
1053
|
+
FFakeTriggerSource Triggers;
|
|
1054
|
+
FFakeTriggerSource::FEntry& E = Triggers.Entries.Add(0);
|
|
1055
|
+
E.Read = EScriptTriggerRead::Unwatched;
|
|
1056
|
+
E.Why = TEXT("no remote player 2");
|
|
1057
|
+
AdvanceScriptRun(Run, 0.0, 0, Reader, nullptr, &Triggers);
|
|
1058
|
+
AdvanceScriptRun(Run, 100.0, 1, Reader, nullptr, &Triggers);
|
|
1059
|
+
TestTrue(TEXT("unwatchable fails at the timeout"), Run.Steps[0].Status == EScriptStepStatus::Failed);
|
|
1060
|
+
TestFalse(TEXT("not observed"), Run.Steps[0].Evidence.bObserved);
|
|
1061
|
+
TestTrue(TEXT("the reason carries why"), Run.Steps[0].Evidence.Reason.Contains(TEXT("no remote player 2")));
|
|
1062
|
+
|
|
1063
|
+
// Without any trigger source the step is never watched.
|
|
1064
|
+
FScriptRun Bare;
|
|
1065
|
+
InitScriptRun(Bare, { TriggeredStep(100) });
|
|
1066
|
+
Bare.State = EScriptRunState::Running;
|
|
1067
|
+
AdvanceScriptRun(Bare, 0.0, 0, Reader);
|
|
1068
|
+
AdvanceScriptRun(Bare, 100.0, 1, Reader);
|
|
1069
|
+
TestTrue(TEXT("no source fails at the timeout"), Bare.Steps[0].Status == EScriptStepStatus::Failed);
|
|
1070
|
+
TestTrue(TEXT("saying nothing watches input"), Bare.Steps[0].Evidence.Reason.Contains(TEXT("nothing watches input")));
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
// A trigger later than within_ms after the window opened does not pass the step.
|
|
1074
|
+
{
|
|
1075
|
+
FScriptRun Run;
|
|
1076
|
+
InitScriptRun(Run, { TriggeredStep(300) });
|
|
1077
|
+
Run.State = EScriptRunState::Running;
|
|
1078
|
+
FFakeTriggerSource Triggers;
|
|
1079
|
+
AdvanceScriptRun(Run, 0.0, 0, Reader, nullptr, &Triggers);
|
|
1080
|
+
Triggers.Fire(0, 350.0, FVector(1, 0, 0), TEXT("bool"));
|
|
1081
|
+
AdvanceScriptRun(Run, 360.0, 1, Reader, nullptr, &Triggers);
|
|
1082
|
+
TestTrue(TEXT("a late trigger fails"), Run.Steps[0].Status == EScriptStepStatus::Failed);
|
|
1083
|
+
}
|
|
1084
|
+
return true;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
|
|
1088
|
+
FPIEScriptTriggerGateTest,
|
|
1089
|
+
"UE.MCP.PIE.Script.Triggered.Gate",
|
|
1090
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
1091
|
+
|
|
1092
|
+
bool FPIEScriptTriggerGateTest::RunTest(const FString& /*Parameters*/)
|
|
1093
|
+
{
|
|
1094
|
+
// Input still down when the watch begins (act's last frame, a held key) needs a release before it counts.
|
|
1095
|
+
MCPPIE::FActionTriggerGate Held;
|
|
1096
|
+
TestFalse(TEXT("held at the start does not fire"), Held.Feed(true));
|
|
1097
|
+
TestFalse(TEXT("still held"), Held.Feed(true));
|
|
1098
|
+
TestFalse(TEXT("released"), Held.Feed(false));
|
|
1099
|
+
TestTrue(TEXT("a fresh press fires"), Held.Feed(true));
|
|
1100
|
+
TestFalse(TEXT("fires once"), Held.Feed(true));
|
|
1101
|
+
TestFalse(TEXT("and stays fired"), Held.Feed(false) || Held.Feed(true));
|
|
1102
|
+
|
|
1103
|
+
MCPPIE::FActionTriggerGate Idle;
|
|
1104
|
+
TestFalse(TEXT("idle"), Idle.Feed(false));
|
|
1105
|
+
TestTrue(TEXT("one frame tap fires"), Idle.Feed(true));
|
|
1106
|
+
return true;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
853
1109
|
#endif
|
package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEScriptValidationTests.cpp
CHANGED
|
@@ -220,6 +220,24 @@ bool FPIEScriptDraftTypingTest::RunTest(const FString& /*Parameters*/)
|
|
|
220
220
|
Bare.Instruction = TEXT("walk somewhere");
|
|
221
221
|
TestTrue(TEXT("an auto step without expect checks nothing"), HasIssue(Check({ Bare, Manual() }), INDEX_NONE, TEXT("steps")));
|
|
222
222
|
|
|
223
|
+
// triggered names an Input Action, checked as act's are, and resolve_in_pie does not skip it.
|
|
224
|
+
FScriptValidationContext WithInput = MakeContext();
|
|
225
|
+
WithInput.ResolveInputAction = [](const FString& Path) -> FScriptLookup
|
|
226
|
+
{
|
|
227
|
+
return Path == TEXT("/Game/Input/IA_Interact.IA_Interact")
|
|
228
|
+
? Found(EScriptValueKind::Boolean, TEXT("InputAction"))
|
|
229
|
+
: Missing(TEXT("no Input Action loads from that path"), { TEXT("/Game/Input/IA_Interact.IA_Interact") });
|
|
230
|
+
};
|
|
231
|
+
TestEqual(TEXT("a triggered step naming a real action passes"),
|
|
232
|
+
Check({ Auto(EScriptExpectOp::Triggered, TEXT("/Game/Input/IA_Interact.IA_Interact")) }, false, &WithInput).Num(), 0);
|
|
233
|
+
FScriptStepDef Typo = Auto(EScriptExpectOp::Triggered, TEXT("/Game/Input/IA_Interactt.IA_Interactt"));
|
|
234
|
+
Typo.bResolveInPIE = true;
|
|
235
|
+
Issues = Check({ Typo }, false, &WithInput);
|
|
236
|
+
TestTrue(TEXT("an unknown action is reported on expect.value"), HasIssue(Issues, 0, TEXT("expect.value")));
|
|
237
|
+
TestTrue(TEXT("with the closest actions"), Issues.Num() > 0 && Issues[0].Candidates.Contains(TEXT("/Game/Input/IA_Interact.IA_Interact")));
|
|
238
|
+
TestFalse(TEXT("as a warning, not a refusal"), Issues.Num() > 0 && Issues[0].bBlocksSave);
|
|
239
|
+
TestFalse(TEXT("a triggered step counts as an auto check"), HasIssue(Issues, INDEX_NONE, TEXT("steps")));
|
|
240
|
+
|
|
223
241
|
// Steps that failed to parse are skipped, and the auto-step rule waits for them.
|
|
224
242
|
TArray<FScriptStepIssue> Skipped;
|
|
225
243
|
ValidateScriptSteps({ Auto(EScriptExpectOp::Gt, TEXT("Nope"), true, 1.0), Manual() }, false, MakeContext(), Skipped, { 0 });
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// Cursor and UI pointer recording (#1822): viewport-relative positions, move
|
|
2
|
+
// coalescing, step building, and the ui_input step round-tripping through
|
|
3
|
+
// sequence.json.
|
|
4
|
+
|
|
5
|
+
#include "Misc/AutomationTest.h"
|
|
6
|
+
|
|
7
|
+
#if WITH_DEV_AUTOMATION_TESTS
|
|
8
|
+
|
|
9
|
+
#include "Handlers/PIE/PIESequenceFormat.h"
|
|
10
|
+
#include "Handlers/PIE/PIEUIPointer.h"
|
|
11
|
+
#include "Dom/JsonObject.h"
|
|
12
|
+
|
|
13
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
|
|
14
|
+
FPIEUIPointerViewportRelativeTest,
|
|
15
|
+
"UE.MCP.PIE.UIPointer.ViewportRelative",
|
|
16
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
17
|
+
|
|
18
|
+
bool FPIEUIPointerViewportRelativeTest::RunTest(const FString& /*Parameters*/)
|
|
19
|
+
{
|
|
20
|
+
using namespace MCPPIE;
|
|
21
|
+
const FVector2D Origin(100.0, 50.0);
|
|
22
|
+
const FVector2D Size(800.0, 600.0);
|
|
23
|
+
|
|
24
|
+
FVector2D Rel;
|
|
25
|
+
TestTrue(TEXT("centre is inside"), ScreenToViewportRelative(FVector2D(500.0, 350.0), Origin, Size, Rel));
|
|
26
|
+
TestEqual(TEXT("centre x"), Rel.X, 0.5);
|
|
27
|
+
TestEqual(TEXT("centre y"), Rel.Y, 0.5);
|
|
28
|
+
|
|
29
|
+
TestTrue(TEXT("top-left corner is inside"), ScreenToViewportRelative(Origin, Origin, Size, Rel));
|
|
30
|
+
TestTrue(TEXT("corner is 0,0"), Rel.X == 0.0 && Rel.Y == 0.0);
|
|
31
|
+
|
|
32
|
+
TestFalse(TEXT("left of the viewport is outside"), ScreenToViewportRelative(FVector2D(99.0, 350.0), Origin, Size, Rel));
|
|
33
|
+
TestTrue(TEXT("outside still reports a position"), Rel.X < 0.0);
|
|
34
|
+
|
|
35
|
+
TestFalse(TEXT("zero-sized viewport"), ScreenToViewportRelative(FVector2D(1.0, 1.0), Origin, FVector2D::ZeroVector, Rel));
|
|
36
|
+
|
|
37
|
+
// A recording made at one size replays at the same relative spot in another.
|
|
38
|
+
const FVector2D OtherOrigin(0.0, 0.0);
|
|
39
|
+
const FVector2D OtherSize(1920.0, 1080.0);
|
|
40
|
+
ScreenToViewportRelative(FVector2D(300.0, 200.0), Origin, Size, Rel);
|
|
41
|
+
const FVector2D Back = ViewportRelativeToScreen(Rel, OtherOrigin, OtherSize);
|
|
42
|
+
TestEqual(TEXT("x scales with the viewport"), Back.X, 0.25 * 1920.0);
|
|
43
|
+
TestEqual(TEXT("y scales with the viewport"), Back.Y, 0.25 * 1080.0);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
|
|
48
|
+
FPIEUIPointerCoalesceTest,
|
|
49
|
+
"UE.MCP.PIE.UIPointer.MovesCoalescePerFrame",
|
|
50
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
51
|
+
|
|
52
|
+
bool FPIEUIPointerCoalesceTest::RunTest(const FString& /*Parameters*/)
|
|
53
|
+
{
|
|
54
|
+
using namespace MCPPIE;
|
|
55
|
+
TArray<FUIPointerSample> Samples;
|
|
56
|
+
auto Sample = [](EUIPointerEvent E, uint64 Frame, double X)
|
|
57
|
+
{
|
|
58
|
+
FUIPointerSample S;
|
|
59
|
+
S.Event = E;
|
|
60
|
+
S.FrameNumber = Frame;
|
|
61
|
+
S.Position = FVector2D(X, 0.5);
|
|
62
|
+
return S;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
AppendUIPointerSample(Samples, Sample(EUIPointerEvent::Move, 10, 0.1));
|
|
66
|
+
AppendUIPointerSample(Samples, Sample(EUIPointerEvent::Move, 10, 0.2));
|
|
67
|
+
AppendUIPointerSample(Samples, Sample(EUIPointerEvent::Move, 10, 0.3));
|
|
68
|
+
TestEqual(TEXT("three moves in one frame are one sample"), Samples.Num(), 1);
|
|
69
|
+
TestEqual(TEXT("the latest position wins"), Samples[0].Position.X, 0.3);
|
|
70
|
+
|
|
71
|
+
AppendUIPointerSample(Samples, Sample(EUIPointerEvent::Move, 11, 0.4));
|
|
72
|
+
TestEqual(TEXT("a move in the next frame is kept"), Samples.Num(), 2);
|
|
73
|
+
|
|
74
|
+
AppendUIPointerSample(Samples, Sample(EUIPointerEvent::Down, 11, 0.4));
|
|
75
|
+
AppendUIPointerSample(Samples, Sample(EUIPointerEvent::Move, 11, 0.5));
|
|
76
|
+
TestEqual(TEXT("a move after a press is not folded into the move before it"), Samples.Num(), 4);
|
|
77
|
+
TestTrue(TEXT("press keeps its place"), Samples[2].Event == EUIPointerEvent::Down);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
|
|
82
|
+
FPIEUIPointerBuildStepsTest,
|
|
83
|
+
"UE.MCP.PIE.UIPointer.BuildSteps",
|
|
84
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
85
|
+
|
|
86
|
+
bool FPIEUIPointerBuildStepsTest::RunTest(const FString& /*Parameters*/)
|
|
87
|
+
{
|
|
88
|
+
using namespace MCPPIE;
|
|
89
|
+
TArray<FUIPointerSample> Samples;
|
|
90
|
+
auto Add = [&Samples](EUIPointerEvent E, double T, const TCHAR* Button = TEXT(""), float Wheel = 0.f)
|
|
91
|
+
{
|
|
92
|
+
FUIPointerSample S;
|
|
93
|
+
S.Event = E;
|
|
94
|
+
S.RealTime = T;
|
|
95
|
+
S.FrameNumber = static_cast<uint64>(T * 1000.0);
|
|
96
|
+
S.Position = FVector2D(0.25, 0.75);
|
|
97
|
+
S.Button = Button;
|
|
98
|
+
S.WheelDelta = Wheel;
|
|
99
|
+
S.Modifiers = UIModifier::Shift;
|
|
100
|
+
Samples.Add(S);
|
|
101
|
+
};
|
|
102
|
+
Add(EUIPointerEvent::Move, 9.0); // before the first row: dropped
|
|
103
|
+
Add(EUIPointerEvent::Move, 10.25);
|
|
104
|
+
Add(EUIPointerEvent::Down, 10.5, TEXT("LeftMouseButton"));
|
|
105
|
+
Add(EUIPointerEvent::Up, 10.6, TEXT("LeftMouseButton"));
|
|
106
|
+
Add(EUIPointerEvent::Wheel, 11.0, TEXT(""), -1.f);
|
|
107
|
+
|
|
108
|
+
TArray<FStep> Steps;
|
|
109
|
+
BuildUIPointerSteps(Samples, 10.0, Steps);
|
|
110
|
+
if (!TestEqual(TEXT("sample before the base is dropped"), Steps.Num(), 4)) return false;
|
|
111
|
+
|
|
112
|
+
TestTrue(TEXT("type"), Steps[0].Type == EStepType::UIInput);
|
|
113
|
+
TestEqual(TEXT("move delay"), Steps[0].DelayMs, 250);
|
|
114
|
+
TestEqual(TEXT("move event"), Steps[0].UIEvent, FString(TEXT("mouse_move")));
|
|
115
|
+
TestTrue(TEXT("move carries no button"), Steps[0].UIKey.IsEmpty());
|
|
116
|
+
TestEqual(TEXT("x"), Steps[0].PointerX, 0.25);
|
|
117
|
+
TestEqual(TEXT("y"), Steps[0].PointerY, 0.75);
|
|
118
|
+
TestTrue(TEXT("modifiers"), Steps[0].UIModifiers == UIModifier::Shift);
|
|
119
|
+
|
|
120
|
+
TestEqual(TEXT("press delay"), Steps[1].DelayMs, 500);
|
|
121
|
+
TestEqual(TEXT("press button"), Steps[1].UIKey, FString(TEXT("LeftMouseButton")));
|
|
122
|
+
TestEqual(TEXT("release event"), Steps[2].UIEvent, FString(TEXT("mouse_up")));
|
|
123
|
+
TestEqual(TEXT("wheel delta"), Steps[3].WheelDelta, -1.0);
|
|
124
|
+
TestTrue(TEXT("wheel carries no button"), Steps[3].UIKey.IsEmpty());
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
|
|
129
|
+
FPIEUIPointerSequenceRoundTripTest,
|
|
130
|
+
"UE.MCP.PIE.UIPointer.SequenceRoundTrip",
|
|
131
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
132
|
+
|
|
133
|
+
bool FPIEUIPointerSequenceRoundTripTest::RunTest(const FString& /*Parameters*/)
|
|
134
|
+
{
|
|
135
|
+
using namespace MCPPIE;
|
|
136
|
+
FSequence In;
|
|
137
|
+
In.SampleHz = 60;
|
|
138
|
+
FStep Down;
|
|
139
|
+
Down.Type = EStepType::UIInput;
|
|
140
|
+
Down.DelayMs = 1200;
|
|
141
|
+
Down.UIEvent = TEXT("mouse_down");
|
|
142
|
+
Down.PointerX = 0.4213;
|
|
143
|
+
Down.PointerY = 0.6012;
|
|
144
|
+
Down.UIKey = TEXT("LeftMouseButton");
|
|
145
|
+
Down.UIModifiers = UIModifier::Shift | UIModifier::Control;
|
|
146
|
+
In.Steps.Add(Down);
|
|
147
|
+
FStep Wheel;
|
|
148
|
+
Wheel.Type = EStepType::UIInput;
|
|
149
|
+
Wheel.DelayMs = 1300;
|
|
150
|
+
Wheel.UIEvent = TEXT("mouse_wheel");
|
|
151
|
+
Wheel.PointerX = 0.5;
|
|
152
|
+
Wheel.PointerY = 0.5;
|
|
153
|
+
Wheel.WheelDelta = 2.0;
|
|
154
|
+
In.Steps.Add(Wheel);
|
|
155
|
+
|
|
156
|
+
const TSharedRef<FJsonObject> Json = SequenceToJson(In);
|
|
157
|
+
const TArray<TSharedPtr<FJsonValue>>& StepsJson = Json->GetArrayField(TEXT("steps"));
|
|
158
|
+
TestEqual(TEXT("written type"), StepsJson[0]->AsObject()->GetStringField(TEXT("type")), FString(TEXT("ui_input")));
|
|
159
|
+
TestFalse(TEXT("wheel step has no button field"), StepsJson[1]->AsObject()->HasField(TEXT("button")));
|
|
160
|
+
TestFalse(TEXT("unmodified step has no modifiers field"), StepsJson[1]->AsObject()->HasField(TEXT("modifiers")));
|
|
161
|
+
|
|
162
|
+
FSequence Out;
|
|
163
|
+
FString Err;
|
|
164
|
+
if (!TestTrue(TEXT("parses"), SequenceFromJson(Json, Out, Err))) { AddError(Err); return false; }
|
|
165
|
+
if (!TestEqual(TEXT("both steps read back"), Out.Steps.Num(), 2)) return false;
|
|
166
|
+
const FStep& D = Out.Steps[0];
|
|
167
|
+
TestTrue(TEXT("type"), D.Type == EStepType::UIInput);
|
|
168
|
+
TestEqual(TEXT("delay"), D.DelayMs, 1200);
|
|
169
|
+
TestEqual(TEXT("event"), D.UIEvent, FString(TEXT("mouse_down")));
|
|
170
|
+
TestEqual(TEXT("x"), D.PointerX, 0.4213);
|
|
171
|
+
TestEqual(TEXT("y"), D.PointerY, 0.6012);
|
|
172
|
+
TestEqual(TEXT("button"), D.UIKey, FString(TEXT("LeftMouseButton")));
|
|
173
|
+
TestTrue(TEXT("modifiers"), D.UIModifiers == (UIModifier::Shift | UIModifier::Control));
|
|
174
|
+
TestEqual(TEXT("wheel delta"), Out.Steps[1].WheelDelta, 2.0);
|
|
175
|
+
|
|
176
|
+
// Inline steps go through the same parser, so a malformed one is refused
|
|
177
|
+
// with a reason rather than silently skipped.
|
|
178
|
+
auto ParseOne = [](const TSharedRef<FJsonObject>& StepObj, FString& OutErr)
|
|
179
|
+
{
|
|
180
|
+
TSharedRef<FJsonObject> Env = MakeShared<FJsonObject>();
|
|
181
|
+
Env->SetNumberField(TEXT("version"), kFormatVersion);
|
|
182
|
+
TArray<TSharedPtr<FJsonValue>> Arr;
|
|
183
|
+
Arr.Add(MakeShared<FJsonValueObject>(StepObj));
|
|
184
|
+
Env->SetArrayField(TEXT("steps"), Arr);
|
|
185
|
+
FSequence S;
|
|
186
|
+
return SequenceFromJson(Env, S, OutErr);
|
|
187
|
+
};
|
|
188
|
+
TSharedRef<FJsonObject> BadEvent = MakeShared<FJsonObject>();
|
|
189
|
+
BadEvent->SetStringField(TEXT("type"), TEXT("ui_input"));
|
|
190
|
+
BadEvent->SetStringField(TEXT("event"), TEXT("mouse_teleport"));
|
|
191
|
+
TestFalse(TEXT("unknown event is refused"), ParseOne(BadEvent, Err));
|
|
192
|
+
TestTrue(TEXT("error names the event"), Err.Contains(TEXT("mouse_teleport")));
|
|
193
|
+
|
|
194
|
+
TSharedRef<FJsonObject> NoButton = MakeShared<FJsonObject>();
|
|
195
|
+
NoButton->SetStringField(TEXT("type"), TEXT("ui_input"));
|
|
196
|
+
NoButton->SetStringField(TEXT("event"), TEXT("mouse_up"));
|
|
197
|
+
TestFalse(TEXT("release without a button is refused"), ParseOne(NoButton, Err));
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
|
|
202
|
+
FPIEUIPointerModifiersTest,
|
|
203
|
+
"UE.MCP.PIE.UIPointer.Modifiers",
|
|
204
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
205
|
+
|
|
206
|
+
bool FPIEUIPointerModifiersTest::RunTest(const FString& /*Parameters*/)
|
|
207
|
+
{
|
|
208
|
+
using namespace MCPPIE;
|
|
209
|
+
const uint8 All = UIModifier::Shift | UIModifier::Control | UIModifier::Alt | UIModifier::Command;
|
|
210
|
+
TestTrue(TEXT("round trip"), UIModifiersFromStrings(UIModifiersToStrings(All)) == All);
|
|
211
|
+
TestEqual(TEXT("none"), UIModifiersToStrings(0).Num(), 0);
|
|
212
|
+
TestTrue(TEXT("ctrl alias and case"), UIModifiersFromStrings({ TEXT("CTRL"), TEXT("Shift") })
|
|
213
|
+
== (UIModifier::Control | UIModifier::Shift));
|
|
214
|
+
TestTrue(TEXT("unknown names ignored"), UIModifiersFromStrings({ TEXT("hyper") }) == 0);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
|
|
219
|
+
FPIEUIPointerEnhancedInputFilterTest,
|
|
220
|
+
"UE.MCP.PIE.UIPointer.EnhancedInputFilter",
|
|
221
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
222
|
+
|
|
223
|
+
bool FPIEUIPointerEnhancedInputFilterTest::RunTest(const FString& /*Parameters*/)
|
|
224
|
+
{
|
|
225
|
+
using namespace MCPPIE;
|
|
226
|
+
const TSet<FKey> Mapped = { EKeys::LeftMouseButton, EKeys::MouseWheelAxis };
|
|
227
|
+
|
|
228
|
+
TestTrue(TEXT("mapped button"), IsUIPointerInputMapped(Mapped, EUIPointerEvent::Down, EKeys::LeftMouseButton));
|
|
229
|
+
TestFalse(TEXT("unmapped button"), IsUIPointerInputMapped(Mapped, EUIPointerEvent::Down, EKeys::RightMouseButton));
|
|
230
|
+
TestTrue(TEXT("mapped wheel axis covers the wheel"), IsUIPointerInputMapped(Mapped, EUIPointerEvent::Wheel, EKeys::Invalid));
|
|
231
|
+
TestFalse(TEXT("unmapped wheel"), IsUIPointerInputMapped({ EKeys::LeftMouseButton }, EUIPointerEvent::Wheel, EKeys::Invalid));
|
|
232
|
+
TestTrue(TEXT("scroll-up key counts as the wheel"), IsUIPointerInputMapped({ EKeys::MouseScrollUp }, EUIPointerEvent::Wheel, EKeys::Invalid));
|
|
233
|
+
TestFalse(TEXT("a move never matches"), IsUIPointerInputMapped(Mapped, EUIPointerEvent::Move, EKeys::LeftMouseButton));
|
|
234
|
+
|
|
235
|
+
// Skipped only when the press reaches the game and Enhanced Input maps it.
|
|
236
|
+
TestTrue(TEXT("mapped click on the game viewport is skipped"), ShouldSkipUIPointerEvent(EUIPointerEvent::Down, true, true));
|
|
237
|
+
TestTrue(TEXT("mapped double click on the game viewport is skipped"), ShouldSkipUIPointerEvent(EUIPointerEvent::DoubleClick, true, true));
|
|
238
|
+
TestTrue(TEXT("mapped wheel on the game viewport is skipped"), ShouldSkipUIPointerEvent(EUIPointerEvent::Wheel, true, true));
|
|
239
|
+
TestFalse(TEXT("click on a UMG widget is recorded even when mapped"), ShouldSkipUIPointerEvent(EUIPointerEvent::Down, false, true));
|
|
240
|
+
TestFalse(TEXT("unmapped click on the game viewport is recorded"), ShouldSkipUIPointerEvent(EUIPointerEvent::Down, true, false));
|
|
241
|
+
TestFalse(TEXT("moves are always recorded"), ShouldSkipUIPointerEvent(EUIPointerEvent::Move, true, true));
|
|
242
|
+
TestFalse(TEXT("releases follow their press"), ShouldSkipUIPointerEvent(EUIPointerEvent::Up, true, true));
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
#endif
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#include "UE_MCP_BridgeModule.h"
|
|
2
|
+
#include "Handlers/Fab/FabLibrary.h"
|
|
3
|
+
#include "Handlers/Fab/FabDownloads.h"
|
|
2
4
|
#include "Modules/ModuleManager.h"
|
|
3
5
|
#include "BridgeServer.h"
|
|
4
6
|
#include "EngineStatusHooks.h"
|
|
@@ -225,6 +227,8 @@ void FUE_MCP_BridgeModule::StartupModule()
|
|
|
225
227
|
|
|
226
228
|
void FUE_MCP_BridgeModule::ShutdownModule()
|
|
227
229
|
{
|
|
230
|
+
MCPFab::ResetLibrary();
|
|
231
|
+
MCPFab::ShutdownDownloads();
|
|
228
232
|
FEditorHandlers::ShutdownMeshStudioRenders();
|
|
229
233
|
UEMCP::SceneCapture::ShutdownWarmCapture();
|
|
230
234
|
if (G_EditorReadyTicker.IsValid())
|