mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-13 04:42:12 +03:00
Add a few more tests for font and text rendering.
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
BIN
bin/unit_tests/assets/fontrendering/eepp-textview.webp
Normal file
BIN
bin/unit_tests/assets/fontrendering/eepp-textview.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
21
bin/unit_tests/assets/fontrendering/tabs_test.txt
Normal file
21
bin/unit_tests/assets/fontrendering/tabs_test.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
{
|
||||
{ "u8", "type" }, { "u16", "type" }, { "u32", "type" },
|
||||
{ "u64", "type" }, { "s8", "type" }, { "s16", "type" },
|
||||
{ "s32", "type" }, { "s64", "type" }, { "int", "type" },
|
||||
{ "float", "type" }, { "float32", "type" }, { "float64", "type" },
|
||||
{ "Any", "type" }, { "array", "type" }, { "bool", "type" },
|
||||
{ "enum", "keyword" }, { "null", "type" }, { "pointer", "type" },
|
||||
{ "procedure", "keyword" }, { "string", "type" }, { "struct", "keyword" },
|
||||
{ "void", "type" }, { "complex", "type" }, { "const", "keyword" },
|
||||
{ "union", "keyword" }, { "defer", "keyword" }, { "do", "keyword" },
|
||||
{ "for", "keyword" }, { "macro", "keyword" }, { "remove", "keyword" },
|
||||
{ "bit_set", "keyword" }, { "switch", "keyword" }, { "if", "keyword" },
|
||||
{ "case", "keyword" }, { "foreign", "keyword" }, { "new", "keyword" },
|
||||
{ "inline", "keyword" }, { "import", "keyword" }, { "false", "literal" },
|
||||
{ "assert", "type" }, { "return", "keyword" }, { "true", "literal" },
|
||||
{ "when", "keyword" }, { "using", "keyword" }, { "continue", "keyword" },
|
||||
{ "in", "keyword" }, { "break", "keyword" }, { "else", "keyword" },
|
||||
{ "while", "keyword" }, { "count", "keyword" }, { "delete", "keyword" },
|
||||
|
||||
},
|
||||
@@ -2162,6 +2162,7 @@ void Text::ensureGeometryUpdate() {
|
||||
mLinesWidth.push_back( x );
|
||||
|
||||
x = 0;
|
||||
prevChar = 0;
|
||||
break;
|
||||
case '\r':
|
||||
break;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <eepp/ui/uicodeeditor.hpp>
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
#include <eepp/ui/uitextedit.hpp>
|
||||
#include <eepp/ui/uitextview.hpp>
|
||||
#include <eepp/window/engine.hpp>
|
||||
|
||||
#include <iostream>
|
||||
@@ -193,7 +194,7 @@ UTEST( FontRendering, editorTest ) {
|
||||
WindowBackend::Default, 32, {}, 1, false, true ),
|
||||
UIApplication::Settings( Sys::getProcessPath() + ".." + FileSystem::getOSSlash(), 1 ) );
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
UICodeEditor* editor = UICodeEditor::New();
|
||||
auto* editor = UICodeEditor::New();
|
||||
editor->setPixelsSize( app.getUI()->getPixelsSize() );
|
||||
editor->loadFromFile( "assets/textformat/english.utf8.lf.bom.txt" );
|
||||
SceneManager::instance()->update();
|
||||
@@ -218,7 +219,7 @@ UTEST( FontRendering, textEditTest ) {
|
||||
WindowBackend::Default, 32, {}, 1, false, true ),
|
||||
UIApplication::Settings( Sys::getProcessPath() + ".." + FileSystem::getOSSlash(), 1 ) );
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
UITextEdit* editor = UITextEdit::New();
|
||||
auto* editor = UITextEdit::New();
|
||||
editor->setPixelsSize( app.getUI()->getPixelsSize() );
|
||||
editor->loadFromFile( "assets/textformat/english.utf8.lf.bom.txt" );
|
||||
SceneManager::instance()->update();
|
||||
@@ -235,3 +236,134 @@ UTEST( FontRendering, textEditTest ) {
|
||||
runTest();
|
||||
}
|
||||
}
|
||||
|
||||
UTEST( FontRendering, tabsTest ) {
|
||||
const auto runTest = [&]() {
|
||||
UIApplication app(
|
||||
WindowSettings( 1024, 650, "eepp - Tabs Test", WindowStyle::Default,
|
||||
WindowBackend::Default, 32, {}, 1, false, true ),
|
||||
UIApplication::Settings( Sys::getProcessPath() + ".." + FileSystem::getOSSlash(), 1 ) );
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
auto* editor = UICodeEditor::New();
|
||||
editor->setPixelsSize( app.getUI()->getPixelsSize() );
|
||||
editor->loadFromFile( "assets/fontrendering/tabs_test.txt" );
|
||||
SceneManager::instance()->update();
|
||||
SceneManager::instance()->draw();
|
||||
compareImages( utest_state, utest_result, app.getWindow(),
|
||||
"eepp-editor-monospace-tabs-test" );
|
||||
};
|
||||
|
||||
UTEST_PRINT_STEP( "Text Shaper disabled" );
|
||||
runTest();
|
||||
|
||||
UTEST_PRINT_STEP( "Text Shaper enabled" );
|
||||
{
|
||||
BoolScopedOp op( Text::TextShaperEnabled, true );
|
||||
runTest();
|
||||
}
|
||||
}
|
||||
|
||||
UTEST( FontRendering, tabStopTest ) {
|
||||
const auto runTest = [&]() {
|
||||
UIApplication app(
|
||||
WindowSettings( 1024, 650, "eepp - Tab Stop Test", WindowStyle::Default,
|
||||
WindowBackend::Default, 32, {}, 1, false, true ),
|
||||
UIApplication::Settings( Sys::getProcessPath() + ".." + FileSystem::getOSSlash(), 1 ) );
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
auto* editor = UICodeEditor::New();
|
||||
editor->setTabStops( true );
|
||||
editor->setPixelsSize( app.getUI()->getPixelsSize() );
|
||||
editor->loadFromFile( "assets/fontrendering/tabs_test.txt" );
|
||||
SceneManager::instance()->update();
|
||||
SceneManager::instance()->draw();
|
||||
compareImages( utest_state, utest_result, app.getWindow(),
|
||||
"eepp-editor-monospace-tab-stop-test" );
|
||||
};
|
||||
|
||||
UTEST_PRINT_STEP( "Text Shaper disabled" );
|
||||
runTest();
|
||||
|
||||
UTEST_PRINT_STEP( "Text Shaper enabled" );
|
||||
{
|
||||
BoolScopedOp op( Text::TextShaperEnabled, true );
|
||||
runTest();
|
||||
}
|
||||
}
|
||||
|
||||
UTEST( FontRendering, tabsTextEditTest ) {
|
||||
const auto runTest = [&]() {
|
||||
UIApplication app(
|
||||
WindowSettings( 1024, 650, "eepp - TextEdit - Tabs Test", WindowStyle::Default,
|
||||
WindowBackend::Default, 32, {}, 1, false, true ),
|
||||
UIApplication::Settings( Sys::getProcessPath() + ".." + FileSystem::getOSSlash(), 1 ) );
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
auto* editor = UITextEdit::New();
|
||||
editor->setPixelsSize( app.getUI()->getPixelsSize() );
|
||||
editor->loadFromFile( "assets/fontrendering/tabs_test.txt" );
|
||||
SceneManager::instance()->update();
|
||||
SceneManager::instance()->draw();
|
||||
compareImages( utest_state, utest_result, app.getWindow(), "eepp-text-edit-tabs-test" );
|
||||
};
|
||||
|
||||
UTEST_PRINT_STEP( "Text Shaper disabled" );
|
||||
runTest();
|
||||
|
||||
UTEST_PRINT_STEP( "Text Shaper enabled" );
|
||||
{
|
||||
BoolScopedOp op( Text::TextShaperEnabled, true );
|
||||
runTest();
|
||||
}
|
||||
}
|
||||
|
||||
UTEST( FontRendering, tabStopTextEditTest ) {
|
||||
const auto runTest = [&]() {
|
||||
UIApplication app(
|
||||
WindowSettings( 1024, 650, "eepp - TextEdit - Tab Stop Test", WindowStyle::Default,
|
||||
WindowBackend::Default, 32, {}, 1, false, true ),
|
||||
UIApplication::Settings( Sys::getProcessPath() + ".." + FileSystem::getOSSlash(), 1 ) );
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
auto* editor = UITextEdit::New();
|
||||
editor->setTabStops( true );
|
||||
editor->setPixelsSize( app.getUI()->getPixelsSize() );
|
||||
editor->loadFromFile( "assets/fontrendering/tabs_test.txt" );
|
||||
SceneManager::instance()->update();
|
||||
SceneManager::instance()->draw();
|
||||
compareImages( utest_state, utest_result, app.getWindow(), "eepp-text-edit-tab-stop-test" );
|
||||
};
|
||||
|
||||
UTEST_PRINT_STEP( "Text Shaper disabled" );
|
||||
runTest();
|
||||
|
||||
UTEST_PRINT_STEP( "Text Shaper enabled" );
|
||||
{
|
||||
BoolScopedOp op( Text::TextShaperEnabled, true );
|
||||
runTest();
|
||||
}
|
||||
}
|
||||
|
||||
UTEST( FontRendering, textViewTest ) {
|
||||
const auto runTest = [&]() {
|
||||
UIApplication app( WindowSettings( 1024, 650, "eepp - TextView", WindowStyle::Default,
|
||||
WindowBackend::Default, 32, {}, 1, false, true ),
|
||||
UIApplication::Settings(
|
||||
Sys::getProcessPath() + ".." + FileSystem::getOSSlash(), 1.5f ) );
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
auto* view = UITextView::New();
|
||||
view->setPixelsSize( app.getUI()->getPixelsSize() );
|
||||
std::string file;
|
||||
FileSystem::fileGet( "assets/textformat/english.utf8.lf.bom.txt", file );
|
||||
view->setText( file );
|
||||
SceneManager::instance()->update();
|
||||
SceneManager::instance()->draw();
|
||||
compareImages( utest_state, utest_result, app.getWindow(), "eepp-textview" );
|
||||
};
|
||||
|
||||
UTEST_PRINT_STEP( "Text Shaper disabled" );
|
||||
runTest();
|
||||
|
||||
UTEST_PRINT_STEP( "Text Shaper enabled" );
|
||||
{
|
||||
BoolScopedOp op( Text::TextShaperEnabled, true );
|
||||
runTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user