#include #include #include #include #include #include #ifndef XCNEWEDITOR_REPO_ROOT #define XCNEWEDITOR_REPO_ROOT "." #endif namespace { using XCEngine::UI::UIDrawCommand; using XCEngine::UI::UIDrawCommandType; using XCEngine::UI::UIDrawData; using XCEngine::UI::Runtime::UIScreenAsset; using XCEngine::UI::Runtime::UIScreenFrameInput; using XCEngine::UI::Runtime::UIScreenPlayer; using XCEngine::UI::Runtime::UIDocumentScreenHost; std::filesystem::path RepoRelative(const char* relativePath) { return (std::filesystem::path(XCNEWEDITOR_REPO_ROOT) / relativePath).lexically_normal(); } bool DrawDataContainsText(const UIDrawData& drawData, const std::string& text) { for (const auto& drawList : drawData.GetDrawLists()) { for (const UIDrawCommand& command : drawList.GetCommands()) { if (command.type == UIDrawCommandType::Text && command.text == text) { return true; } } } return false; } bool ContainsPathWithFilename( const std::vector& paths, const char* expectedFileName) { for (const std::string& path : paths) { if (std::filesystem::path(path).filename() == expectedFileName) { return true; } } return false; } } // namespace TEST(NewEditorStructuredShellTest, AuthoredEditorShellLoadsFromRepositoryResources) { const std::filesystem::path viewPath = RepoRelative("new_editor/ui/views/editor_shell.xcui"); const std::filesystem::path themePath = RepoRelative("new_editor/ui/themes/editor_shell.xctheme"); ASSERT_TRUE(std::filesystem::exists(viewPath)); ASSERT_TRUE(std::filesystem::exists(themePath)); UIScreenAsset asset = {}; asset.screenId = "new_editor.editor_shell"; asset.documentPath = viewPath.string(); asset.themePath = themePath.string(); UIDocumentScreenHost host = {}; UIScreenPlayer player(host); ASSERT_TRUE(player.Load(asset)) << player.GetLastError(); ASSERT_NE(player.GetDocument(), nullptr); EXPECT_TRUE(player.GetDocument()->hasThemeDocument); EXPECT_TRUE(ContainsPathWithFilename(player.GetDocument()->dependencies, "editor_shell.xctheme")); UIScreenFrameInput input = {}; input.viewportRect = XCEngine::UI::UIRect(0.0f, 0.0f, 1440.0f, 900.0f); input.frameIndex = 1u; input.focused = true; const auto& frame = player.Update(input); EXPECT_TRUE(frame.stats.documentLoaded); EXPECT_GT(frame.stats.nodeCount, 6u); EXPECT_GT(frame.stats.commandCount, 12u); EXPECT_TRUE(DrawDataContainsText(frame.drawData, "XCUI Core Validation")); EXPECT_TRUE(DrawDataContainsText(frame.drawData, "Input Core")); EXPECT_TRUE(DrawDataContainsText(frame.drawData, "Hover / Focus")); EXPECT_TRUE(DrawDataContainsText(frame.drawData, "Pointer Capture")); EXPECT_TRUE(DrawDataContainsText(frame.drawData, "Route Target")); }