More http post end points filled
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#include "RuntimeStateJson.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -17,29 +19,19 @@ void ExpectContains(const std::string& text, const std::string& fragment, const
|
||||
std::cerr << "FAIL: " << message << "\n";
|
||||
}
|
||||
|
||||
ShaderPackage MakePackage()
|
||||
std::filesystem::path MakeTestRoot()
|
||||
{
|
||||
ShaderPackage package;
|
||||
package.id = "solid-color";
|
||||
package.displayName = "Solid Color";
|
||||
package.description = "A single color shader.";
|
||||
package.category = "Generator";
|
||||
const auto stamp = std::chrono::steady_clock::now().time_since_epoch().count();
|
||||
const std::filesystem::path root = std::filesystem::temp_directory_path() / ("render-cadence-state-json-tests-" + std::to_string(stamp));
|
||||
std::filesystem::create_directories(root);
|
||||
return root;
|
||||
}
|
||||
|
||||
ShaderPassDefinition pass;
|
||||
pass.id = "main";
|
||||
package.passes.push_back(pass);
|
||||
|
||||
ShaderParameterDefinition color;
|
||||
color.id = "color";
|
||||
color.label = "Color";
|
||||
color.description = "Output color.";
|
||||
color.type = ShaderParameterType::Color;
|
||||
color.defaultNumbers = { 1.0, 0.25, 0.5, 1.0 };
|
||||
color.minNumbers = { 0.0, 0.0, 0.0, 0.0 };
|
||||
color.maxNumbers = { 1.0, 1.0, 1.0, 1.0 };
|
||||
color.stepNumbers = { 0.01, 0.01, 0.01, 0.01 };
|
||||
package.parameters.push_back(color);
|
||||
return package;
|
||||
void WriteFile(const std::filesystem::path& path, const std::string& contents)
|
||||
{
|
||||
std::filesystem::create_directories(path.parent_path());
|
||||
std::ofstream output(path, std::ios::binary);
|
||||
output << contents;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +45,41 @@ int main()
|
||||
telemetry.renderFps = 59.94;
|
||||
telemetry.shaderBuildsCommitted = 1;
|
||||
|
||||
std::vector<RenderCadenceCompositor::SupportedShaderSummary> shaders = {
|
||||
{ "solid-color", "Solid Color", "A single color shader.", "Generator" }
|
||||
};
|
||||
const ShaderPackage package = MakePackage();
|
||||
const std::filesystem::path root = MakeTestRoot();
|
||||
WriteFile(root / "solid-color" / "shader.slang", "float4 shadeVideo(float2 uv) { return float4(uv, 0.0, 1.0); }\n");
|
||||
WriteFile(root / "solid-color" / "shader.json", R"({
|
||||
"id": "solid-color",
|
||||
"name": "Solid Color",
|
||||
"description": "A single color shader.",
|
||||
"category": "Generator",
|
||||
"entryPoint": "shadeVideo",
|
||||
"parameters": [
|
||||
{
|
||||
"id": "color",
|
||||
"label": "Color",
|
||||
"description": "Output color.",
|
||||
"type": "color",
|
||||
"default": [1.0, 0.25, 0.5, 1.0],
|
||||
"min": [0.0, 0.0, 0.0, 0.0],
|
||||
"max": [1.0, 1.0, 1.0, 1.0],
|
||||
"step": [0.01, 0.01, 0.01, 0.01]
|
||||
}
|
||||
]
|
||||
})");
|
||||
|
||||
RenderCadenceCompositor::SupportedShaderCatalog shaderCatalog;
|
||||
std::string error;
|
||||
ExpectContains(shaderCatalog.Load(root, 4, error) ? "loaded" : error, "loaded", "test shader catalog should load");
|
||||
|
||||
RenderCadenceCompositor::RuntimeLayerModel layerModel;
|
||||
layerModel.InitializeSingleLayer(shaderCatalog, "solid-color", error);
|
||||
RuntimeShaderArtifact artifact;
|
||||
artifact.shaderId = "solid-color";
|
||||
artifact.displayName = "Solid Color";
|
||||
artifact.fragmentShaderSource = "void main(){}";
|
||||
artifact.message = "Runtime shader committed.";
|
||||
layerModel.MarkBuildReady(artifact, error);
|
||||
const RenderCadenceCompositor::RuntimeLayerModelSnapshot layerSnapshot = layerModel.Snapshot();
|
||||
|
||||
const std::string json = RenderCadenceCompositor::RuntimeStateToJson(RenderCadenceCompositor::RuntimeStateJsonInput{
|
||||
config,
|
||||
@@ -64,10 +87,8 @@ int main()
|
||||
8080,
|
||||
true,
|
||||
"DeckLink scheduled output running.",
|
||||
shaders,
|
||||
true,
|
||||
"Runtime shader committed.",
|
||||
&package
|
||||
shaderCatalog,
|
||||
layerSnapshot
|
||||
});
|
||||
|
||||
ExpectContains(json, "\"shaders\":[{\"id\":\"solid-color\"", "state JSON should include supported shaders");
|
||||
@@ -78,6 +99,8 @@ int main()
|
||||
ExpectContains(json, "\"width\":1920", "state JSON should expose output width");
|
||||
ExpectContains(json, "\"height\":1080", "state JSON should expose output height");
|
||||
|
||||
std::filesystem::remove_all(root);
|
||||
|
||||
if (gFailures != 0)
|
||||
{
|
||||
std::cerr << gFailures << " RenderCadenceCompositorRuntimeStateJson test failure(s).\n";
|
||||
|
||||
Reference in New Issue
Block a user