diff --git a/Telegram/SourceFiles/tests/test_main.cpp b/Telegram/SourceFiles/tests/test_main.cpp index 77315ac081..57b7c391b4 100644 --- a/Telegram/SourceFiles/tests/test_main.cpp +++ b/Telegram/SourceFiles/tests/test_main.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "tests/test_main.h" +#include "base/base_file_utilities.h" #include "base/invoke_queued.h" #include "base/integration.h" #include "ui/effects/animations.h" @@ -171,6 +172,10 @@ int main(int argc, char *argv[]) { auto app = App(argc, argv); app.installNativeEventFilter(&app); +#ifdef Q_OS_MAC + base::RegisterBundledResources(u"test_text.rcc"_q); +#endif // Q_OS_MAC + const auto ratio = app.devicePixelRatio(); const auto useRatio = std::clamp(qCeil(ratio), 1, 3); style::SetDevicePixelRatio(useRatio); diff --git a/Telegram/SourceFiles/tests/test_main.h b/Telegram/SourceFiles/tests/test_main.h index 0652a460d9..e4c06acef7 100644 --- a/Telegram/SourceFiles/tests/test_main.h +++ b/Telegram/SourceFiles/tests/test_main.h @@ -36,6 +36,12 @@ void test(not_null window, not_null widget); }; class App final : public QApplication, public QAbstractNativeEventFilter { +private: + auto createEventNestingLevel() { + incrementEventNestingLevel(); + return gsl::finally([=] { decrementEventNestingLevel(); }); + } + public: using QApplication::QApplication; @@ -56,11 +62,6 @@ private: FnMut callable; }; - auto createEventNestingLevel() { - incrementEventNestingLevel(); - return gsl::finally([=] { decrementEventNestingLevel(); }); - } - void checkForEmptyLoopNestingLevel(); void processPostponedCalls(int level); void incrementEventNestingLevel(); diff --git a/Telegram/SourceFiles/tests/test_text.cpp b/Telegram/SourceFiles/tests/test_text.cpp index fa2db5eb39..e5f44ede94 100644 --- a/Telegram/SourceFiles/tests/test_text.cpp +++ b/Telegram/SourceFiles/tests/test_text.cpp @@ -438,7 +438,7 @@ void test(not_null window, not_null body) { Expects(!HasEntityType(formulaMime.rich.entities, EntityType::CustomEmoji)); Expects(formulaMime.tags.size() == 1); const auto expectedFormulaTag = TextForMimeDataTag{ - .offset = formulaPosition, + .offset = int(formulaPosition), .length = int(formulaReplacementText.size()), .id = Ui::InputField::kTagIvMath, }; @@ -464,6 +464,46 @@ void test(not_null window, not_null body) { Expects(!formulaText->isOnlyCustomEmoji()); Expects(!formulaText->isIsolatedEmoji()); + auto longFormulaSource = QString(); + while (longFormulaSource.size() <= 4096) { + longFormulaSource.append(u"\\alpha+\\beta "_q); + } + auto longFormulaData = TextWithEntities(); + longFormulaData.append(u"Before "_q); + const auto longFormulaPosition = longFormulaData.text.size(); + longFormulaData.append(longFormulaSource); + longFormulaData.entities.push_back(EntityInText( + EntityType::CustomEmoji, + longFormulaPosition, + longFormulaSource.size(), + formulaEntityData)); + longFormulaData.append(u" after"_q); + const auto longFormulaText = Ui::Text::String( + st::defaultTextStyle, + longFormulaData, + kMarkupTextOptions, + scale(64), + context); + Expects(longFormulaText.maxWidth() >= formulaImage.width()); + Expects(longFormulaText.countHeight(scale(200)) > 0); + Expects( + longFormulaText.toString() + == u"Before "_q + formulaReplacementText + u" after"_q); + const auto longFormulaRender = RenderTextOffscreen( + longFormulaText, + scale(200)); + Expects(HasPaintedPixels(longFormulaRender)); + + const auto longSpacedEmojiText = Ui::Text::String( + st::defaultTextStyle, + QString::fromUtf8("\xF0\x9F\x98\x80") + + QString(4100, QChar(' ')) + + u"x"_q, + kDefaultTextOptions, + scale(64)); + Expects(longSpacedEmojiText.maxWidth() > 0); + Expects(longSpacedEmojiText.countHeight(scale(200)) > 0); + auto controlData = TextWithEntities(); controlData.append(QChar::ObjectReplacementCharacter); controlData.entities.push_back(EntityInText( diff --git a/Telegram/cmake/tests.cmake b/Telegram/cmake/tests.cmake index 4f2e5651b6..a647ed9463 100644 --- a/Telegram/cmake/tests.cmake +++ b/Telegram/cmake/tests.cmake @@ -42,3 +42,14 @@ set_target_properties(test_text PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINA add_dependencies(Telegram test_text) target_prepare_qrc(test_text) + +if (APPLE) + add_custom_command(TARGET test_text POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory + "$/Contents/Resources" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_BINARY_DIR}/test_text.rcc" + "${CMAKE_BINARY_DIR}/lib_ui.rcc" + "$/Contents/Resources/" + ) +endif() diff --git a/Telegram/lib_ui b/Telegram/lib_ui index df7d2bd279..07cea400e2 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit df7d2bd2792c4d21cfa68b6221d8361940c7ebf2 +Subproject commit 07cea400e2e6b2a7c08a289472bf5976a77e6500