┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMéven Car <[email protected]>2026-06-18 11:46:33 +0000
committerMéven Car <[email protected]>2026-06-18 11:46:33 +0000
commitb55e45f88e8ae63115f290fc2db847cb4b370c88 (patch)
tree61c7239e052e7e665aacee519537b40f1de13647 /src
parent922ccb27fba27328741aafdf6bd7a4258d193e88 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/tests/dolphinmainwindowtest.cpp18
1 files 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<QUrl>("activeViewUrl");
QTest::addColumn<QString>("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"