kduei: testing build fix

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-30 04:12:15 +03:00
parent e13f945e89
commit eb0b79bfca
5 changed files with 18 additions and 52 deletions

View file

@ -85,13 +85,8 @@ void tst_KActionCollection::writeSettings()
{
KConfigGroup cfg = clearConfig();
KShortcut defaultShortcut;
defaultShortcut.setPrimary(Qt::Key_A);
defaultShortcut.setAlternate(Qt::Key_B);
KShortcut temporaryShortcut;
temporaryShortcut.setPrimary(Qt::Key_C);
temporaryShortcut.setAlternate(Qt::Key_D);
QKeySequence defaultShortcut = QKeySequence(Qt::Key_A, Qt::Key_B);
QKeySequence temporaryShortcut = QKeySequence(Qt::Key_C, Qt::Key_D);
KAction *actionWithDifferentShortcut = new KAction(this);
actionWithDifferentShortcut->setShortcut(defaultShortcut, KAction::DefaultShortcut);
@ -117,7 +112,7 @@ void tst_KActionCollection::writeSettings()
collection->writeSettings(&cfg);
QCOMPARE(cfg.readEntry("actionWithDifferentShortcut", QString()), KShortcut(actionWithDifferentShortcut->shortcut()).toString());
QCOMPARE(cfg.readEntry("actionWithDifferentShortcut", QString()), actionWithDifferentShortcut->shortcut().toString());
QCOMPARE(cfg.readEntry("immutableAction", QString()), QString());
QCOMPARE(cfg.readEntry("actionWithSameShortcut", QString()), QString());
QCOMPARE(cfg.readEntry("actionToDelete", QString()), QString());
@ -129,13 +124,8 @@ void tst_KActionCollection::readSettings()
{
KConfigGroup cfg = clearConfig();
KShortcut defaultShortcut;
defaultShortcut.setPrimary(Qt::Key_A);
defaultShortcut.setAlternate(Qt::Key_B);
KShortcut temporaryShortcut;
temporaryShortcut.setPrimary(Qt::Key_C);
temporaryShortcut.setAlternate(Qt::Key_D);
QKeySequence defaultShortcut = QKeySequence(Qt::Key_A, Qt::Key_B);
QKeySequence temporaryShortcut = QKeySequence(Qt::Key_C, Qt::Key_D);
cfg.writeEntry("normalAction", defaultShortcut.toString());
cfg.writeEntry("immutable", defaultShortcut.toString());
@ -154,14 +144,14 @@ void tst_KActionCollection::readSettings()
collection->addAction("empty", empty);
empty->setShortcut(temporaryShortcut, KAction::ActiveShortcut);
empty->setShortcut(defaultShortcut, KAction::DefaultShortcut);
QCOMPARE(KShortcut(empty->shortcut()).toString(), temporaryShortcut.toString());
QCOMPARE(empty->shortcut().toString(), temporaryShortcut.toString());
collection->readSettings(&cfg);
QCOMPARE(KShortcut(normal->shortcut()).toString(), defaultShortcut.toString());
QCOMPARE(KShortcut(empty->shortcut()).toString(), defaultShortcut.toString());
QCOMPARE(normal->shortcut().toString(), defaultShortcut.toString());
QCOMPARE(empty->shortcut().toString(), defaultShortcut.toString());
QCOMPARE(KShortcut(immutable->shortcut()).toString(), temporaryShortcut.toString());
QCOMPARE(immutable->shortcut().toString(), temporaryShortcut.toString());
qDeleteAll(collection->actions());
}
@ -224,17 +214,11 @@ void tst_KActionCollection::testSetShortcuts()
{
KAction *action = new KAction(i18n("Next Unread &Folder"), this);
collection->addAction("go_next_unread_folder", action);
action->setShortcut(QKeySequence(Qt::ALT+Qt::Key_Plus));
KShortcut shortcut = KShortcut(action->shortcut());
shortcut.setAlternate( QKeySequence( Qt::CTRL+Qt::Key_Plus ) );
action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Plus));
QKeySequence shortcut = action->shortcut();
shortcut = QKeySequence(shortcut[0], Qt::CTRL + Qt::Key_Plus);
action->setShortcut( shortcut );
QCOMPARE(action->shortcut().toString(), QString("Alt++; Ctrl++"));
// Simpler way:
KShortcut shortcut2;
shortcut2.setPrimary( QKeySequence( Qt::ALT+Qt::Key_Plus ) );
shortcut2.setAlternate( QKeySequence( Qt::CTRL+Qt::Key_Plus ) );
QCOMPARE(shortcut2.toString(), QString("Alt++; Ctrl++"));
QCOMPARE(action->shortcut().toString(), QString("Alt++, Ctrl++"));
}
QTEST_KDEMAIN(tst_KActionCollection, GUI)

View file

@ -44,18 +44,16 @@ void tst_KStandardAction::implicitInsertionUsingCut()
void tst_KStandardAction::shortcutForActionId()
{
KShortcut stdShortcut = KStandardShortcut::shortcut(KStandardShortcut::Cut);
QKeySequence stdShortcut = KStandardShortcut::shortcut(KStandardShortcut::Cut);
KAction *cut = KStandardAction::cut(NULL);
KShortcut actShortcut = cut->shortcut();
QVERIFY(stdShortcut.primary() == actShortcut.primary());
QVERIFY(actShortcut.alternate() == actShortcut.alternate());
QKeySequence actShortcut = cut->shortcut();
QCOMPARE(stdShortcut.toString(), actShortcut.toString());
delete cut;
cut = KStandardAction::create(KStandardAction::Cut, NULL, NULL, NULL);
actShortcut = cut->shortcut();
QVERIFY(stdShortcut.primary() == actShortcut.primary());
QVERIFY(actShortcut.alternate() == actShortcut.alternate());
QCOMPARE(stdShortcut.toString(), actShortcut.toString());
delete cut;
}

View file

@ -58,18 +58,3 @@ void KStandardShortcutTest::testFindStdAccel()
QCOMPARE( KStandardShortcut::find( QString( "Ctrl+F" ) ), KStandardShortcut::Find );
QCOMPARE( KStandardShortcut::find( QString( "Ctrl+Shift+Alt+G" ) ), KStandardShortcut::AccelNone );
}
void KStandardShortcutTest::testRemoveShortcut()
{
KShortcut cutShortCut = KStandardShortcut::shortcut( KStandardShortcut::Cut );
cutShortCut.remove( Qt::SHIFT + Qt::Key_Delete, KShortcut::KeepEmpty );
cutShortCut.remove( Qt::CTRL + Qt::Key_X, KShortcut::KeepEmpty );
//qDebug( "%s", qPrintable( cutShortCut.toString() ) );
QVERIFY( cutShortCut.isEmpty() );
cutShortCut = KStandardShortcut::shortcut( KStandardShortcut::Cut );
//remove primary shortcut. We expect the alternate to become primary.
cutShortCut.remove( Qt::CTRL + Qt::Key_X, KShortcut::RemoveEmpty );
QVERIFY( cutShortCut.primary() == QKeySequence(Qt::SHIFT + Qt::Key_Delete) );
QVERIFY( cutShortCut.alternate().isEmpty() );
}

View file

@ -32,7 +32,6 @@ private Q_SLOTS:
void testLabel();
void testShortcut();
void testFindStdAccel();
void testRemoveShortcut();
};

View file

@ -618,7 +618,7 @@ void KXmlGui_UnitTest::testActionListAndSeparator()
KAction* action1 = new KAction(this);
action1->setObjectName("action1");
action1->setShortcut(KShortcut("Ctrl+2"));
action1->setShortcut(QKeySequence("Ctrl+2"));
QList<QAction*> actionList;
actionList << action1;
client.plugActionList("view_groups_list", actionList);