Initial font work
This commit is contained in:
@@ -47,6 +47,7 @@ void TestValidManifest()
|
||||
{
|
||||
const std::filesystem::path root = MakeTestRoot();
|
||||
WriteFile(root / "look" / "mask.png", "not a real png, but enough for existence checks");
|
||||
WriteFile(root / "look" / "Inter.ttf", "not a real font, but enough for existence checks");
|
||||
WriteShaderPackage(root, "look", R"({
|
||||
"id": "look-01",
|
||||
"name": "Look 01",
|
||||
@@ -54,9 +55,11 @@ void TestValidManifest()
|
||||
"category": "Tests",
|
||||
"entryPoint": "shadeVideo",
|
||||
"textures": [{ "id": "maskTex", "path": "mask.png" }],
|
||||
"fonts": [{ "id": "inter", "path": "Inter.ttf" }],
|
||||
"temporal": { "enabled": true, "historySource": "source", "historyLength": 8 },
|
||||
"parameters": [
|
||||
{ "id": "gain", "label": "Gain", "type": "float", "default": 0.5, "min": 0, "max": 1 },
|
||||
{ "id": "titleText", "label": "Title", "type": "text", "default": "LIVE", "font": "inter", "maxLength": 32 },
|
||||
{ "id": "mode", "label": "Mode", "type": "enum", "default": "soft", "options": [
|
||||
{ "value": "soft", "label": "Soft" },
|
||||
{ "value": "hard", "label": "Hard" }
|
||||
@@ -70,8 +73,29 @@ void TestValidManifest()
|
||||
Expect(registry.ParseManifest(root / "look" / "shader.json", package, error), "valid manifest parses");
|
||||
Expect(package.id == "look-01", "manifest id is preserved");
|
||||
Expect(package.textureAssets.size() == 1 && package.textureAssets[0].id == "maskTex", "texture assets parse");
|
||||
Expect(package.fontAssets.size() == 1 && package.fontAssets[0].id == "inter", "font assets parse");
|
||||
Expect(package.temporal.enabled && package.temporal.effectiveHistoryLength == 4, "temporal history is capped");
|
||||
Expect(package.parameters.size() == 2, "parameters parse");
|
||||
Expect(package.parameters.size() == 3, "parameters parse");
|
||||
Expect(package.parameters[1].type == ShaderParameterType::Text && package.parameters[1].defaultTextValue == "LIVE", "text parameter parses");
|
||||
|
||||
std::filesystem::remove_all(root);
|
||||
}
|
||||
|
||||
void TestMissingFontAsset()
|
||||
{
|
||||
const std::filesystem::path root = MakeTestRoot();
|
||||
WriteShaderPackage(root, "bad-font", R"({
|
||||
"id": "bad-font",
|
||||
"name": "Bad Font",
|
||||
"fonts": [{ "id": "missingFont", "path": "missing.ttf" }],
|
||||
"parameters": []
|
||||
})");
|
||||
|
||||
ShaderPackageRegistry registry(4);
|
||||
ShaderPackage package;
|
||||
std::string error;
|
||||
Expect(!registry.ParseManifest(root / "bad-font" / "shader.json", package, error), "missing font asset is rejected");
|
||||
Expect(error.find("font asset not found") != std::string::npos, "missing font error is clear");
|
||||
|
||||
std::filesystem::remove_all(root);
|
||||
}
|
||||
@@ -115,6 +139,7 @@ void TestDuplicateScan()
|
||||
int main()
|
||||
{
|
||||
TestValidManifest();
|
||||
TestMissingFontAsset();
|
||||
TestInvalidManifest();
|
||||
TestDuplicateScan();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user