Add UI layout XML automation

This commit is contained in:
2026-06-01 00:21:23 +02:00
parent dfdb7a4468
commit 20b5dba41e
13 changed files with 245 additions and 9 deletions

View File

@@ -96,6 +96,16 @@ add_test(NAME pp_ui_core_layout_value_tests COMMAND pp_ui_core_layout_value_test
set_tests_properties(pp_ui_core_layout_value_tests PROPERTIES
LABELS "ui;desktop-fast")
add_executable(pp_ui_core_layout_xml_tests
ui_core/layout_xml_tests.cpp)
target_link_libraries(pp_ui_core_layout_xml_tests PRIVATE
pp_ui_core
pp_test_harness)
add_test(NAME pp_ui_core_layout_xml_tests COMMAND pp_ui_core_layout_xml_tests)
set_tests_properties(pp_ui_core_layout_xml_tests PROPERTIES
LABELS "ui;desktop-fast")
if(TARGET pano_cli)
add_test(NAME pano_cli_create_document_smoke
COMMAND pano_cli create-document --width 64 --height 32 --layers 2)
@@ -107,4 +117,9 @@ if(TARGET pano_cli)
set_tests_properties(pano_cli_inspect_image_rejects_unsupported PROPERTIES
LABELS "assets;integration;desktop-fast"
WILL_FAIL TRUE)
add_test(NAME pano_cli_parse_layout_smoke
COMMAND pano_cli parse-layout --path "${CMAKE_CURRENT_SOURCE_DIR}/data/layouts/simple-layout.xml")
set_tests_properties(pano_cli_parse_layout_smoke PROPERTIES
LABELS "ui;integration;desktop-fast")
endif()

View File

@@ -0,0 +1,5 @@
<layout width="100%" height="auto">
<panel width="320" height="200">
<button width="64" height="28"/>
</panel>
</layout>

View File

@@ -0,0 +1,47 @@
#include "ui_core/layout_xml.h"
#include "test_harness.h"
using pp::foundation::StatusCode;
using pp::ui::parse_layout_xml;
namespace {
void parses_nested_layout_xml_and_lengths(pp::tests::Harness& h)
{
constexpr auto xml =
"<layout width=\"100%\" height=\"auto\">"
" <panel width=\"320\" height=\"200\">"
" <button width=\"64\" height=\"28\"/>"
" </panel>"
"</layout>";
const auto summary = parse_layout_xml(xml);
PP_EXPECT(h, summary.ok());
PP_EXPECT(h, summary.value().node_count == 3U);
PP_EXPECT(h, summary.value().length_attribute_count == 6U);
}
void rejects_malformed_empty_and_invalid_lengths(pp::tests::Harness& h)
{
const auto empty = parse_layout_xml("");
const auto malformed = parse_layout_xml("<layout><panel></layout>");
const auto invalid_length = parse_layout_xml("<layout width=\"101%\"/>");
PP_EXPECT(h, !empty.ok());
PP_EXPECT(h, empty.status().code == StatusCode::invalid_argument);
PP_EXPECT(h, !malformed.ok());
PP_EXPECT(h, malformed.status().code == StatusCode::invalid_argument);
PP_EXPECT(h, !invalid_length.ok());
PP_EXPECT(h, invalid_length.status().code == StatusCode::out_of_range);
}
}
int main()
{
pp::tests::Harness harness;
harness.run("parses_nested_layout_xml_and_lengths", parses_nested_layout_xml_and_lengths);
harness.run("rejects_malformed_empty_and_invalid_lengths", rejects_malformed_empty_and_invalid_lengths);
return harness.finish();
}