46 lines
1.7 KiB
C++
46 lines
1.7 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include "XCUIBackend/XCUIStandaloneTextAtlasProvider.h"
|
|
|
|
#include <cstdint>
|
|
|
|
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<std::uint32_t>('A'), glyphInfo));
|
|
EXPECT_EQ(glyphInfo.requestedCodepoint, static_cast<std::uint32_t>('A'));
|
|
EXPECT_GT(glyphInfo.advanceX, 0.0f);
|
|
EXPECT_GE(glyphInfo.u1, glyphInfo.u0);
|
|
EXPECT_GE(glyphInfo.v1, glyphInfo.v0);
|
|
}
|
|
|
|
} // namespace
|