From eb0b79bfcadf408db3b660f75628be1243207773 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 30 Apr 2024 04:12:15 +0300 Subject: [PATCH] kduei: testing build fix Signed-off-by: Ivailo Monev --- kdeui/tests/kactioncollectiontest.cpp | 42 +++++++++------------------ kdeui/tests/kstandardactiontest.cpp | 10 +++---- kdeui/tests/kstandardshortcuttest.cpp | 15 ---------- kdeui/tests/kstandardshortcuttest.h | 1 - kdeui/tests/kxmlgui_unittest.cpp | 2 +- 5 files changed, 18 insertions(+), 52 deletions(-) diff --git a/kdeui/tests/kactioncollectiontest.cpp b/kdeui/tests/kactioncollectiontest.cpp index e0614fbf..f6e2e597 100644 --- a/kdeui/tests/kactioncollectiontest.cpp +++ b/kdeui/tests/kactioncollectiontest.cpp @@ -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) diff --git a/kdeui/tests/kstandardactiontest.cpp b/kdeui/tests/kstandardactiontest.cpp index 7159515c..fd193c6a 100644 --- a/kdeui/tests/kstandardactiontest.cpp +++ b/kdeui/tests/kstandardactiontest.cpp @@ -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; } diff --git a/kdeui/tests/kstandardshortcuttest.cpp b/kdeui/tests/kstandardshortcuttest.cpp index a86ad807..d294008e 100644 --- a/kdeui/tests/kstandardshortcuttest.cpp +++ b/kdeui/tests/kstandardshortcuttest.cpp @@ -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() ); -} diff --git a/kdeui/tests/kstandardshortcuttest.h b/kdeui/tests/kstandardshortcuttest.h index a370fae2..91be854b 100644 --- a/kdeui/tests/kstandardshortcuttest.h +++ b/kdeui/tests/kstandardshortcuttest.h @@ -32,7 +32,6 @@ private Q_SLOTS: void testLabel(); void testShortcut(); void testFindStdAccel(); - void testRemoveShortcut(); }; diff --git a/kdeui/tests/kxmlgui_unittest.cpp b/kdeui/tests/kxmlgui_unittest.cpp index ed36882b..2036df5e 100644 --- a/kdeui/tests/kxmlgui_unittest.cpp +++ b/kdeui/tests/kxmlgui_unittest.cpp @@ -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 actionList; actionList << action1; client.plugActionList("view_groups_list", actionList);