From 6de8d406aafa9730ddb7cfd27e9a38102509497a Mon Sep 17 00:00:00 2001 From: Beat Hangartner Date: Wed, 7 Oct 2026 22:59:50 +0200 Subject: [PATCH] Give the toolbar and gesture settings tests their own settings scope tst_toolbarsettings, tst_diagramtoolbarsettings and tst_gesturesettings never set an organization or application name. On macOS and Linux, QSettings then falls back to an "Unknown Organization" file, so the tests pass there. On Windows it has no registry key: every write is dropped and every read gives the default, and nine checks fail. Each test now sets its own organization and application name in initTestCase(), as tst_scriptingsetting and tst_sheetbackgroundsetting already do. That also keeps the tests away from the settings of the account that runs them. Tests only; no change to the app or its files. Co-Authored-By: Claude Opus 5.5 --- tests/qttest/tst_diagramtoolbarsettings.cpp | 6 ++++++ tests/qttest/tst_gesturesettings.cpp | 6 ++++++ tests/qttest/tst_toolbarsettings.cpp | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/tests/qttest/tst_diagramtoolbarsettings.cpp b/tests/qttest/tst_diagramtoolbarsettings.cpp index 9c77cc8d9..87fb12143 100644 --- a/tests/qttest/tst_diagramtoolbarsettings.cpp +++ b/tests/qttest/tst_diagramtoolbarsettings.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -86,6 +87,11 @@ private slots: void initTestCase() { QStandardPaths::setTestModeEnabled(true); + //A scope of this test's own. Without an organization name, + //QSettings on Windows has no registry key: it drops every + //write and reads only defaults. + QCoreApplication::setOrganizationName(QStringLiteral("QElectroTech-tst_diagramtoolbarsettings")); + QCoreApplication::setApplicationName(QStringLiteral("tst_diagramtoolbarsettings")); clearSettings(); //A few of the diagram editor's commands, as it registers them for (const QString &id : {QStringLiteral("diagrameditor.copy"), diff --git a/tests/qttest/tst_gesturesettings.cpp b/tests/qttest/tst_gesturesettings.cpp index b06930ab5..387be1538 100644 --- a/tests/qttest/tst_gesturesettings.cpp +++ b/tests/qttest/tst_gesturesettings.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -64,6 +65,11 @@ private slots: void initTestCase() { QStandardPaths::setTestModeEnabled(true); + //A scope of this test's own. Without an organization name, + //QSettings on Windows has no registry key: it drops every + //write and reads only defaults. + QCoreApplication::setOrganizationName(QStringLiteral("QElectroTech-tst_gesturesettings")); + QCoreApplication::setApplicationName(QStringLiteral("tst_gesturesettings")); QSettings().remove(QStringLiteral("diagrameditor")); addCommand(QStringLiteral("diagrameditor.copy"), QStringLiteral("Copier")); addCommand(QStringLiteral("diagrameditor.cut"), QStringLiteral("Couper")); diff --git a/tests/qttest/tst_toolbarsettings.cpp b/tests/qttest/tst_toolbarsettings.cpp index 184b773d1..d9f90246d 100644 --- a/tests/qttest/tst_toolbarsettings.cpp +++ b/tests/qttest/tst_toolbarsettings.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,11 @@ private slots: void initTestCase() { QStandardPaths::setTestModeEnabled(true); + //A scope of this test's own. Without an organization name, + //QSettings on Windows has no registry key: it drops every + //write and reads only defaults. + QCoreApplication::setOrganizationName(QStringLiteral("QElectroTech-tst_toolbarsettings")); + QCoreApplication::setApplicationName(QStringLiteral("tst_toolbarsettings")); QSettings().remove(QStringLiteral("toolbars")); m_window = new QMainWindow();