diff options
author | David Redondo <kde@david-redondo.de> | 2022-01-28 10:58:14 +0100 |
---|---|---|
committer | David Redondo <kde@david-redondo.de> | 2022-02-01 14:06:35 +0100 |
commit | 4d31ec78f80d6add09dc80404470cfae7f2b13c7 (patch) | |
tree | 1660347401a2a59e8d364a7e90f71a44288f0adf /autotests/kstandardshortcutwatchertest.cpp | |
parent | 724966b63f48b8b8fa8891f82924328f3f73fad0 (diff) | |
download | kconfig-4d31ec78f80d6add09dc80404470cfae7f2b13c7.tar.gz kconfig-4d31ec78f80d6add09dc80404470cfae7f2b13c7.tar.bz2 |
Don't use saveShortcut for setting up tests
It will trigger side effects like triggering the dbus signal
which depending on the timing may be delivered only in the next
test case causing an unexpected change signal emission.
Diffstat (limited to 'autotests/kstandardshortcutwatchertest.cpp')
-rw-r--r-- | autotests/kstandardshortcutwatchertest.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/autotests/kstandardshortcutwatchertest.cpp b/autotests/kstandardshortcutwatchertest.cpp index f20fc635..64d55d5c 100644 --- a/autotests/kstandardshortcutwatchertest.cpp +++ b/autotests/kstandardshortcutwatchertest.cpp @@ -7,6 +7,7 @@ #include "kstandardshortcutwatcher.h" #include "kconfiggroup.h" #include "ksharedconfig.h" +#include "kstandardshortcut_p.h" #include <QSignalSpy> #include <QStandardPaths> @@ -35,7 +36,10 @@ void KStandardShortcutWatcherTest::initTestCase() void KStandardShortcutWatcherTest::init() { - KStandardShortcut::saveShortcut(KStandardShortcut::Open, KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::Open)); + KConfigGroup group(KSharedConfig::openConfig(), "Shortcuts"); + group.writeEntry("Open", QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::Open)), KConfig::Global); + group.sync(); + KStandardShortcut::initialize(KStandardShortcut::Open); } void KStandardShortcutWatcherTest::testSignal() @@ -54,7 +58,7 @@ void KStandardShortcutWatcherTest::testDataUpdated() // Writing manually to forego automatic update in saveShortcut() KConfigGroup group(KSharedConfig::openConfig(), "Shortcuts"); group.writeEntry("Open", QKeySequence::listToString(newShortcut), KConfig::Global | KConfig::Notify); - group.config()->sync(); + group.sync(); QTRY_COMPARE(signalSpy.count(), 1); QCOMPARE(KStandardShortcut::open(), newShortcut); } |