From kde-commits Thu Dec 09 12:36:15 2010 From: David Faure Date: Thu, 09 Dec 2010 12:36:15 +0000 To: kde-commits Subject: KDE/kdelibs/kdeui/tests Message-Id: <20101209123615.246CDAC8A5 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129189820929029 SVN commit 1204885 by dfaure: Skip the tests that need kglobalaccel, if kdebase is not installed. M +19 -0 kglobalshortcuttest.cpp M +2 -0 kglobalshortcuttest.h --- trunk/KDE/kdelibs/kdeui/tests/kglobalshortcuttest.cpp #1204884:1204885 @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -48,6 +49,11 @@ //we need a KComponentData and a GUI so that the implementation can grab keys QTEST_KDEMAIN( KGlobalShortcutTest, GUI ) +void KGlobalShortcutTest::initTestCase() +{ + m_daemonInstalled = KService::serviceByDesktopName("kglobalaccel") != 0; +} + void KGlobalShortcutTest::setupTest(QString id) { if (m_actionA) { @@ -90,6 +96,9 @@ { setupTest("testSetShortcut"); + if (!m_daemonInstalled) + QSKIP("kglobalaccel not installed", SkipAll); + // Just ensure that the desired values are set for both actions KShortcut cutA(sequenceA, sequenceB); QCOMPARE(m_actionA->globalShortcut(), cutA); @@ -107,6 +116,8 @@ { // Skip this. The above testcase hasn't changed the actions setupTest("testFindActionByKey"); + if (!m_daemonInstalled) + QSKIP("kglobalaccel not installed", SkipAll); QList actionId = KGlobalAccel::self()->getGlobalShortcutsByKey(sequenceB); QCOMPARE(actionId.size(), 1); @@ -135,6 +146,8 @@ // Skip this. The above testcase hasn't changed the actions setupTest("testChangeShortcut"); + if (!m_daemonInstalled) + QSKIP("kglobalaccel not installed", SkipAll); // Change the shortcut KShortcut newCutA(sequenceC); m_actionA->setGlobalShortcut(newCutA, KAction::ActiveShortcut, KAction::NoAutoloading); @@ -166,6 +179,8 @@ void KGlobalShortcutTest::testStealShortcut() { setupTest("testStealShortcut"); + if (!m_daemonInstalled) + QSKIP("kglobalaccel not installed", SkipAll); // Steal a shortcut from an action. First ensure the initial state is // correct @@ -221,6 +236,8 @@ void KGlobalShortcutTest::testListActions() { setupTest("testListActions"); + if (!m_daemonInstalled) + QSKIP("kglobalaccel not installed", SkipAll); // As in kdebase/workspace/kcontrol/keys/globalshortcuts.cpp KGlobalAccel *kga = KGlobalAccel::self(); @@ -388,6 +405,8 @@ // Ensure that forgetGlobalShortcut can be called on any action. KAction a("Test", NULL); a.forgetGlobalShortcut(); + if (!m_daemonInstalled) + QSKIP("kglobalaccel not installed", SkipAll); // We forget these two shortcuts and check that the component is gone // after that. If not it can mean the forgetGlobalShortcut() call is --- trunk/KDE/kdelibs/kdeui/tests/kglobalshortcuttest.h #1204884:1204885 @@ -30,6 +30,7 @@ { Q_OBJECT private Q_SLOTS: + void initTestCase(); void testSetShortcut(); void testFindActionByKey(); void testChangeShortcut(); @@ -53,6 +54,7 @@ KAction *m_actionA; KAction *m_actionB; + bool m_daemonInstalled; }; #endif