#include #include TEST(XCUIDrawDataTest, DrawListBuilderPreservesCommandOrderAndPayload) { using XCEngine::UI::UIColor; using XCEngine::UI::UIDrawCommandType; using XCEngine::UI::UIDrawList; using XCEngine::UI::UIPoint; using XCEngine::UI::UIRect; using XCEngine::UI::UITextureHandle; UIDrawList drawList("PrimaryList"); drawList.PushClipRect(UIRect(0.0f, 0.0f, 200.0f, 120.0f)); drawList.AddFilledRect(UIRect(10.0f, 12.0f, 48.0f, 24.0f), UIColor(0.1f, 0.2f, 0.3f, 1.0f), 4.0f); drawList.AddRectOutline(UIRect(10.0f, 12.0f, 48.0f, 24.0f), UIColor(0.4f, 0.5f, 0.6f, 1.0f), 2.0f, 4.0f); drawList.AddText(UIPoint(18.0f, 22.0f), "XCUI", UIColor(1.0f, 1.0f, 1.0f, 1.0f), 16.0f); drawList.AddImage( UIRect(70.0f, 18.0f, 32.0f, 32.0f), UITextureHandle{ 123u, 32u, 32u }, UIColor(0.8f, 0.9f, 1.0f, 1.0f)); drawList.PopClipRect(); ASSERT_EQ(drawList.GetCommandCount(), 6u); const auto& commands = drawList.GetCommands(); EXPECT_EQ(commands[0].type, UIDrawCommandType::PushClipRect); EXPECT_EQ(commands[1].type, UIDrawCommandType::FilledRect); EXPECT_EQ(commands[2].type, UIDrawCommandType::RectOutline); EXPECT_EQ(commands[3].type, UIDrawCommandType::Text); EXPECT_EQ(commands[4].type, UIDrawCommandType::Image); EXPECT_EQ(commands[5].type, UIDrawCommandType::PopClipRect); EXPECT_FLOAT_EQ(commands[1].rounding, 4.0f); EXPECT_FLOAT_EQ(commands[2].thickness, 2.0f); EXPECT_EQ(commands[3].text, "XCUI"); EXPECT_EQ(commands[4].texture.nativeHandle, 123u); } TEST(XCUIDrawDataTest, DrawDataAggregatesMultipleLists) { using XCEngine::UI::UIColor; using XCEngine::UI::UIDrawData; using XCEngine::UI::UIRect; UIDrawData drawData = {}; auto& first = drawData.EmplaceDrawList("First"); first.AddFilledRect(UIRect(0.0f, 0.0f, 20.0f, 20.0f), UIColor(1.0f, 0.0f, 0.0f, 1.0f)); auto& second = drawData.EmplaceDrawList("Second"); second.AddFilledRect(UIRect(5.0f, 5.0f, 10.0f, 10.0f), UIColor(0.0f, 1.0f, 0.0f, 1.0f)); second.AddRectOutline(UIRect(5.0f, 5.0f, 10.0f, 10.0f), UIColor(1.0f, 1.0f, 1.0f, 1.0f)); EXPECT_EQ(drawData.GetDrawListCount(), 2u); EXPECT_EQ(drawData.GetTotalCommandCount(), 3u); }