From b55e45f88e8ae63115f290fc2db847cb4b370c88 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Thu, 18 Jun 2026 11:46:33 +0000 Subject: tests: force the English locale for dolphinmainwindowtest testWindowTitle compares the window title against fixed strings such as "Home" and "Trash". On a machine configured for another language the title comes back translated, for example "Dossier Personnel", and the test fails. Set the language environment variables to English in main(), before QApplication is constructed and before any translation is loaded, so the comparisons are deterministic regardless of the machine's configured language. --- src/tests/dolphinmainwindowtest.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index 1b036436e..ad2543a99 100644 --- a/src/tests/dolphinmainwindowtest.cpp +++ b/src/tests/dolphinmainwindowtest.cpp @@ -519,7 +519,7 @@ void DolphinMainWindowTest::testWindowTitle_data() QTest::addColumn("activeViewUrl"); QTest::addColumn("expectedWindowTitle"); - // TODO: this test should enforce the english locale. + // The English locale is forced in main(), so these titles are compared verbatim. QTest::newRow("home") << QUrl::fromLocalFile(QDir::homePath()) << QStringLiteral("Home"); QTest::newRow("home with trailing slash") << QUrl::fromLocalFile(QStringLiteral("%1/").arg(QDir::homePath())) << QStringLiteral("Home"); QTest::newRow("trash") << QUrl::fromUserInput(QStringLiteral("trash:/")) << QStringLiteral("Trash"); @@ -1534,6 +1534,20 @@ void DolphinMainWindowTest::cleanupTestCase() m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Quit))->trigger(); } -QTEST_MAIN(DolphinMainWindowTest) +int main(int argc, char *argv[]) +{ + // Force the English locale before QApplication and any translation lookup, so that + // tests comparing user-visible strings (such as window titles) do not depend on the + // language configured on the developer's or CI machine. + qputenv("LANG", "C.UTF-8"); + qputenv("LANGUAGE", "en_US"); + qputenv("LC_ALL", "C.UTF-8"); + + QApplication app(argc, argv); + app.setAttribute(Qt::AA_Use96Dpi, true); + QTEST_SET_MAIN_SOURCE_PATH + DolphinMainWindowTest tc; + return QTest::qExec(&tc, argc, argv); +} #include "dolphinmainwindowtest.moc" -- cgit v1.3.1