Add XCUI schema document regression coverage
This commit is contained in:
@@ -14,7 +14,7 @@ constexpr Core::uint32 kTextureArtifactSchemaVersion = 1;
|
||||
constexpr Core::uint32 kMaterialArtifactSchemaVersion = 2;
|
||||
constexpr Core::uint32 kMeshArtifactSchemaVersion = 2;
|
||||
constexpr Core::uint32 kShaderArtifactSchemaVersion = 1;
|
||||
constexpr Core::uint32 kUIDocumentArtifactSchemaVersion = 1;
|
||||
constexpr Core::uint32 kUIDocumentArtifactSchemaVersion = 2;
|
||||
|
||||
struct TextureArtifactHeader {
|
||||
char magic[8] = { 'X', 'C', 'T', 'E', 'X', '0', '1', '\0' };
|
||||
|
||||
@@ -19,6 +19,15 @@ enum class UIDocumentDiagnosticSeverity : Core::uint8 {
|
||||
Error
|
||||
};
|
||||
|
||||
enum class UISchemaValueType : Core::uint8 {
|
||||
String = 0,
|
||||
Boolean,
|
||||
Integer,
|
||||
Number,
|
||||
Document,
|
||||
Enum
|
||||
};
|
||||
|
||||
struct UIDocumentSourceLocation {
|
||||
Core::uint32 line = 1;
|
||||
Core::uint32 column = 1;
|
||||
@@ -35,6 +44,67 @@ struct UIDocumentDiagnostic {
|
||||
Containers::String message;
|
||||
};
|
||||
|
||||
struct UISchemaAttributeDefinition {
|
||||
Containers::String name;
|
||||
UISchemaValueType valueType = UISchemaValueType::String;
|
||||
UIDocumentKind documentKind = UIDocumentKind::View;
|
||||
Containers::Array<Containers::String> allowedValues;
|
||||
UIDocumentSourceLocation location = {};
|
||||
bool required = false;
|
||||
bool restrictDocumentKind = false;
|
||||
};
|
||||
|
||||
struct UISchemaElementDefinition {
|
||||
Containers::String tagName;
|
||||
Containers::Array<UISchemaAttributeDefinition> attributes;
|
||||
Containers::Array<UISchemaElementDefinition> children;
|
||||
UIDocumentSourceLocation location = {};
|
||||
bool allowUnknownAttributes = false;
|
||||
bool allowUnknownChildren = false;
|
||||
|
||||
const UISchemaAttributeDefinition* FindAttribute(const Containers::String& name) const {
|
||||
for (const UISchemaAttributeDefinition& attribute : attributes) {
|
||||
if (attribute.name == name) {
|
||||
return &attribute;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const UISchemaElementDefinition* FindChild(const Containers::String& tagNameValue) const {
|
||||
for (const UISchemaElementDefinition& child : children) {
|
||||
if (child.tagName == tagNameValue) {
|
||||
return &child;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
struct UISchemaDefinition {
|
||||
Containers::String name;
|
||||
Containers::Array<UISchemaElementDefinition> elements;
|
||||
bool valid = false;
|
||||
|
||||
const UISchemaElementDefinition* FindElement(const Containers::String& tagNameValue) const {
|
||||
for (const UISchemaElementDefinition& element : elements) {
|
||||
if (element.tagName == tagNameValue) {
|
||||
return &element;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
name.Clear();
|
||||
elements.Clear();
|
||||
valid = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct UIDocumentNode {
|
||||
Containers::String tagName;
|
||||
Containers::Array<UIDocumentAttribute> attributes;
|
||||
@@ -58,6 +128,7 @@ struct UIDocumentModel {
|
||||
Containers::String sourcePath;
|
||||
Containers::String displayName;
|
||||
UIDocumentNode rootNode;
|
||||
UISchemaDefinition schemaDefinition;
|
||||
Containers::Array<Containers::String> dependencies;
|
||||
Containers::Array<UIDocumentDiagnostic> diagnostics;
|
||||
bool valid = false;
|
||||
@@ -66,6 +137,7 @@ struct UIDocumentModel {
|
||||
sourcePath.Clear();
|
||||
displayName.Clear();
|
||||
rootNode = UIDocumentNode();
|
||||
schemaDefinition.Clear();
|
||||
dependencies.Clear();
|
||||
diagnostics.Clear();
|
||||
valid = false;
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
|
||||
const UIDocumentModel& GetDocument() const { return m_document; }
|
||||
const UIDocumentNode& GetRootNode() const { return m_document.rootNode; }
|
||||
const UISchemaDefinition& GetSchemaDefinition() const { return m_document.schemaDefinition; }
|
||||
const Containers::Array<Containers::String>& GetDependencies() const { return m_document.dependencies; }
|
||||
const Containers::Array<UIDocumentDiagnostic>& GetDiagnostics() const { return m_document.diagnostics; }
|
||||
const Containers::String& GetSourcePath() const { return m_document.sourcePath; }
|
||||
|
||||
Reference in New Issue
Block a user