From 4d31ec78f80d6add09dc80404470cfae7f2b13c7 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Fri, 28 Jan 2022 10:58:14 +0100 Subject: 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. --- autotests/kstandardshortcutwatchertest.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'autotests/kstandardshortcutwatchertest.cpp') 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 #include @@ -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); } -- cgit v1.2.1