#include "../Common/TestsShell.h" #include #include #include #include #include using namespace Rml; static const String document_layout_rml = R"(
)"; static const String document_layout_rml_nested = R"(
)"; TEST_CASE("Layout.Position.Relative") { Context* context = TestsShell::GetContext(); REQUIRE(context); // Test that percentage positioning in 'position: relative' elements is correctly resolved during the first layout run, and // does not change during the next layout run. See issue: https://github.com/mikke89/RmlUi/issues/262 for (auto&& rml_source : {document_layout_rml, document_layout_rml_nested}) { ElementDocument* document = context->LoadDocumentFromMemory(rml_source); REQUIRE(document); document->Show(); Element* element = document->GetElementById("relative"); REQUIRE(element); TestsShell::RenderLoop(); const float absolute_top = element->GetAbsoluteTop(); CHECK(absolute_top >= 150.f); // This forces a new layout run but shouldn't make any difference to the rendered output. document->SetProperty("width", "500px"); TestsShell::RenderLoop(); CHECK(absolute_top == element->GetAbsoluteTop()); document->SetProperty("width", "400px"); TestsShell::RenderLoop(); CHECK(absolute_top == element->GetAbsoluteTop()); document->Close(); } TestsShell::ShutdownShell(); }