#include #include "XCUIBackend/XCUIStandaloneTextAtlasProvider.h" #include namespace { using XCEngine::Editor::XCUIBackend::IXCUITextAtlasProvider; using XCEngine::Editor::XCUIBackend::XCUIStandaloneTextAtlasProvider; TEST(XCUIStandaloneTextAtlasProviderTest, BuildsDefaultEditorAtlasWithoutImGuiContext) { XCUIStandaloneTextAtlasProvider provider = {}; IXCUITextAtlasProvider::AtlasTextureView atlasView = {}; ASSERT_TRUE(provider.IsReady()); ASSERT_TRUE(provider.GetAtlasTextureView(IXCUITextAtlasProvider::PixelFormat::RGBA32, atlasView)); EXPECT_TRUE(atlasView.IsValid()); EXPECT_EQ(atlasView.format, IXCUITextAtlasProvider::PixelFormat::RGBA32); EXPECT_GT(provider.GetFontCount(), 0u); } TEST(XCUIStandaloneTextAtlasProviderTest, ExposesDefaultFontMetricsAndGlyphs) { XCUIStandaloneTextAtlasProvider provider = {}; const IXCUITextAtlasProvider::FontHandle defaultFont = provider.GetDefaultFont(); ASSERT_TRUE(defaultFont.IsValid()); IXCUITextAtlasProvider::FontInfo fontInfo = {}; ASSERT_TRUE(provider.GetFontInfo(defaultFont, fontInfo)); EXPECT_GT(fontInfo.nominalSize, 0.0f); IXCUITextAtlasProvider::BakedFontInfo bakedFontInfo = {}; ASSERT_TRUE(provider.GetBakedFontInfo(defaultFont, 0.0f, bakedFontInfo)); EXPECT_GT(bakedFontInfo.lineHeight, 0.0f); EXPECT_GT(bakedFontInfo.rasterizerDensity, 0.0f); IXCUITextAtlasProvider::GlyphInfo glyphInfo = {}; ASSERT_TRUE(provider.FindGlyph(defaultFont, 0.0f, static_cast('A'), glyphInfo)); EXPECT_EQ(glyphInfo.requestedCodepoint, static_cast('A')); EXPECT_GT(glyphInfo.advanceX, 0.0f); EXPECT_GE(glyphInfo.u1, glyphInfo.u0); EXPECT_GE(glyphInfo.v1, glyphInfo.v0); } } // namespace