OSC stubs
This commit is contained in:
@@ -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"
|
||||
|
||||
81
tests/OscControlServerTests.cpp
Normal file
81
tests/OscControlServerTests.cpp
Normal 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;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user