void KGlobalShortcutTest::testOverrideMainComponentData() { setupTest("testOverrideMainComponentData"); KComponentData otherComponent("test_component1"); KActionCollection coll((QObject*)NULL); coll.setComponentData(otherComponent); KShortcut cutB; // Action without action collection KAction *action = new KAction("Text For Action A", this); QVERIFY(action->d->componentData == KGlobal::mainComponent()); action->setObjectName("Action A"); action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); QVERIFY(action->d->componentData == KGlobal::mainComponent()); // Action with action collection action->forgetGlobalShortcut(); delete action; action = coll.addAction("Action A"); QVERIFY(action->d->componentData == otherComponent); action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); QVERIFY(action->d->componentData == otherComponent); // cleanup action->forgetGlobalShortcut(); delete coll.takeAction(action); }
void KGlobalShortcutTest::testNotification() { setupTest("testNotification"); // Action without action collection KAction *action = new KAction("Text For Action A", this); QVERIFY(action->d->componentData == KGlobal::mainComponent()); action->setObjectName("Action A"); KShortcut cutB; action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); QVERIFY(action->d->componentData == KGlobal::mainComponent()); // kglobalacceld collects registrations and shows the together. Give it // time to kick in. sleep(2); action->forgetGlobalShortcut(); }
void KGlobalShortcutTest::testComponentAssignment() { // We don't use them here // setupTest(); KComponentData otherComponent("test_component1"); KActionCollection coll((QObject*)NULL); coll.setComponentData(otherComponent); KShortcut cutB; /************************************************************ * Ensure that the actions get a correct component assigned * ************************************************************/ // Action without action collection get the global component { KAction action("Text For Action A", NULL); action.setObjectName("Action C"); QVERIFY(action.d->componentData == KGlobal::mainComponent()); action.setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); QVERIFY(action.d->componentData == KGlobal::mainComponent()); // cleanup action.forgetGlobalShortcut(); } // Action with action collection get the component of the collection { KAction *action = coll.addAction("Action C"); QVERIFY(action->d->componentData == otherComponent); action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); QVERIFY(action->d->componentData == otherComponent); // cleanup action->forgetGlobalShortcut(); delete action; } }