From c3f8ff7710e627225bcb953697806b86ffcd9ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 5 Apr 2025 13:11:11 +0200 Subject: [PATCH] Text: various silly test changes to make coverage happier. --- .../Test/DistanceFieldGlyphCacheGLTest.cpp | 5 +++ src/Magnum/Text/Test/GlyphCacheGLTest.cpp | 2 ++ src/Magnum/Text/Test/RendererGLTest.cpp | 32 +++++++++++++++---- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/Magnum/Text/Test/DistanceFieldGlyphCacheGLTest.cpp b/src/Magnum/Text/Test/DistanceFieldGlyphCacheGLTest.cpp index e527c0534..f5c3224c6 100644 --- a/src/Magnum/Text/Test/DistanceFieldGlyphCacheGLTest.cpp +++ b/src/Magnum/Text/Test/DistanceFieldGlyphCacheGLTest.cpp @@ -144,6 +144,11 @@ void DistanceFieldGlyphCacheGLTest::construct() { DistanceFieldGlyphCacheGL cache{{1024, 2048}, {128, 256}, 16}; MAGNUM_VERIFY_NO_GL_ERROR(); + #ifndef MAGNUM_TARGET_GLES + CORRADE_COMPARE(cache.features(), GlyphCacheFeature::ImageProcessing|GlyphCacheFeature::ProcessedImageDownload); + #else + CORRADE_COMPARE(cache.features(), GlyphCacheFeature::ImageProcessing); + #endif /* The input format is always single-channel */ CORRADE_COMPARE(cache.format(), PixelFormat::R8Unorm); CORRADE_COMPARE(cache.size(), (Vector3i{1024, 2048, 1})); diff --git a/src/Magnum/Text/Test/GlyphCacheGLTest.cpp b/src/Magnum/Text/Test/GlyphCacheGLTest.cpp index afe2c0088..aba1cf10d 100644 --- a/src/Magnum/Text/Test/GlyphCacheGLTest.cpp +++ b/src/Magnum/Text/Test/GlyphCacheGLTest.cpp @@ -148,6 +148,7 @@ void GlyphCacheGLTest::construct() { GlyphCacheGL cache{PixelFormat::R8Unorm, {1024, 2048}, {3, 2}}; MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_COMPARE(cache.features(), GlyphCacheFeatures{}); CORRADE_COMPARE(cache.format(), PixelFormat::R8Unorm); CORRADE_COMPARE(cache.size(), (Vector3i{1024, 2048, 1})); CORRADE_COMPARE(cache.padding(), (Vector2i{3, 2})); @@ -161,6 +162,7 @@ void GlyphCacheGLTest::constructArray() { GlyphCacheArrayGL cache{PixelFormat::R8Unorm, {1024, 2048, 7}, {3, 2}}; MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_COMPARE(cache.features(), GlyphCacheFeatures{}); CORRADE_COMPARE(cache.format(), PixelFormat::R8Unorm); CORRADE_COMPARE(cache.size(), (Vector3i{1024, 2048, 7})); CORRADE_COMPARE(cache.padding(), (Vector2i{3, 2})); diff --git a/src/Magnum/Text/Test/RendererGLTest.cpp b/src/Magnum/Text/Test/RendererGLTest.cpp index 08cebc38c..ff023042c 100644 --- a/src/Magnum/Text/Test/RendererGLTest.cpp +++ b/src/Magnum/Text/Test/RendererGLTest.cpp @@ -53,6 +53,18 @@ #include "Magnum/Text/RendererGL.h" #include "Magnum/Trade/AbstractImporter.h" +/* Somehow on GCC 4.8 to 7 the {} passed as a default argument for + ArrayView causes "error: elements of array 'const class + Magnum::Text::FeatureRange [0]' have incomplete type". GCC 9 is fine, no + idea about version 8, but including the definition for it as well to be + safe. Similar problem happens with MSVC STL, where the initializer_list is + implemented as a (begin, end) pair and size() is a difference of those two + pointers. Which needs to know the type size to calculate the actual element + count. */ +#if (defined(CORRADE_TARGET_GCC) && __GNUC__ <= 8) || defined(CORRADE_TARGET_DINKUMWARE) +#include "Magnum/Text/Feature.h" +#endif + #ifdef MAGNUM_BUILD_DEPRECATED #include #include @@ -277,6 +289,8 @@ void RendererGLTest::construct() { CORRADE_COMPARE(renderer.indexType(), data.expectedIndexType); CORRADE_COMPARE(renderer.mesh().count(), 0); CORRADE_COMPARE(renderer.mesh().indexType(), GL::meshIndexType(data.expectedIndexType)); + /* Testing the const mesh() overload also */ + CORRADE_COMPARE(static_cast(renderer).mesh().indexType(), GL::meshIndexType(data.expectedIndexType)); } #ifdef MAGNUM_TARGET_GLES2 @@ -526,11 +540,13 @@ void RendererGLTest::renderClearReset() { .setCursor({-3.0f, 1.0f}) .render(shaper, 1.0f, "abc"); - /* This uploads indices if reserve() wasn't called or was too little */ + /* This uploads indices if reserve() wasn't called or was too little. + Using an add() overload + render() to make coverage happier. */ renderer .setAlignment(Alignment::LineRight) .setCursor({5.0f, -3.0f}) - .render(shaper, 2.0f, "de"); + .add(shaper, 2.0f, "de", 0, 2, {}) + .render(); /* This may reupload indices if called */ if(data.indexTypeAfter) { @@ -807,11 +823,13 @@ void RendererGLTest::renderIndexTypeChanged() { change, not 16k */ renderer.setIndexType(MeshIndexType::UnsignedByte); - /* 16*16 glyphs. Index type doesn't change yet, only after render(). */ + /* 16*16 glyphs. Index type doesn't change yet, only after render(). Using + yet another add() overload to make coverage happier. */ renderer .setAlignment(Alignment::LineLeft) .setCursor({-3.0f, 1.0f}) - .add(shaper, 1.0f, "0123456789abcdef"_s*16); + .add(shaper, 1.0f, "0123456789abcdef"_s*8, {}) + .add(shaper, 1.0f, "0123456789abcdef"_s*8, 0, 8*16, Containers::ArrayView{}); CORRADE_COMPARE(renderer.indexType(), MeshIndexType::UnsignedByte); CORRADE_COMPARE(renderer.mesh().indexType(), GL::MeshIndexType::UnsignedByte); @@ -822,11 +840,13 @@ void RendererGLTest::renderIndexTypeChanged() { CORRADE_COMPARE(renderer.mesh().indexType(), GL::MeshIndexType::UnsignedShort); /* Just to match the image made in renderClearReset(), nothing else. There - should be 256 + 5 glyphs in total. */ + should be 256 + 5 glyphs in total. Using yet another add() overload + + render() just to make coverage happier. */ renderer .setAlignment(Alignment::LineRight) .setCursor({5.0f, -3.0f}) - .render(shaper, 2.0f, "de"); + .add(shaper, 2.0f, "de", 0, 2) + .render(); CORRADE_COMPARE(renderer.glyphCount(), 256 + 5); /* Draw just the suffix from the mesh, not everything */