MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / RunTest

Method RunTest

Source/URLabEditor/Private/Tests/MjStepServerTests.cpp:61–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
60
61bool FMjStepServerNoManagerGuard::RunTest(const FString& Parameters)
62{
63 UURLabBridgeServer* Server = NewObject<UURLabBridgeServer>();
64 Server->AddToRoot();
65 Server->Start(TEXT("")); // skip ZMQ bind — test only exercises Dispatch()
66 FURLabRpcDispatcher* Disp = Server->GetDispatcher();
67 if (!Disp)
68 {
69 AddError(TEXT("Server has no dispatcher"));
70 Server->RemoveFromRoot();
71 return false;
72 }
73
74 // Plant a session id so subsequent ops reach the manager guard rather
75 // than the session check.
76 Disp->SetActiveSessionIdForTest(TEXT("test-session"));
77
78 // The dispatcher validates RequiredFields BEFORE the manager guard
79 // so malformed requests fail with `missing_field` regardless of PIE
80 // state. To exercise the no-manager path, the request has to be
81 // otherwise well-formed — supply the required fields per op when
82 // probing.
83 auto MakeReq = [](const FString& Op) -> TSharedPtr<FJsonObject> {
84 TSharedPtr<FJsonObject> R = MakeShared<FJsonObject>();
85 R->SetStringField(TEXT("op"), Op);
86 R->SetStringField(TEXT("session_id"), TEXT("test-session"));
87 // Declarative-required fields per op.
88 if (Op == TEXT("set_paused"))
89 R->SetBoolField(TEXT("paused"), true);
90 if (Op == TEXT("set_sim_speed"))
91 R->SetNumberField(TEXT("percent"), 100.0);
92 if (Op == TEXT("configure_controller"))
93 {
94 R->SetStringField(TEXT("articulation"), TEXT("ignored"));
95 R->SetObjectField(TEXT("params"), MakeShared<FJsonObject>());
96 }
97 if (Op == TEXT("set_qpos"))
98 {
99 R->SetStringField(TEXT("target"), TEXT("ignored"));
100 TArray<TSharedPtr<FJsonValue>> EmptyQpos;
101 R->SetArrayField(TEXT("qpos"), EmptyQpos);
102 }
103 if (Op == TEXT("set_mocap_pose") || Op == TEXT("read_mocap_pose"))
104 {
105 R->SetStringField(TEXT("body"), TEXT("ignored"));
106 }
107 return R;
108 };
109
110 auto AssertNoManager = [this, Disp, &MakeReq](const FString& Op) {
111 TSharedPtr<FJsonObject> Reply = Disp->Dispatch(MakeReq(Op));
112 FString Code;
113 Reply->TryGetStringField(TEXT("code"), Code);
114 TestEqual(*FString::Printf(TEXT("op %s -> no_active_manager"), *Op),
115 Code, FString(TEXT("no_active_manager")));
116 };
117
118 AssertNoManager(TEXT("step"));

Callers

nothing calls this directly

Calls 15

RegisterHandlerFunction · 0.85
UnregisterHandlerFunction · 0.85
StartMethod · 0.80
DispatchMethod · 0.80
SetActiveStepModeMethod · 0.80
GetConfigSchemaMethod · 0.80
ApplyConfigMethod · 0.80
GetCurrentConfigMethod · 0.80
GetModelMethod · 0.80
GetDataMethod · 0.80
GetActuatorsMethod · 0.80

Tested by

no test coverage detected