OSC stubs
All checks were successful
CI / React UI Build (push) Successful in 12s
CI / Native Windows Build And Tests (push) Successful in 2m11s
CI / Windows Release Package (push) Has been skipped

This commit is contained in:
Aiden
2026-05-30 20:42:38 +10:00
parent 04e0802ef2
commit 0f3db3ba1b
18 changed files with 298 additions and 16 deletions

View File

@@ -98,6 +98,11 @@ add_video_shader_test(RenderCadenceCompositorHttpControlServerTests
)
target_link_libraries(RenderCadenceCompositorHttpControlServerTests PRIVATE Ws2_32)
add_video_shader_test(OscControlServerTests
"${SRC_DIR}/control/osc/OscControlServer.cpp"
"${TEST_DIR}/OscControlServerTests.cpp"
)
add_video_shader_test(RenderCadenceCompositorAppConfigProviderTests
"${SRC_DIR}/app/AppConfig.cpp"
"${SRC_DIR}/app/AppRestart.cpp"

View File

@@ -0,0 +1,81 @@
#include "osc/OscControlServer.h"
#include <iostream>
#include <string>
namespace
{
int gFailures = 0;
void Expect(bool condition, const std::string& message)
{
if (condition)
return;
++gFailures;
std::cerr << "FAILED: " << message << "\n";
}
void ExpectEquals(const std::string& actual, const std::string& expected, const std::string& message)
{
if (actual == expected)
return;
++gFailures;
std::cerr << "FAILED: " << message << "\n"
<< "expected: " << expected << "\n"
<< "actual: " << actual << "\n";
}
void TestDisabledWhenPortIsZero()
{
using namespace RenderCadenceCompositor;
OscControlServer server;
OscControlServerConfig config;
config.bindAddress = "127.0.0.1";
config.port = 0;
config.smoothing = 0.25;
std::string error;
Expect(server.Start(config, error), "disabled OSC stub starts successfully");
Expect(error.empty(), "disabled OSC stub does not report an error");
Expect(!server.IsConfigured(), "port zero leaves OSC unconfigured");
Expect(!server.IsListening(), "port zero does not listen");
ExpectEquals(server.State().statusMessage, "OSC ingress disabled by config.", "disabled status is explicit");
}
void TestConfiguredStubDoesNotListenYet()
{
using namespace RenderCadenceCompositor;
OscControlServer server;
OscControlServerConfig config;
config.bindAddress = "0.0.0.0";
config.port = 9000;
config.smoothing = 0.18;
std::string error;
Expect(server.Start(config, error), "configured OSC stub starts successfully");
Expect(error.empty(), "configured OSC stub does not report an error");
Expect(server.IsConfigured(), "nonzero port marks OSC as configured");
Expect(!server.IsListening(), "stub does not claim to listen before UDP ingress exists");
ExpectEquals(server.State().bindAddress, "0.0.0.0", "bind address is retained");
Expect(server.State().statusMessage.find("UDP listener is not implemented yet") != std::string::npos, "status reports stub state");
}
}
int main()
{
TestDisabledWhenPortIsZero();
TestConfiguredStubDoesNotListenYet();
if (gFailures != 0)
{
std::cerr << gFailures << " OscControlServer test failure(s).\n";
return 1;
}
std::cout << "OscControlServer tests passed.\n";
return 0;
}

View File

@@ -115,6 +115,27 @@ void TestCommandLineOverrides()
Expect(config.http.preferredPort == 8282, "port CLI override applies");
}
void TestOscPortZeroIsAllowed()
{
using namespace RenderCadenceCompositor;
const std::filesystem::path path = std::filesystem::temp_directory_path() / "render-cadence-compositor-config-osc-disabled-test.json";
std::ofstream output(path, std::ios::binary);
output << "{ \"oscPort\": 0 }\n";
output.close();
std::string error;
AppConfigProvider provider;
Expect(provider.Load(path, error), "provider accepts oscPort zero");
Expect(provider.Config().oscPort == 0, "provider loads oscPort zero");
AppConfig parsed;
Expect(ParseAppConfigJson("{\"oscPort\":0}", parsed, error), "config JSON parser accepts oscPort zero");
Expect(parsed.oscPort == 0, "config JSON parser loads oscPort zero");
std::filesystem::remove(path);
}
void TestPreviewDefaultsAreOptIn()
{
using namespace RenderCadenceCompositor;
@@ -216,6 +237,7 @@ int main()
{
TestLoadsRuntimeHostConfig();
TestCommandLineOverrides();
TestOscPortZeroIsAllowed();
TestPreviewDefaultsAreOptIn();
TestConfigJsonRoundTrip();
TestOutputAlphaNormalizesLegacyKeying();

View File

@@ -119,6 +119,7 @@ int main()
ExpectContains(json, "\"height\":1080", "state JSON should expose output height");
ExpectContains(json, "\"input\":{\"backend\":\"decklink\",\"device\":\"default\",\"resolution\":\"1080p\",\"frameRate\":\"59.94\"}", "state JSON should expose nested input config");
ExpectContains(json, "\"output\":{\"backend\":\"decklink\",\"device\":\"default\",\"resolution\":\"1080p\",\"frameRate\":\"59.94\",\"pixelFormat\":\"auto\",\"systemFramePixelFormat\":\"8-bit BGRA\",\"keying\"", "state JSON should expose nested output config");
ExpectContains(json, "\"osc\":{\"configured\":true,\"listening\":false", "state JSON should expose OSC stub status");
ExpectContains(json, "\"videoOutput\":{\"enabled\":true,\"backend\":\"decklink\"", "state JSON should expose neutral video output status");
ExpectContains(json, "\"scheduleFailures\":2", "state JSON should expose neutral video output schedule failures");
ExpectContains(json, "\"backendMetrics\":{\"bufferedAvailable\":true,\"buffered\":4", "state JSON should expose backend-specific video output metrics");