summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel')
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp60
-rw-r--r--tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp65
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp776
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp154
4 files changed, 583 insertions, 472 deletions
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 3d68e42baf..0d62c2cd4b 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -70,7 +70,7 @@ private slots:
void shortcutFromKeyEvent(); // QTBUG-48325
private:
- int m_lastEventType;
+ QEvent::Type m_lastEventType;
const int m_keyboardScheme;
QAction *m_lastAction;
};
@@ -82,7 +82,7 @@ tst_QAction::tst_QAction()
void tst_QAction::init()
{
- m_lastEventType = 0;
+ m_lastEventType = QEvent::None;
m_lastAction = nullptr;
}
@@ -94,23 +94,23 @@ void tst_QAction::cleanup()
// Testing get/set functions
void tst_QAction::getSetCheck()
{
- QAction obj1(0);
+ QAction obj1(nullptr);
// QActionGroup * QAction::actionGroup()
// void QAction::setActionGroup(QActionGroup *)
- QActionGroup *var1 = new QActionGroup(0);
+ QActionGroup *var1 = new QActionGroup(nullptr);
obj1.setActionGroup(var1);
QCOMPARE(var1, obj1.actionGroup());
- obj1.setActionGroup((QActionGroup *)0);
- QCOMPARE((QActionGroup *)0, obj1.actionGroup());
+ obj1.setActionGroup(nullptr);
+ QCOMPARE(obj1.actionGroup(), nullptr);
delete var1;
// QMenu * QAction::menu()
// void QAction::setMenu(QMenu *)
- QMenu *var2 = new QMenu(0);
+ QMenu *var2 = new QMenu(nullptr);
obj1.setMenu(var2);
QCOMPARE(var2, obj1.menu());
- obj1.setMenu((QMenu *)0);
- QCOMPARE((QMenu *)0, obj1.menu());
+ obj1.setMenu(nullptr);
+ QCOMPARE(obj1.menu(), nullptr);
delete var2;
QCOMPARE(obj1.priority(), QAction::NormalPriority);
@@ -148,7 +148,7 @@ void tst_QAction::setText()
{
QFETCH(QString, text);
- QAction action(0);
+ QAction action(nullptr);
action.setText(text);
QCOMPARE(action.text(), text);
@@ -161,7 +161,7 @@ void tst_QAction::setIconText()
{
QFETCH(QString, iconText);
- QAction action(0);
+ QAction action(nullptr);
action.setIconText(iconText);
QCOMPARE(action.iconText(), iconText);
@@ -171,7 +171,7 @@ void tst_QAction::setIconText()
void tst_QAction::setUnknownFont() // QTBUG-42728
{
- QAction action(0);
+ QAction action(nullptr);
QFont font("DoesNotExist", 11);
action.setFont(font);
@@ -182,17 +182,17 @@ void tst_QAction::setUnknownFont() // QTBUG-42728
void tst_QAction::updateState(QActionEvent *e)
{
if (!e) {
- m_lastEventType = 0;
- m_lastAction = 0;
+ m_lastEventType = QEvent::None;
+ m_lastAction = nullptr;
} else {
- m_lastEventType = (int)e->type();
+ m_lastEventType = e->type();
m_lastAction = e->action();
}
}
void tst_QAction::actionEvent()
{
- QAction a(0);
+ QAction a(nullptr);
a.setText("action text");
// add action
@@ -202,33 +202,33 @@ void tst_QAction::actionEvent()
testWidget.addAction(&a);
qApp->processEvents();
- QCOMPARE(m_lastEventType, (int)QEvent::ActionAdded);
+ QCOMPARE(m_lastEventType, QEvent::ActionAdded);
QCOMPARE(m_lastAction, &a);
// change action
a.setText("new action text");
qApp->processEvents();
- QCOMPARE(m_lastEventType, (int)QEvent::ActionChanged);
+ QCOMPARE(m_lastEventType, QEvent::ActionChanged);
QCOMPARE(m_lastAction, &a);
// remove action
testWidget.removeAction(&a);
qApp->processEvents();
- QCOMPARE(m_lastEventType, (int)QEvent::ActionRemoved);
+ QCOMPARE(m_lastEventType, QEvent::ActionRemoved);
QCOMPARE(m_lastAction, &a);
}
//basic testing of standard keys
void tst_QAction::setStandardKeys()
{
- QAction act(0);
+ QAction act(nullptr);
act.setShortcut(QKeySequence("CTRL+L"));
QList<QKeySequence> list;
act.setShortcuts(list);
act.setShortcuts(QKeySequence::Copy);
- QCOMPARE(act.shortcut(), act.shortcuts().first());
+ QCOMPARE(act.shortcut(), act.shortcuts().constFirst());
QList<QKeySequence> expected;
const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C"));
@@ -263,7 +263,7 @@ void tst_QAction::alternateShortcuts()
QList<QKeySequence> shlist = QList<QKeySequence>() << QKeySequence("CTRL+P") << QKeySequence("CTRL+A");
act.setShortcuts(shlist);
- QSignalSpy spy(&act, SIGNAL(triggered()));
+ QSignalSpy spy(&act, &QAction::triggered);
act.setAutoRepeat(true);
QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier);
@@ -322,7 +322,7 @@ void tst_QAction::enabledVisibleInteraction()
testWidget.show();
QApplication::setActiveWindow(&testWidget);
- QAction act(0);
+ QAction act(nullptr);
// check defaults
QVERIFY(act.isEnabled());
QVERIFY(act.isVisible());
@@ -370,7 +370,7 @@ void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
{
// test without a group
const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", nullptr));
- QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), SIGNAL(triggered(bool)));
+ QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), QOverload<bool>::of(&QAction::triggered));
QCOMPARE(spyWithoutGroup.count(), 0);
actionWithoutGroup->trigger();
// signal should be emitted
@@ -388,7 +388,7 @@ void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
void tst_QAction::task229128TriggeredSignalWhenInActiongroup()
{
- QActionGroup ag(0);
+ QActionGroup ag(nullptr);
QAction *action = new QAction("Test", &ag);
QAction *checkedAction = new QAction("Test 2", &ag);
ag.addAction(action);
@@ -397,8 +397,8 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup()
checkedAction->setCheckable(true);
checkedAction->setChecked(true);
- QSignalSpy actionSpy(checkedAction, SIGNAL(triggered(bool)));
- QSignalSpy actionGroupSpy(&ag, SIGNAL(triggered(QAction*)));
+ QSignalSpy actionSpy(checkedAction, QOverload<bool>::of(&QAction::triggered));
+ QSignalSpy actionGroupSpy(&ag, QOverload<QAction*>::of(&QActionGroup::triggered));
QCOMPARE(actionGroupSpy.count(), 0);
QCOMPARE(actionSpy.count(), 0);
checkedAction->trigger();
@@ -513,10 +513,10 @@ void tst_QAction::disableShortcutsWithBlockedWidgets()
class ShortcutOverrideWidget : public QWidget
{
public:
- ShortcutOverrideWidget(QWidget *parent = 0) : QWidget(parent), shortcutOverrideCount(0) {}
- int shortcutOverrideCount;
+ using QWidget::QWidget;
+ int shortcutOverrideCount = 0;
protected:
- bool event(QEvent *e)
+ bool event(QEvent *e) override
{
if (e->type() == QEvent::ShortcutOverride)
++shortcutOverrideCount;
diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
index 0ba3cedf16..524040d003 100644
--- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
+++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
@@ -41,6 +41,7 @@ private slots:
void enabledPropagation();
void visiblePropagation();
void exclusive();
+ void exclusiveOptional();
void separators();
void testActionInTwoQActionGroup();
void unCheckCurrentAction();
@@ -48,11 +49,11 @@ private slots:
void tst_QActionGroup::enabledPropagation()
{
- QActionGroup testActionGroup( 0 );
+ QActionGroup testActionGroup(nullptr);
QAction* childAction = new QAction( &testActionGroup );
QAction* anotherChildAction = new QAction( &testActionGroup );
- QAction* freeAction = new QAction(0);
+ QAction* freeAction = new QAction(nullptr);
QVERIFY( testActionGroup.isEnabled() );
QVERIFY( childAction->isEnabled() );
@@ -87,11 +88,11 @@ void tst_QActionGroup::enabledPropagation()
void tst_QActionGroup::visiblePropagation()
{
- QActionGroup testActionGroup( 0 );
+ QActionGroup testActionGroup(nullptr);
QAction* childAction = new QAction( &testActionGroup );
QAction* anotherChildAction = new QAction( &testActionGroup );
- QAction* freeAction = new QAction(0);
+ QAction* freeAction = new QAction(nullptr);
QVERIFY( testActionGroup.isVisible() );
QVERIFY( childAction->isVisible() );
@@ -124,7 +125,7 @@ void tst_QActionGroup::visiblePropagation()
void tst_QActionGroup::exclusive()
{
- QActionGroup group(0);
+ QActionGroup group(nullptr);
group.setExclusive(false);
QVERIFY( !group.isExclusive() );
@@ -151,6 +152,52 @@ void tst_QActionGroup::exclusive()
QVERIFY( !actThree->isChecked() );
}
+void tst_QActionGroup::exclusiveOptional()
+{
+ QActionGroup group(0);
+ group.setExclusive(true);
+ QVERIFY( group.isExclusive() );
+
+ QAction* actOne = new QAction( &group );
+ actOne->setCheckable( true );
+ QAction* actTwo = new QAction( &group );
+ actTwo->setCheckable( true );
+ QAction* actThree = new QAction( &group );
+ actThree->setCheckable( true );
+
+ QVERIFY( !actOne->isChecked() );
+ QVERIFY( !actTwo->isChecked() );
+ QVERIFY( !actThree->isChecked() );
+
+ actOne->trigger();
+ QVERIFY( actOne->isChecked() );
+ QVERIFY( !actTwo->isChecked() );
+ QVERIFY( !actThree->isChecked() );
+
+ actOne->trigger();
+ QVERIFY( actOne->isChecked() );
+ QVERIFY( !actTwo->isChecked() );
+ QVERIFY( !actThree->isChecked() );
+
+ group.setExclusionPolicy( QActionGroup::ExclusionPolicy::ExclusiveOptional );
+ QVERIFY( group.isExclusive() );
+
+ actOne->trigger();
+ QVERIFY( !actOne->isChecked() );
+ QVERIFY( !actTwo->isChecked() );
+ QVERIFY( !actThree->isChecked() );
+
+ actTwo->trigger();
+ QVERIFY( !actOne->isChecked() );
+ QVERIFY( actTwo->isChecked() );
+ QVERIFY( !actThree->isChecked() );
+
+ actTwo->trigger();
+ QVERIFY( !actOne->isChecked() );
+ QVERIFY( !actTwo->isChecked() );
+ QVERIFY( !actThree->isChecked() );
+}
+
void tst_QActionGroup::separators()
{
QMainWindow mw;
@@ -168,7 +215,7 @@ void tst_QActionGroup::separators()
menu.addActions(actGroup.actions());
- QCOMPARE((int)menu.actions().size(), 2);
+ QCOMPARE(menu.actions().size(), 2);
const auto removeActions = [&menu](const QList<QAction *> &actions) {
for (QAction *action : actions)
@@ -176,14 +223,14 @@ void tst_QActionGroup::separators()
};
removeActions(actGroup.actions());
- QCOMPARE((int)menu.actions().size(), 0);
+ QCOMPARE(menu.actions().size(), 0);
action = new QAction(&actGroup);
action->setText("test two");
menu.addActions(actGroup.actions());
- QCOMPARE((int)menu.actions().size(), 3);
+ QCOMPARE(menu.actions().size(), 3);
}
void tst_QActionGroup::testActionInTwoQActionGroup()
@@ -203,7 +250,7 @@ void tst_QActionGroup::testActionInTwoQActionGroup()
void tst_QActionGroup::unCheckCurrentAction()
{
- QActionGroup group(0);
+ QActionGroup group(nullptr);
QAction action1(&group) ,action2(&group);
action1.setCheckable(true);
action2.setCheckable(true);
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index b78287f84b..8c262ff3a5 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -30,6 +30,8 @@
#include <QtTest/QtTest>
#include <qapplication.h>
#include <qtextedit.h>
+#include <qlineedit.h>
+#include <qcompleter.h>
#include <qpushbutton.h>
#include <qmainwindow.h>
#include <qstatusbar.h>
@@ -39,7 +41,6 @@
#include <qshortcut.h>
#include <qscreen.h>
-class AccelForm;
QT_BEGIN_NAMESPACE
class QMainWindow;
class QTextEdit;
@@ -49,15 +50,14 @@ class tst_QShortcut : public QObject
{
Q_OBJECT
public:
- tst_QShortcut();
- virtual ~tst_QShortcut();
-
enum Action {
SetupAccel,
TestAccel,
- ClearAll
- } currentAction;
+ ClearAll,
+ TestEnd
+ };
+ Q_ENUM(Action)
enum Widget {
NoWidget,
@@ -68,8 +68,8 @@ public:
TriggerSlot5,
TriggerSlot6,
TriggerSlot7,
- SendKeyEvent
};
+ Q_ENUM(Widget)
enum Result {
NoResult,
@@ -82,7 +82,8 @@ public:
Slot7Triggered,
SentKeyEvent,
Ambiguous
- } currentResult;
+ } currentResult = NoResult;
+ Q_ENUM(Result)
public slots:
void slotTrig1() { currentResult = Slot1Triggered; }
@@ -99,16 +100,9 @@ public slots:
void ambigSlot5() { currentResult = Ambiguous; ambigResult = Slot5Triggered; }
void ambigSlot6() { currentResult = Ambiguous; ambigResult = Slot6Triggered; }
void ambigSlot7() { currentResult = Ambiguous; ambigResult = Slot7Triggered; }
- void statusMessage( const QString& message ) { sbText = message; }
- void shortcutDestroyed(QObject* obj);
- void sendKeyEvent() { sendKeyEvents(edit, Qt::CTRL + Qt::Key_B, 0); currentResult = SentKeyEvent; }
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void cleanup() { QCOMPARE(QApplication::topLevelWidgets().size(), 1); }
private slots:
+ void cleanup();
void number_data();
void number();
void text_data();
@@ -120,34 +114,25 @@ private slots:
void unicodeCompare();
void context();
void duplicatedShortcutOverride();
+ void shortcutToFocusProxy();
protected:
static Qt::KeyboardModifiers toButtons( int key );
void defElements();
- void clearAllShortcuts();
- QShortcut *setupShortcut(int testWidget, const QKeySequence &ks);
- QShortcut *setupShortcut(int testWidget, const QString &txt, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0);
-
- QShortcut *setupShortcut(QWidget *parent, const char *name, int testWidget, const QString &txt, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0);
- QShortcut *setupShortcut(QWidget *parent, const char *name, int testWidget, const QKeySequence &ks, Qt::ShortcutContext context = Qt::WindowShortcut);
+ QShortcut *setupShortcut(QWidget *parent, const QString &name, const QKeySequence &ks,
+ Qt::ShortcutContext context = Qt::WindowShortcut);
+ QShortcut *setupShortcut(QWidget *parent, const QString &name, Widget testWidget,
+ const QKeySequence &ks, Qt::ShortcutContext context = Qt::WindowShortcut);
- void sendKeyEvents(QWidget *w, int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0, int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0);
- void sendKeyEvents(int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0, int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0);
+ static void sendKeyEvents(QWidget *w, int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0,
+ int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0);
void testElement();
- QMainWindow *mainW;
- QList<QShortcut*> shortcuts;
- QTextEdit *edit;
- QString sbText;
Result ambigResult;
};
-Q_DECLARE_METATYPE(tst_QShortcut::Widget);
-Q_DECLARE_METATYPE(tst_QShortcut::Result);
-Q_DECLARE_METATYPE(tst_QShortcut::Action);
-
class TestEdit : public QTextEdit
{
Q_OBJECT
@@ -159,7 +144,8 @@ public:
}
protected:
- bool event(QEvent *e) {
+ bool event(QEvent *e) override
+ {
// Make testedit allow any Ctrl+Key as shortcut
if (e->type() == QEvent::ShortcutOverride) {
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
@@ -192,33 +178,28 @@ protected:
}
};
-tst_QShortcut::tst_QShortcut(): mainW( 0 )
+class MainWindow : public QMainWindow
{
-}
+public:
+ MainWindow();
-tst_QShortcut::~tst_QShortcut()
-{
- clearAllShortcuts();
-}
+ TestEdit *testEdit() const { return m_testEdit; }
+
+private:
+ TestEdit *m_testEdit;
+};
-void tst_QShortcut::initTestCase()
+MainWindow::MainWindow()
{
- currentResult = NoResult;
- mainW = new QMainWindow(0);
- mainW->setWindowFlags(Qt::X11BypassWindowManagerHint);
- edit = new TestEdit(mainW, "test_edit");
- mainW->setFixedSize( 200, 200 );
- mainW->setCentralWidget( edit );
- mainW->show();
- mainW->activateWindow();
- QVERIFY(QTest::qWaitForWindowActive(mainW));
- connect( mainW->statusBar(), SIGNAL(messageChanged(QString)),
- this, SLOT(statusMessage(QString)) );
+ setWindowFlags(Qt::X11BypassWindowManagerHint);
+ m_testEdit = new TestEdit(this, "test_edit");
+ setCentralWidget(m_testEdit);
+ setFixedSize(200, 200);
}
-void tst_QShortcut::cleanupTestCase()
+void tst_QShortcut::cleanup()
{
- delete mainW;
+ QVERIFY(QApplication::topLevelWidgets().size() <= 1); // The data driven tests keep a widget around
}
Qt::KeyboardModifiers tst_QShortcut::toButtons( int key )
@@ -273,7 +254,7 @@ void tst_QShortcut::number_data()
defElements();
// Clear all
- QTest::newRow("N00 - clear") << ClearAll << NoWidget <<QString("")<<0<<0<<0<<0<<0<<0<<0<<0<<NoResult;
+ QTest::newRow("N00 - clear") << ClearAll << NoWidget <<QString()<<0<<0<<0<<0<<0<<0<<0<<0<<NoResult;
//===========================================
// [Shift + key] on non-shift shortcuts testing
@@ -285,15 +266,15 @@ void tst_QShortcut::number_data()
Shift + Qt::Key_Plus on Qt::Key_Pluss
Qt::Key_Plus on Qt::Key_Pluss
*/
- QTest::newRow("N001 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N001 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
//commented out because the behaviour changed, those tests should be updated
- //QTest::newRow("N001:Shift + M - [M]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N001:M - [M]") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N001 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ //QTest::newRow("N001:Shift + M - [M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N001:M - [M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N001 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
//commented out because the behaviour changed, those tests should be updated
- //QTest::newRow("N001:Shift++ [+]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N001:+ [+]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N001 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ //QTest::newRow("N001:Shift++ [+]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N001:+ [+]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N001 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Shift + Qt::Key_M on Shift + Qt::Key_M
@@ -301,32 +282,32 @@ void tst_QShortcut::number_data()
Shift + Qt::Key_Plus on Shift + Qt::Key_Pluss
Qt::Key_Plus on Shift + Qt::Key_Pluss
*/
- QTest::newRow("N002 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::SHIFT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N002:M - [Shift+M]") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N002 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::SHIFT + Qt::Key_Plus) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N002:Shift++ [Shift++]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N002:+ [Shift++]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N002 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("N002 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N002:M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N002 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT + Qt::Key_Plus) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N002:+ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N002 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Shift + Qt::Key_F1 on Qt::Key_F1
Qt::Key_F1 on Qt::Key_F1
*/
- QTest::newRow("N003 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N003 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
//commented out because the behaviour changed, those tests should be updated
- //QTest::newRow("N003:Shift+F1 - [F1]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N003:F1 - [F1]") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N003 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ //QTest::newRow("N003:Shift+F1 - [F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N003:F1 - [F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N003 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Shift + Qt::Key_F1 on Shift + Qt::Key_F1
Qt::Key_F1 on Shift + Qt::Key_F1
*/
- QTest::newRow("N004 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N004 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("N004 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N004 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Qt::Key_Tab on Qt::Key_Tab
@@ -334,14 +315,14 @@ void tst_QShortcut::number_data()
Qt::Key_Backtab on Qt::Key_Tab
Shift + Qt::Key_Backtab on Qt::Key_Tab
*/
- QTest::newRow("N005a - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005a:Tab - [Tab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N005a - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N005a:Tab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
//commented out because the behaviour changed, those tests should be updated
- //QTest::newRow("N005a:Shift+Tab - [Tab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ //QTest::newRow("N005a:Shift+Tab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
// (Shift+)BackTab != Tab, but Shift+BackTab == Shift+Tab
- QTest::newRow("N005a:Backtab - [Tab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005a:Shift+Backtab - [Tab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005a - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("N005a:Backtab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N005a:Shift+Backtab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N005a - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Qt::Key_Tab on Shift + Qt::Key_Tab
@@ -349,12 +330,12 @@ void tst_QShortcut::number_data()
Qt::Key_Backtab on Shift + Qt::Key_Tab
Shift + Qt::Key_Backtab on Shift + Qt::Key_Tab
*/
- QTest::newRow("N005b - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005b:Tab - [Shift+Tab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005b:Shift+Tab - [Shift+Tab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N005b:BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005b:Shift+BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N005b - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("N005b - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N005b:Tab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N005b:Shift+Tab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N005b:BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N005b:Shift+BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N005b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Qt::Key_Tab on Qt::Key_Backtab
@@ -362,15 +343,15 @@ void tst_QShortcut::number_data()
Qt::Key_Backtab on Qt::Key_Backtab
Shift + Qt::Key_Backtab on Qt::Key_Backtab
*/
- QTest::newRow("N006a - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N006a:Tab - [BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N006a - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N006a:Tab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
// This should work, since platform dependent code will transform the
// Shift+Tab into a Shift+BackTab, which should trigger the shortcut
- QTest::newRow("N006a:Shift+Tab - [BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
- QTest::newRow("N006a:BackTab - [BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N006a:Shift+Tab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
+ QTest::newRow("N006a:BackTab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
//commented out because the behaviour changed, those tests should be updated
- //QTest::newRow("N006a:Shift+BackTab - [BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N006a - clear") << ClearAll << NoWidget<< QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ //QTest::newRow("N006a:Shift+BackTab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N006a - clear") << ClearAll << NoWidget<< QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Qt::Key_Tab on Shift + Qt::Key_Backtab
@@ -378,12 +359,12 @@ void tst_QShortcut::number_data()
Qt::Key_Backtab on Shift + Qt::Key_Backtab
Shift + Qt::Key_Backtab on Shift + Qt::Key_Backtab
*/
- QTest::newRow("N006b - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N006b:Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N006b:Shift+Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N006b:BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N006b:Shift+BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
- QTest::newRow("N006b - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("N006b - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N006b:Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N006b:Shift+Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N006b:BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N006b:Shift+BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
+ QTest::newRow("N006b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
//===========================================
// [Shift + key] and [key] on shortcuts with
@@ -394,11 +375,11 @@ void tst_QShortcut::number_data()
Qt::Key_F1
Shift + Qt::Key_F1
*/
- QTest::newRow("N007 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N007 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N007:F1") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N007:Shift + F1") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N007 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("N007 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N007 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N007:F1") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N007:Shift + F1") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N007 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Qt::Key_M
@@ -406,51 +387,51 @@ void tst_QShortcut::number_data()
Ctrl + Qt::Key_M
Alt + Qt::Key_M
*/
- QTest::newRow("N01 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N02 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N03 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N04 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N:Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Shift+Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N:Ctrl+Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Alt+Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N01 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N02 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N03 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N04 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N:Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N:Shift+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Ctrl+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N:Alt+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
/* Testing Single Sequence Ambiguity
Qt::Key_M on shortcut2
*/
- QTest::newRow("N05 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N:Qt::Key_M on slot") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Ambiguous;
- QTest::newRow("N05 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("N05 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N:Qt::Key_M on slot") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Ambiguous;
+ QTest::newRow("N05 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Specialkeys
Qt::Key_aring
Qt::Key_Aring
Qt::UNICODE_ACCEL + Qt::Key_K
*/
- QTest::newRow("N06 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N07 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N08 - slot2") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::UNICODE_ACCEL + Qt::Key_K) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N06 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N07 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N08 - slot2") << SetupAccel << TriggerSlot1 << QString() << int(Qt::UNICODE_ACCEL + Qt::Key_K) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N:Qt::Key_aring") << TestAccel << NoWidget << QString("") << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Qt::Key_Aring") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString("") << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N:Qt::UNICODE_ACCEL + Qt::Key_K")<< TestAccel << NoWidget << QString("") << int(Qt::UNICODE_ACCEL + Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N09 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("N:Qt::Key_aring") << TestAccel << NoWidget << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString() << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Qt::UNICODE_ACCEL + Qt::Key_K")<< TestAccel << NoWidget << QString() << int(Qt::UNICODE_ACCEL + Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N09 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Multiple Sequences
Qt::Key_M
Qt::Key_I, Qt::Key_M
Shift+Qt::Key_I, Qt::Key_M
*/
- QTest::newRow("N10 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N11 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N12 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::SHIFT + Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult;
-
- QTest::newRow("N:Qt::Key_M (2)") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N13 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("N10 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N11 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N12 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult;
+
+ QTest::newRow("N:Qt::Key_M (2)") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N:end") << TestEnd << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
}
// ------------------------------------------------------------------
@@ -460,7 +441,7 @@ void tst_QShortcut::text_data()
{
defElements();
// Clear all
- QTest::newRow("T00 - clear") << ClearAll << NoWidget <<QString("")<<0<<0<<0<<0<<0<<0<<0<<0<< NoResult;
+ QTest::newRow("T00 - clear") << ClearAll << NoWidget <<QString()<<0<<0<<0<<0<<0<<0<<0<<0<< NoResult;
//===========================================
// [Shift + key] on non-shift shortcuts testing
@@ -474,13 +455,13 @@ void tst_QShortcut::text_data()
*/
QTest::newRow("T001 - slot1") << SetupAccel << TriggerSlot1 << QString("M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
//commented out because the behaviour changed, those tests should be updated
- //QTest::newRow("T001:Shift+M - [M]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T001:M - [M]") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ //QTest::newRow("T001:Shift+M - [M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T001:M - [M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T001 - slot2") << SetupAccel << TriggerSlot2 << QString("+") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
//commented out because the behaviour changed, those tests should be updated
- //QTest::newRow("T001:Shift++ [+]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T001:+ [+]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T001 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ //QTest::newRow("T001:Shift++ [+]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T001:+ [+]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T001 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Shift + Qt::Key_M on Shift + Qt::Key_M
@@ -491,12 +472,12 @@ void tst_QShortcut::text_data()
Ctrl + Qt::Key_Plus on Ctrl + Qt::Key_Pluss
*/
QTest::newRow("T002 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T002:M - [Shift+M]") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("T002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T002:M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T002 - slot2") << SetupAccel << TriggerSlot2 << QString("Shift++") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T002:Shift++ [Shift++]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T002:+ [Shift++]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T002 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("T002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T002:+ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("T002 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Shift + Ctrl + Qt::Key_Plus on Ctrl + Qt::Key_Plus
@@ -505,10 +486,10 @@ void tst_QShortcut::text_data()
*/
QTest::newRow("T002b - slot1") << SetupAccel << TriggerSlot1 << QString("Ctrl++") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
//commented out because the behaviour changed, those tests should be updated
- //QTest::newRow("T002b:Shift+Ctrl++ [Ctrl++]")<< TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T002b:Ctrl++ [Ctrl++]") << TestAccel << NoWidget << QString("") << int(Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T002b:+ [Ctrl++]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T002b - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ //QTest::newRow("T002b:Shift+Ctrl++ [Ctrl++]")<< TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T002b:Ctrl++ [Ctrl++]") << TestAccel << NoWidget << QString() << int(Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T002b:+ [Ctrl++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("T002b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Shift + Qt::Key_F1 on Qt::Key_F1
@@ -516,18 +497,18 @@ void tst_QShortcut::text_data()
*/
QTest::newRow("T003 - slot1") << SetupAccel << TriggerSlot1 << QString("F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
//commented out because the behaviour changed, those tests should be updated
- //QTest::newRow("T003:Shift+F1 - [F1]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T003:F1 - [F1]") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T003 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ //QTest::newRow("T003:Shift+F1 - [F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T003:F1 - [F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T003 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Shift + Qt::Key_F1 on Shift + Qt::Key_F1
Qt::Key_F1 on Shift + Qt::Key_F1
*/
QTest::newRow("T004 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T004 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("T004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("T004 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
//===========================================
// [Shift + key] and [key] on shortcuts with
@@ -540,9 +521,9 @@ void tst_QShortcut::text_data()
*/
QTest::newRow("T007 - slot1") << SetupAccel << TriggerSlot1 << QString("F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T007 - slot2") << SetupAccel << TriggerSlot2 << QString("Shift+F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T007:F1") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T007:Shift + F1") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T007 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("T007:F1") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T007:Shift + F1") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T007 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
Qt::Key_M
@@ -555,17 +536,17 @@ void tst_QShortcut::text_data()
QTest::newRow("T03 - slot1") << SetupAccel << TriggerSlot1 << QString("Ctrl+M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T04 - slot2") << SetupAccel << TriggerSlot2 << QString("Alt+M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T:Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Shift + Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T:Ctrl + Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Alt + Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T:Shift + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Ctrl + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T:Alt + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
/* Testing Single Sequence Ambiguity
Qt::Key_M on shortcut2
*/
QTest::newRow("T05 - slot2") << SetupAccel << TriggerSlot2 << QString("M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T:Qt::Key_M on TriggerSlot2") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Ambiguous;
- QTest::newRow("T06 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("T:Qt::Key_M on TriggerSlot2") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Ambiguous;
+ QTest::newRow("T06 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Specialkeys
Qt::Key_aring
@@ -576,12 +557,12 @@ void tst_QShortcut::text_data()
QTest::newRow("T06 - slot1") << SetupAccel << TriggerSlot1 << QString::fromLatin1("\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T07 - slot2") << SetupAccel << TriggerSlot2 << QString::fromLatin1("Shift+\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T08 - slot2") << SetupAccel << TriggerSlot1 << QString("K") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T:Qt::Key_aring") << TestAccel << NoWidget << QString("") << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Qt::Key_Aring") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString("") << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T:Qt::UNICODE_ACCEL + Qt::Key_K")<< TestAccel << NoWidget << QString("") << int(Qt::UNICODE_ACCEL + Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T09 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("T:Qt::Key_aring") << TestAccel << NoWidget << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString() << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Qt::UNICODE_ACCEL + Qt::Key_K")<< TestAccel << NoWidget << QString() << int(Qt::UNICODE_ACCEL + Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T09 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Multiple Sequences
Qt::Key_M
@@ -591,10 +572,38 @@ void tst_QShortcut::text_data()
QTest::newRow("T10 - slot1") << SetupAccel << TriggerSlot1 << QString("M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T11 - slot2") << SetupAccel << TriggerSlot2 << QString("I, M")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T12 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+I, M")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T:Qt::Key_M (2)") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T13 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
+ QTest::newRow("T:Qt::Key_M (2)") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T:end") << TestEnd << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+}
+
+class ButtonWidget : public QWidget
+{
+public:
+ ButtonWidget();
+
+ QPushButton *pushButton1() const { return m_pb1; }
+ QPushButton *pushButton2() const { return m_pb2; }
+
+private:
+ QPushButton *m_pb1;
+ QPushButton *m_pb2;
+};
+
+ButtonWidget::ButtonWidget()
+{
+ // Setup two identical shortcuts on different pushbuttons
+ QString name = QLatin1String("pushbutton-1");
+ m_pb1 = new QPushButton(name, this);
+ m_pb1->setObjectName(name);
+ name = QLatin1String("pushbutton-2");
+ m_pb2 = new QPushButton(name, this);
+ m_pb2->setObjectName(name);
+ auto hLayout = new QHBoxLayout(this);
+ hLayout->addWidget(m_pb1);
+ hLayout->addWidget(m_pb2);
+ hLayout->addStretch();
}
// ------------------------------------------------------------------
@@ -602,9 +611,11 @@ void tst_QShortcut::text_data()
// ------------------------------------------------------------------
void tst_QShortcut::disabledItems()
{
- clearAllShortcuts();
- mainW->activateWindow();
- QVERIFY(QTest::qWaitForWindowActive(mainW));
+ ButtonWidget mainW;
+ mainW.setWindowTitle(QTest::currentTestFunction());
+ mainW.show();
+ mainW.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&mainW));
/* Testing Disabled Shortcuts
Qt::Key_M on slot1
@@ -614,27 +625,27 @@ void tst_QShortcut::disabledItems()
*/
// Setup two identical shortcuts on different pushbuttons
- QPushButton pb1(mainW);
- QPushButton pb2(mainW);
- pb1.setObjectName("pushbutton-1");
- pb2.setObjectName("pushbutton-2");
- pb1.show(); // Must be show for QShortcutMap::correctSubWindow to trigger
- pb2.show();
-
- QShortcut *cut1 = setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "M");
- QShortcut *cut2 = setupShortcut(&pb1, "shortcut2-pb1", TriggerSlot1, "Shift+M");
- QShortcut *cut3 = setupShortcut(&pb2, "shortcut3-pb2", TriggerSlot2, "M");
- QShortcut *cut4 = setupShortcut(&pb2, "shortcut4-pb2", TriggerSlot2, "Shift+M");
+ auto pb1 = mainW.pushButton1();
+ auto pb2 = mainW.pushButton2();
+ const int shiftM = Qt::SHIFT + Qt::Key_M;
+ QShortcut *cut1 = setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1,
+ QKeySequence(Qt::Key_M));
+ QShortcut *cut2 = setupShortcut(pb1, "shortcut2-pb1", TriggerSlot1,
+ QKeySequence(shiftM));
+ QShortcut *cut3 = setupShortcut(pb2, "shortcut3-pb2", TriggerSlot2,
+ QKeySequence(Qt::Key_M));
+ QShortcut *cut4 = setupShortcut(pb2, "shortcut4-pb2", TriggerSlot2,
+ QKeySequence(shiftM));
cut3->setEnabled(false);
cut4->setEnabled(false);
currentResult = NoResult;
- sendKeyEvents(Qt::Key_M, 'm');
+ sendKeyEvents(&mainW, Qt::Key_M, 'm');
QCOMPARE(currentResult, Slot1Triggered);
currentResult = NoResult;
- sendKeyEvents(Qt::SHIFT+Qt::Key_M, 'M');
+ sendKeyEvents(&mainW, shiftM, 'M');
QCOMPARE(currentResult, Slot1Triggered);
cut2->setEnabled(false);
@@ -647,11 +658,11 @@ void tst_QShortcut::disabledItems()
Shift + Qt::Key_M on slot2
*/
currentResult = NoResult;
- sendKeyEvents( Qt::Key_M, 'm' );
+ sendKeyEvents(&mainW, Qt::Key_M, 'm' );
QCOMPARE( currentResult, Slot1Triggered );
currentResult = NoResult;
- sendKeyEvents( Qt::SHIFT+Qt::Key_M, 'M' );
+ sendKeyEvents(&mainW, shiftM, 'M' );
QCOMPARE( currentResult, Slot2Triggered );
@@ -659,67 +670,34 @@ void tst_QShortcut::disabledItems()
Qt::Key_F5 on slot1
Shift + Qt::Key_F5 on slot2 (disabled)
*/
- clearAllShortcuts();
- cut1 = setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "F5");
- cut4 = setupShortcut(&pb2, "shortcut4-pb2", TriggerSlot2, "Shift+F5");
-
- cut1->setKey(QKeySequence("F5"));
- cut4->setKey(QKeySequence("Shift+F5"));
+ qDeleteAll(mainW.findChildren<QShortcut *>());
+ const int shiftF5 = Qt::SHIFT + Qt::Key_F5;
+ cut1 = setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, QKeySequence(Qt::Key_F5));
+ cut4 = setupShortcut(pb2, "shortcut4-pb2", TriggerSlot2, QKeySequence(shiftF5));
cut1->setEnabled(true);
cut4->setEnabled(false);
currentResult = NoResult;
- sendKeyEvents( Qt::Key_F5, 0 );
+ sendKeyEvents(&mainW, Qt::Key_F5, 0 );
QCOMPARE( currentResult, Slot1Triggered );
currentResult = NoResult;
- sendKeyEvents( Qt::SHIFT+Qt::Key_F5, 0 );
+ sendKeyEvents(&mainW, shiftF5, 0 );
QCOMPARE( currentResult, NoResult );
-
-#if 0
- qFatal("Not testing statusbar text feedback yet, since not implemented");
- /* Testing Disabled Accel, and the corresponding statusbar feedback
- Ctrl + Qt::Key_K, Ctrl + Qt::Key_L on slot1
- Ctrl + Qt::Key_K, Ctrl + Qt::Key_M on slot2 (disabled)
- */
- cut1->setKey(QKeySequence("Ctrl+K, Ctrl+L"));
- cut4->setKey(QKeySequence("Ctrl+K, Ctrl+M"));
-
- cut1->setEnabled(true);
- cut4->setEnabled(false);
-
- currentResult = NoResult;
- sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 );
- sendKeyEvents( Qt::CTRL+Qt::Key_Q, 0 );
- QCOMPARE( currentResult, NoResult );
- if (over_330)
- QCOMPARE( sbText, QString("Ctrl+K, Ctrl+Q not defined") );
-
- currentResult = NoResult;
- sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 );
- sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 );
- QCOMPARE( currentResult, NoResult );
- if (over_330)
- QCOMPARE( sbText, QString() );
-
- currentResult = NoResult;
- sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 );
- sendKeyEvents( Qt::CTRL+Qt::Key_L, 0 );
- QCOMPARE( currentResult, Slot1Triggered );
- if (over_330)
- QCOMPARE( sbText, QString() );
-#endif
- clearAllShortcuts();
- cut1 = 0;
- cut4 = 0;
}
// ------------------------------------------------------------------
// Ambiguous Elements -----------------------------------------------
// ------------------------------------------------------------------
void tst_QShortcut::ambiguousRotation()
{
- clearAllShortcuts();
+ MainWindow mainW;
+ const QString name = QLatin1String(QTest::currentTestFunction());
+ mainW.setWindowTitle(name);
+ mainW.show();
+ mainW.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&mainW));
+
/* Testing Shortcut rotation scheme
Ctrl + Qt::Key_A on slot1 (disabled)
Ctrl + Qt::Key_A on slot2 (disabled)
@@ -729,13 +707,15 @@ void tst_QShortcut::ambiguousRotation()
Ctrl + Qt::Key_A on slot6
Ctrl + Qt::Key_A on slot7 (disabled)
*/
- QShortcut *cut1 = setupShortcut(TriggerSlot1, "Ctrl+A");
- QShortcut *cut2 = setupShortcut(TriggerSlot2, "Ctrl+A");
- QShortcut *cut3 = setupShortcut(TriggerSlot3, "Ctrl+A");
- QShortcut *cut4 = setupShortcut(TriggerSlot4, "Ctrl+A");
- QShortcut *cut5 = setupShortcut(TriggerSlot5, "Ctrl+A");
- QShortcut *cut6 = setupShortcut(TriggerSlot6, "Ctrl+A");
- QShortcut *cut7 = setupShortcut(TriggerSlot7, "Ctrl+A");
+ const int ctrlA = Qt::CTRL + Qt::Key_A;
+ QKeySequence ctrlA_Sequence(ctrlA);
+ QShortcut *cut1 = setupShortcut(&mainW, name, TriggerSlot1, ctrlA_Sequence);
+ QShortcut *cut2 = setupShortcut(&mainW, name, TriggerSlot2, ctrlA_Sequence);
+ QShortcut *cut3 = setupShortcut(&mainW, name, TriggerSlot3, ctrlA_Sequence);
+ QShortcut *cut4 = setupShortcut(&mainW, name, TriggerSlot4, ctrlA_Sequence);
+ QShortcut *cut5 = setupShortcut(&mainW, name, TriggerSlot5, ctrlA_Sequence);
+ QShortcut *cut6 = setupShortcut(&mainW, name, TriggerSlot6, ctrlA_Sequence);
+ QShortcut *cut7 = setupShortcut(&mainW, name, TriggerSlot7, ctrlA_Sequence);
cut1->setEnabled(false);
cut2->setEnabled(false);
@@ -749,37 +729,37 @@ void tst_QShortcut::ambiguousRotation()
// Continue...
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot3Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot4Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot6Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot3Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot4Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot6Triggered);
@@ -804,94 +784,87 @@ void tst_QShortcut::ambiguousRotation()
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot1Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot2Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot5Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot7Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot1Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot2Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot5Triggered);
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(Qt::CTRL+Qt::Key_A);
+ sendKeyEvents(&mainW, ctrlA);
QCOMPARE(currentResult, Ambiguous);
QCOMPARE(ambigResult, Slot7Triggered);
-
- clearAllShortcuts();
- cut1 = 0; cut2 = 0;
- cut3 = 0; cut4 = 0;
- cut5 = 0; cut6 = 0;
- cut7 = 0;
}
void tst_QShortcut::ambiguousItems()
{
- clearAllShortcuts();
+ ButtonWidget mainW;
+ mainW.setWindowTitle(QTest::currentTestFunction());
+ mainW.show();
+ mainW.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&mainW));
+
/* Testing Ambiguous Shortcuts
Qt::Key_M on Pushbutton 1
Qt::Key_M on Pushbutton 2
*/
// Setup two identical shortcuts on different pushbuttons
- QPushButton pb1(mainW);
- QPushButton pb2(mainW);
- pb1.setObjectName("pushbutton-1");
- pb2.setObjectName("pushbutton-2");
- pb1.show(); // Must be show for QShortcutMap::correctSubWindow to trigger
- pb2.show();
+ auto pb1 = mainW.pushButton1();
+ auto pb2 = mainW.pushButton2();
- setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "M");
- setupShortcut(&pb1, "shortcut2-pb2", TriggerSlot2, "M");
+ setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, QKeySequence(Qt::Key_M));
+ setupShortcut(pb2, "shortcut2-pb2", TriggerSlot2, QKeySequence(Qt::Key_M));
currentResult = NoResult;
- sendKeyEvents( Qt::Key_M, 'm' );
+ sendKeyEvents(&mainW, Qt::Key_M, 'm' );
QCOMPARE( currentResult, Ambiguous );
QCOMPARE( ambigResult, Slot1Triggered );
currentResult = NoResult;
- sendKeyEvents( Qt::Key_M, 'm' );
+ sendKeyEvents(&mainW, Qt::Key_M, 'm' );
QCOMPARE( currentResult, Ambiguous );
QCOMPARE( ambigResult, Slot2Triggered );
currentResult = NoResult;
- sendKeyEvents( Qt::Key_M, 'm' );
+ sendKeyEvents(&mainW, Qt::Key_M, 'm' );
QCOMPARE( currentResult, Ambiguous );
QCOMPARE( ambigResult, Slot1Triggered );
-
- clearAllShortcuts();
}
@@ -900,32 +873,31 @@ void tst_QShortcut::ambiguousItems()
// ------------------------------------------------------------------
void tst_QShortcut::unicodeCompare()
{
- clearAllShortcuts();
+ ButtonWidget mainW;
+ mainW.setWindowTitle(QTest::currentTestFunction());
+ mainW.show();
+ mainW.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&mainW));
+
/* Testing Unicode/non-Unicode Shortcuts
Qt::Key_M on Pushbutton 1
Qt::Key_M on Pushbutton 2
*/
- QPushButton pb1(mainW);
- QPushButton pb2(mainW);
- pb1.setObjectName("pushbutton-1");
- pb2.setObjectName("pushbutton-2");
- pb1.show(); // Must be show for QShortcutMap::correctSubWindow to trigger
- pb2.show();
+ auto pb1 = mainW.pushButton1();
+ auto pb2 = mainW.pushButton2();
QKeySequence ks1("Ctrl+M"); // Unicode
QKeySequence ks2(Qt::CTRL+Qt::Key_M); // non-Unicode
- setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, ks1);
- setupShortcut(&pb1, "shortcut2-pb2", TriggerSlot2, ks2);
+ setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, ks1);
+ setupShortcut(pb2, "shortcut2-pb2", TriggerSlot2, ks2);
currentResult = NoResult;
- sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 );
+ sendKeyEvents(&mainW, Qt::CTRL + Qt::Key_M, 0);
QCOMPARE( currentResult, Ambiguous );
// They _are_ ambiguous, so the QKeySequence operator==
// should indicate the same
QVERIFY( ks1 == ks2 );
QVERIFY( !(ks1 != ks2) );
-
- clearAllShortcuts();
}
// ------------------------------------------------------------------
@@ -933,25 +905,29 @@ void tst_QShortcut::unicodeCompare()
// ------------------------------------------------------------------
void tst_QShortcut::keypressConsumption()
{
- clearAllShortcuts();
- edit->clear();
- QCOMPARE(edit->toPlainText().size(), 0);
+ MainWindow mainW;
+ mainW.setWindowTitle(QTest::currentTestFunction());
+ mainW.show();
+ mainW.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&mainW));
+ auto edit = mainW.testEdit();
- QShortcut *cut1 = setupShortcut(edit, "shortcut1-line", TriggerSlot1, "Ctrl+I, A");
- QShortcut *cut2 = setupShortcut(edit, "shortcut1-line", TriggerSlot2, "Ctrl+I, B");
+ const int ctrlI = Qt::CTRL + Qt::Key_I;
+ QShortcut *cut1 = setupShortcut(edit, "shortcut1-line", TriggerSlot1, QKeySequence(ctrlI, Qt::Key_A));
+ QShortcut *cut2 = setupShortcut(edit, "shortcut1-line", TriggerSlot2, QKeySequence(ctrlI, Qt::Key_B));
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(edit, Qt::CTRL + Qt::Key_I, 0); // Send key to edit
+ sendKeyEvents(edit, ctrlI, 0); // Send key to edit
QCOMPARE( currentResult, NoResult );
QCOMPARE( ambigResult, NoResult );
- QCOMPARE(edit->toPlainText(), QString(""));
+ QCOMPARE(edit->toPlainText(), QString());
// Make sure next keypress is eaten (failing multiple keysequence)
sendKeyEvents(edit, Qt::Key_C, 'c'); // Send key to edit
QCOMPARE( currentResult, NoResult );
QCOMPARE( ambigResult, NoResult );
- QCOMPARE(edit->toPlainText(), QString(""));
+ QCOMPARE(edit->toPlainText(), QString());
// Next keypress should be normal
sendKeyEvents(edit, Qt::Key_C, 'c'); // Send key to edit
@@ -979,11 +955,15 @@ void tst_QShortcut::keypressConsumption()
QCOMPARE( ambigResult, NoResult );
QVERIFY(edit->toPlainText().endsWith("<Ctrl+I>a"));
- clearAllShortcuts();
+ qDeleteAll(mainW.findChildren<QShortcut *>());
edit->clear();
QCOMPARE(edit->toPlainText().size(), 0);
- setupShortcut(edit, "first", SendKeyEvent, "Ctrl+A");
+ auto cut = setupShortcut(edit, QLatin1String("first"), QKeySequence(Qt::CTRL + Qt::Key_A));
+ connect(cut, &QShortcut::activated, edit, [this, edit] () {
+ this->sendKeyEvents(edit, Qt::CTRL + Qt::Key_B, 0);
+ this->currentResult = tst_QShortcut::SentKeyEvent;
+ });
// Verify reentrancy when a non-shortcut is triggered as part
// of shortcut processing.
@@ -992,7 +972,7 @@ void tst_QShortcut::keypressConsumption()
sendKeyEvents(edit, Qt::CTRL + Qt::Key_A, 0);
QCOMPARE(currentResult, SentKeyEvent);
QCOMPARE(ambigResult, NoResult);
- QCOMPARE(edit->toPlainText(), QString(QString("<Ctrl+B>")));
+ QCOMPARE(edit->toPlainText(), QLatin1String("<Ctrl+B>"));
}
// ------------------------------------------------------------------
@@ -1000,12 +980,17 @@ void tst_QShortcut::keypressConsumption()
// ------------------------------------------------------------------
void tst_QShortcut::context()
{
- clearAllShortcuts();
+ const QString name = QLatin1String(QTest::currentTestFunction());
+ MainWindow mainW;
+ mainW.setWindowTitle(name + QLatin1String("_Helper"));
+ mainW.show();
+ auto edit = mainW.testEdit();
QWidget myBox;
- TestEdit *other1 = new TestEdit(&myBox, "test_edit_other1");
- TestEdit *other2 = new TestEdit(&myBox, "test_edit_other2");
- QHBoxLayout *layout = new QHBoxLayout(&myBox);
+ myBox.setWindowTitle(name);
+ auto other1 = new TestEdit(&myBox, "test_edit_other1");
+ auto other2 = new TestEdit(&myBox, "test_edit_other2");
+ auto layout = new QHBoxLayout(&myBox);
layout->addWidget(other1);
layout->addWidget(other2);
myBox.show();
@@ -1030,8 +1015,8 @@ void tst_QShortcut::context()
// Focus on 'other1' edit, so Active Window context should trigger
other1->activateWindow(); // <---
QApplication::setActiveWindow(other1);
- QCOMPARE(qApp->activeWindow(), other1->window());
- QCOMPARE(qApp->focusWidget(), (QWidget *)other1);
+ QCOMPARE(QApplication::activeWindow(), other1->window());
+ QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(other1));
currentResult = NoResult;
ambigResult = NoResult;
@@ -1039,13 +1024,13 @@ void tst_QShortcut::context()
other1->clear();
other2->clear();
- QCOMPARE(qApp->focusWidget(), (QWidget *)other1);
+ QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(other1));
sendKeyEvents(other1, Qt::ALT+Qt::Key_1);
QCOMPARE(currentResult, Slot1Triggered);
QCOMPARE(ambigResult, NoResult);
- QCOMPARE(edit->toPlainText(), QString(""));
- QCOMPARE(other1->toPlainText(), QString(""));
- QCOMPARE(other2->toPlainText(), QString(""));
+ QCOMPARE(edit->toPlainText(), QString());
+ QCOMPARE(other1->toPlainText(), QString());
+ QCOMPARE(other2->toPlainText(), QString());
// ..but not Focus context on 'other2'..
currentResult = NoResult;
@@ -1057,9 +1042,9 @@ void tst_QShortcut::context()
sendKeyEvents(other1, Qt::ALT+Qt::Key_2);
QCOMPARE(currentResult, NoResult);
QCOMPARE(ambigResult, NoResult);
- QCOMPARE(edit->toPlainText(), QString(""));
+ QCOMPARE(edit->toPlainText(), QString());
QCOMPARE(other1->toPlainText(), QString("<Alt+2>"));
- QCOMPARE(other2->toPlainText(), QString(""));
+ QCOMPARE(other2->toPlainText(), QString());
// ..however, application global context on 'edit' should..
currentResult = NoResult;
@@ -1071,15 +1056,15 @@ void tst_QShortcut::context()
sendKeyEvents(other1, Qt::ALT+Qt::Key_3);
QCOMPARE(currentResult, Slot3Triggered);
QCOMPARE(ambigResult, NoResult);
- QCOMPARE(edit->toPlainText(), QString(""));
- QCOMPARE(other1->toPlainText(), QString(""));
- QCOMPARE(other2->toPlainText(), QString(""));
+ QCOMPARE(edit->toPlainText(), QString());
+ QCOMPARE(other1->toPlainText(), QString());
+ QCOMPARE(other2->toPlainText(), QString());
// Changing focus to 'other2' should make the Focus context there work
other2->activateWindow();
other2->setFocus(); // ###
- QTRY_COMPARE(qApp->activeWindow(), other2->window());
- QCOMPARE(qApp->focusWidget(), (QWidget *)other2);
+ QTRY_COMPARE(QApplication::activeWindow(), other2->window());
+ QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(other2));
currentResult = NoResult;
ambigResult = NoResult;
@@ -1090,20 +1075,18 @@ void tst_QShortcut::context()
sendKeyEvents(other2, Qt::ALT+Qt::Key_2);
QCOMPARE(currentResult, Slot2Triggered);
QCOMPARE(ambigResult, NoResult);
- QCOMPARE(edit->toPlainText(), QString(""));
- QCOMPARE(other1->toPlainText(), QString(""));
- QCOMPARE(other2->toPlainText(), QString(""));
-
- clearAllShortcuts();
+ QCOMPARE(edit->toPlainText(), QString());
+ QCOMPARE(other1->toPlainText(), QString());
+ QCOMPARE(other2->toPlainText(), QString());
}
// QTBUG-38986, do not generate duplicated QEvent::ShortcutOverride in event processing.
class OverrideCountingWidget : public QWidget
{
public:
- OverrideCountingWidget(QWidget *parent = 0) : QWidget(parent), overrideCount(0) {}
+ using QWidget::QWidget;
- int overrideCount;
+ int overrideCount = 0;
bool event(QEvent *e) override
{
@@ -1127,95 +1110,55 @@ void tst_QShortcut::duplicatedShortcutOverride()
QCOMPARE(w.overrideCount, 1);
}
-// ------------------------------------------------------------------
-// Element Testing helper functions ---------------------------------
-// ------------------------------------------------------------------
-void tst_QShortcut::clearAllShortcuts()
+QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const QString &name, const QKeySequence &ks, Qt::ShortcutContext context)
{
- QList<QShortcut *> shortcutsCpy = shortcuts;
- qDeleteAll(shortcutsCpy);
- shortcuts.clear();
-}
-
-QShortcut *tst_QShortcut::setupShortcut(int testWidget, const QKeySequence &ks)
-{
- return setupShortcut(mainW, QTest::currentDataTag() ? QTest::currentDataTag() : "", testWidget, ks);
-}
-
-QShortcut *tst_QShortcut::setupShortcut(int testWidget, const QString &txt, int k1, int k2, int k3, int k4)
-{
- return setupShortcut(mainW, QTest::currentDataTag() ? QTest::currentDataTag() : "", testWidget,
- (txt.isEmpty() ? QKeySequence(k1, k2, k3, k4) : QKeySequence(txt)));
-}
-
-QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, int testWidget, const QString &txt, int k1, int k2, int k3, int k4)
-{
- return setupShortcut(parent, name, testWidget,
- (txt.isEmpty() ? QKeySequence(k1, k2, k3, k4) : QKeySequence(txt)));
+ // Set up shortcut for next test
+ auto cut = new QShortcut(ks, parent, nullptr, nullptr, context);
+ cut->setObjectName(name);
+ return cut;
}
-QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, int testWidget,
+QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const QString &name, Widget testWidget,
const QKeySequence &ks, Qt::ShortcutContext context)
{
// Set up shortcut for next test
- QShortcut *cut = new QShortcut(QKeySequence(), parent, 0, 0, context);
- cut->setObjectName(name);
- cut->setKey(ks);
+ auto cut = setupShortcut(parent, name, ks, context);
- const char *normal = 0;
- const char *ambig = 0;
- switch(testWidget)
- {
+ switch (testWidget) {
case TriggerSlot1:
- normal = SLOT(slotTrig1());
- ambig = SLOT(ambigSlot1());
+ connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig1);
+ connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot1);
break;
case TriggerSlot2:
- normal = SLOT(slotTrig2());
- ambig = SLOT(ambigSlot2());
+ connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig2);
+ connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot2);
break;
case TriggerSlot3:
- normal = SLOT(slotTrig3());
- ambig = SLOT(ambigSlot3());
+ connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig3);
+ connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot3);
break;
case TriggerSlot4:
- normal = SLOT(slotTrig4());
- ambig = SLOT(ambigSlot4());
+ connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig4);
+ connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot4);
break;
case TriggerSlot5:
- normal = SLOT(slotTrig5());
- ambig = SLOT(ambigSlot5());
+ connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig5);
+ connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot5);
break;
case TriggerSlot6:
- normal = SLOT(slotTrig6());
- ambig = SLOT(ambigSlot6());
+ connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig6);
+ connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot6);
break;
case TriggerSlot7:
- normal = SLOT(slotTrig7());
- ambig = SLOT(ambigSlot7());
+ connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig7);
+ connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot7);
+ break;
+ case NoWidget:
break;
- case SendKeyEvent:
- normal = SLOT(sendKeyEvent());
}
- connect(cut, SIGNAL(activated()), this, normal);
- if (ambig)
- connect(cut, SIGNAL(activatedAmbiguously()), this, ambig);
- connect(cut, SIGNAL(destroyed(QObject*)), this, SLOT(shortcutDestroyed(QObject*)));
- shortcuts.append(cut);
return cut;
}
-void tst_QShortcut::shortcutDestroyed(QObject* obj)
-{
- shortcuts.erase(std::remove(shortcuts.begin(), shortcuts.end(), obj),
- shortcuts.end());
-}
-
-void tst_QShortcut::sendKeyEvents(int k1, QChar c1, int k2, QChar c2, int k3, QChar c3, int k4, QChar c4)
-{
- sendKeyEvents(mainW, k1, c1, k2, c2, k3, c3, k4, c4);
-}
-
void tst_QShortcut::sendKeyEvents(QWidget *w, int k1, QChar c1, int k2, QChar c2, int k3, QChar c3, int k4, QChar c4)
{
Qt::KeyboardModifiers b1 = toButtons( k1 );
@@ -1255,6 +1198,8 @@ void tst_QShortcut::sendKeyEvents(QWidget *w, int k1, QChar c1, int k2, QChar c2
void tst_QShortcut::testElement()
{
+ static QScopedPointer<MainWindow> mainW;
+
currentResult = NoResult;
QFETCH(tst_QShortcut::Action, action);
QFETCH(tst_QShortcut::Widget, testWidget);
@@ -1269,15 +1214,54 @@ void tst_QShortcut::testElement()
QFETCH(int, c4);
QFETCH(tst_QShortcut::Result, result);
- if (action == ClearAll) {
- clearAllShortcuts();
- } else if (action == SetupAccel) {
- setupShortcut(testWidget, txt, k1, k2, k3, k4);
- } else {
- sendKeyEvents(k1, c1, k2, c2, k3, c3, k4, c4);
- QCOMPARE((int)currentResult, (int)result);
+ if (mainW.isNull()) {
+ mainW.reset(new MainWindow);
+ mainW->setWindowTitle(QTest::currentTestFunction());
+ mainW->show();
+ mainW->activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(mainW.data()));
+ }
+
+ switch (action) {
+ case ClearAll:
+ qDeleteAll(mainW->findChildren<QShortcut *>());
+ break;
+ case SetupAccel:
+ setupShortcut(mainW.data(), txt, testWidget, txt.isEmpty()
+ ? QKeySequence(k1, k2, k3, k4) : QKeySequence::fromString(txt));
+ break;
+ case TestAccel:
+ sendKeyEvents(mainW.data(), k1, c1, k2, c2, k3, c3, k4, c4);
+ QCOMPARE(currentResult, result);
+ break;
+ case TestEnd:
+ mainW.reset();
+ break;
}
}
+void tst_QShortcut::shortcutToFocusProxy()
+{
+ QLineEdit le;
+ QCompleter completer;
+ QStringListModel *slm = new QStringListModel(QStringList() << "a0" << "a1" << "a2", &completer);
+ completer.setModel(slm);
+ completer.setCompletionMode(QCompleter::PopupCompletion);
+ le.setCompleter(&completer);
+ QShortcut *shortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_S), &le);
+ QObject::connect(shortcut, &QShortcut::activated, &le, &QLineEdit::clear);
+ le.setFocus();
+ le.show();
+
+ QVERIFY(QTest::qWaitForWindowActive(&le));
+ QCOMPARE(QApplication::focusWidget(), &le);
+ QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_A);
+
+ QCOMPARE(le.text(), QString::fromLocal8Bit("a"));
+ QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_Alt);
+ QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_S, Qt::AltModifier);
+ QCOMPARE(le.text(), QString());
+}
+
QTEST_MAIN(tst_QShortcut)
#include "tst_qshortcut.moc"
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 7203e7b170..103be88f86 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -26,6 +26,7 @@
**
****************************************************************************/
+#include "../../../shared/highdpi.h"
#include <qboxlayout.h>
#include <qapplication.h>
@@ -53,6 +54,7 @@
#include <qrandom.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
+#include <QtCore/qoperatingsystemversion.h>
#include <QtGui/qpaintengine.h>
#include <QtGui/qbackingstore.h>
#include <QtGui/qguiapplication.h>
@@ -140,19 +142,6 @@ static QByteArray msgComparisonFailed(T v1, const char *op, T v2)
return s.toLocal8Bit();
}
-// Compare a window position that may go through scaling in the platform plugin with fuzz.
-static inline bool qFuzzyCompareWindowPosition(const QPoint &p1, const QPoint p2, int fuzz)
-{
- return (p1 - p2).manhattanLength() <= fuzz;
-}
-
-static QString msgPointMismatch(const QPoint &p1, const QPoint p2)
-{
- QString result;
- QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength();
- return result;
-}
-
class tst_QWidget : public QObject
{
Q_OBJECT
@@ -192,6 +181,7 @@ private slots:
void tabOrderWithProxy();
void tabOrderWithCompoundWidgets();
void tabOrderNoChange();
+ void tabOrderNoChange2();
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void activation();
#endif
@@ -418,6 +408,7 @@ private:
QPoint m_safeCursorPos;
const bool m_windowsAnimationsEnabled;
QTouchDevice *m_touchScreen;
+ const int m_fuzz;
};
bool tst_QWidget::ensureScreenSize(int width, int height)
@@ -576,6 +567,7 @@ tst_QWidget::tst_QWidget()
, m_safeCursorPos(0, 0)
, m_windowsAnimationsEnabled(windowsAnimationsEnabled())
, m_touchScreen(QTest::createTouchDevice())
+ , m_fuzz(int(QGuiApplication::primaryScreen()->devicePixelRatio()))
{
if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild()
setWindowsAnimationsEnabled(false);
@@ -1952,6 +1944,24 @@ static QVector<QWidget*> getFocusChain(QWidget *start, bool bForward)
return ret;
}
+//#define DEBUG_FOCUS_CHAIN
+static void dumpFocusChain(QWidget *start, bool bForward, const char *desc = nullptr)
+{
+#ifdef DEBUG_FOCUS_CHAIN
+ qDebug() << "Dump focus chain, start:" << start << "isForward:" << bForward << desc;
+ QWidget *cur = start;
+ do {
+ qDebug() << cur;
+ auto widgetPrivate = static_cast<QWidgetPrivate *>(qt_widget_private(cur));
+ cur = bForward ? widgetPrivate->focus_next : widgetPrivate->focus_prev;
+ } while (cur != start);
+#else
+ Q_UNUSED(start)
+ Q_UNUSED(bForward)
+ Q_UNUSED(desc)
+#endif
+}
+
void tst_QWidget::tabOrderNoChange()
{
QWidget w;
@@ -1963,7 +1973,61 @@ void tst_QWidget::tabOrderNoChange()
const auto focusChainForward = getFocusChain(&w, true);
const auto focusChainBackward = getFocusChain(&w, false);
+ dumpFocusChain(&w, true);
QWidget::setTabOrder(tabWidget, tv);
+ dumpFocusChain(&w, true);
+ QCOMPARE(focusChainForward, getFocusChain(&w, true));
+ QCOMPARE(focusChainBackward, getFocusChain(&w, false));
+}
+
+void tst_QWidget::tabOrderNoChange2()
+{
+ QWidget w;
+ auto *verticalLayout = new QVBoxLayout(&w);
+ auto *tabWidget = new QTabWidget(&w);
+ tabWidget->setObjectName("tabWidget");
+ verticalLayout->addWidget(tabWidget);
+
+ auto *tab1 = new QWidget(tabWidget);
+ tab1->setObjectName("tab1");
+ auto *vLay1 = new QVBoxLayout(tab1);
+ auto *le1 = new QLineEdit(tab1);
+ le1->setObjectName("le1");
+ auto *le2 = new QLineEdit(tab1);
+ le2->setObjectName("le2");
+ vLay1->addWidget(le1);
+ vLay1->addWidget(le2);
+ tabWidget->addTab(tab1, QStringLiteral("Tab 1"));
+
+ auto *tab2 = new QWidget(tabWidget);
+ tab2->setObjectName("tab2");
+ auto *vLay2 = new QVBoxLayout(tab2);
+ auto *le3 = new QLineEdit(tab2);
+ le3->setObjectName("le3");
+ auto *le4 = new QLineEdit(tab2);
+ le4->setObjectName("le4");
+ vLay2->addWidget(le3);
+ vLay2->addWidget(le4);
+ tabWidget->addTab(tab2, QStringLiteral("Tab 2"));
+
+ const auto focusChainForward = getFocusChain(&w, true);
+ const auto focusChainBackward = getFocusChain(&w, false);
+ dumpFocusChain(&w, true);
+ dumpFocusChain(&w, false);
+ // this will screw up the focus chain order without visible changes,
+ // so don't call it here for the simplicity of the test
+ //QWidget::setTabOrder(tabWidget, le1);
+
+ QWidget::setTabOrder(le1, le2);
+ dumpFocusChain(&w, true, "QWidget::setTabOrder(le1, le2)");
+ QWidget::setTabOrder(le2, le3);
+ dumpFocusChain(&w, true, "QWidget::setTabOrder(le2, le3)");
+ QWidget::setTabOrder(le3, le4);
+ dumpFocusChain(&w, true, "QWidget::setTabOrder(le3, le4)");
+ QWidget::setTabOrder(le4, tabWidget);
+ dumpFocusChain(&w, true, "QWidget::setTabOrder(le4, tabWidget)");
+ dumpFocusChain(&w, false);
+
QCOMPARE(focusChainForward, getFocusChain(&w, true));
QCOMPARE(focusChainBackward, getFocusChain(&w, false));
}
@@ -2049,10 +2113,9 @@ void tst_QWidget::windowState()
widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized);
QTest::qWait(100);
- const int fuzz = int(QHighDpiScaling::factor(widget1.windowHandle()));
QVERIFY(!(widget1.windowState() & Qt::WindowMaximized));
- QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
- qPrintable(msgPointMismatch(widget1.pos(), pos)));
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowMinimized);
@@ -2073,8 +2136,8 @@ void tst_QWidget::windowState()
widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized);
QTest::qWait(100);
QVERIFY(!(widget1.windowState() & (Qt::WindowMinimized|Qt::WindowMaximized)));
- QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
- qPrintable(msgPointMismatch(widget1.pos(), pos)));
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowFullScreen);
@@ -2095,8 +2158,8 @@ void tst_QWidget::windowState()
widget1.setWindowState(Qt::WindowNoState);
QTest::qWait(100);
VERIFY_STATE(Qt::WindowNoState);
- QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
- qPrintable(msgPointMismatch(widget1.pos(), pos)));
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowFullScreen);
@@ -2129,8 +2192,8 @@ void tst_QWidget::windowState()
QVERIFY(!(widget1.windowState() & stateMask));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
- QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
- qPrintable(msgPointMismatch(widget1.pos(), pos)));
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget1.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget1.pos(), pos)));
QTRY_COMPARE(widget1.size(), size);
}
@@ -2323,7 +2386,7 @@ void tst_QWidget::resizeEvent()
{
QWidget wParent;
wParent.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- wParent.resize(200, 200);
+ wParent.resize(m_testWidgetSize);
ResizeWidget wChild(&wParent);
wParent.show();
QVERIFY(QTest::qWaitForWindowExposed(&wParent));
@@ -2341,7 +2404,7 @@ void tst_QWidget::resizeEvent()
{
ResizeWidget wTopLevel;
wTopLevel.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- wTopLevel.resize(200, 200);
+ wTopLevel.resize(m_testWidgetSize);
wTopLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&wTopLevel));
if (m_platform == QStringLiteral("winrt"))
@@ -2379,17 +2442,20 @@ void tst_QWidget::showMinimized()
#ifdef Q_OS_WINRT
QEXPECT_FAIL("", "Winrt does not support move and resize", Abort);
#endif
- QCOMPARE(plain.pos(), pos);
+ QVERIFY2(HighDpi::fuzzyCompare(plain.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(plain.pos(), pos)));
plain.showNormal();
QVERIFY(!plain.isMinimized());
QVERIFY(plain.isVisible());
- QCOMPARE(plain.pos(), pos);
+ QVERIFY2(HighDpi::fuzzyCompare(plain.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(plain.pos(), pos)));
plain.showMinimized();
QVERIFY(plain.isMinimized());
QVERIFY(plain.isVisible());
- QCOMPARE(plain.pos(), pos);
+ QVERIFY2(HighDpi::fuzzyCompare(plain.pos(), pos, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(plain.pos(), pos)));
plain.hide();
QVERIFY(plain.isMinimized());
@@ -2781,7 +2847,9 @@ void tst_QWidget::setGeometry()
tlw.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
QWidget child(&tlw);
- QRect tr(100,100,200,200);
+ const QPoint topLeft = QGuiApplication::primaryScreen()->availableGeometry().topLeft();
+ const QSize initialSize = 2 * m_testWidgetSize;
+ QRect tr(topLeft + QPoint(100,100), initialSize);
QRect cr(50,50,50,50);
tlw.setGeometry(tr);
child.setGeometry(cr);
@@ -2792,8 +2860,7 @@ void tst_QWidget::setGeometry()
QCOMPARE(child.geometry(), cr);
tlw.setParent(nullptr, Qt::Window|Qt::FramelessWindowHint);
- tr = QRect(0,0,100,100);
- tr.moveTopLeft(QGuiApplication::primaryScreen()->availableGeometry().topLeft());
+ tr = QRect(topLeft, initialSize / 2);
tlw.setGeometry(tr);
QCOMPARE(tlw.geometry(), tr);
tlw.showNormal();
@@ -3265,7 +3332,8 @@ void tst_QWidget::saveRestoreGeometry()
if (m_platform == QStringLiteral("winrt"))
QEXPECT_FAIL("", "WinRT does not support move/resize", Abort);
- QTRY_COMPARE(widget.pos(), position);
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget.pos(), position, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget.pos(), position)));
QCOMPARE(widget.size(), size);
savedGeometry = widget.saveGeometry();
}
@@ -3293,10 +3361,12 @@ void tst_QWidget::saveRestoreGeometry()
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QApplication::processEvents();
- QTRY_COMPARE(widget.pos(), position);
+ QVERIFY2(HighDpi::fuzzyCompare(widget.pos(), position, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget.pos(), position)));
QCOMPARE(widget.size(), size);
widget.show();
- QCOMPARE(widget.pos(), position);
+ QVERIFY2(HighDpi::fuzzyCompare(widget.pos(), position, m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget.pos(), position)));
QCOMPARE(widget.size(), size);
}
@@ -3410,6 +3480,9 @@ void tst_QWidget::restoreVersion1Geometry()
QFETCH(QSize, expectedSize);
QFETCH(QRect, expectedNormalGeometry);
+ if (m_platform == QLatin1String("windows") && QGuiApplication::primaryScreen()->geometry().width() > 2000)
+ QSKIP("Skipping due to minimum decorated window size on Windows");
+
// WindowActive is uninteresting for this test
const Qt::WindowStates WindowStateMask = Qt::WindowFullScreen | Qt::WindowMaximized | Qt::WindowMinimized;
@@ -4990,7 +5063,8 @@ void tst_QWidget::windowMoveResize()
widget.showNormal();
QTest::qWait(10);
- QTRY_COMPARE(widget.pos(), rect.topLeft());
+ QTRY_VERIFY2(HighDpi::fuzzyCompare(widget.pos(), rect.topLeft(), m_fuzz),
+ qPrintable(HighDpi::msgPointMismatch(widget.pos(), rect.topLeft())));
// Windows: Minimum size of decorated windows.
const bool expectResizeFail = (!windowFlags && (rect.width() < 160 || rect.height() < 40))
&& m_platform == QStringLiteral("windows");
@@ -6983,7 +7057,7 @@ void tst_QWidget::renderWithPainter()
// Make sure QWidget::render does not modify the render hints set on the painter.
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform
- | QPainter::NonCosmeticDefaultPen | QPainter::TextAntialiasing);
+ | QPainter::TextAntialiasing);
QPainter::RenderHints oldRenderHints = painter.renderHints();
widget.render(&painter);
QCOMPARE(painter.renderHints(), oldRenderHints);
@@ -7581,7 +7655,7 @@ void tst_QWidget::moveWindowInShowEvent()
void tst_QWidget::repaintWhenChildDeleted()
{
#ifdef Q_OS_WIN
- if (QSysInfo::WindowsVersion & QSysInfo::WV_VISTA) {
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista) {
QTest::qWait(1000);
}
#endif
@@ -8780,7 +8854,7 @@ void tst_QWidget::translucentWidget()
#ifdef Q_OS_WIN
QWidget *desktopWidget = QApplication::desktop()->screen(0);
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista)
widgetSnapshot = grabWindow(desktopWidget->windowHandle(), labelPos.x(), labelPos.y(), label.width(), label.height());
else
#endif
@@ -8791,6 +8865,12 @@ void tst_QWidget::translucentWidget()
QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort);
QCOMPARE(actual.size(),expected.size());
QCOMPARE(actual,expected);
+
+ const QWindow *window = label.windowHandle();
+ const QSurfaceFormat translucentFormat = window->requestedFormat();
+ label.setAttribute(Qt::WA_TranslucentBackground, false);
+ const QSurfaceFormat opaqueFormat = window->requestedFormat();
+ QVERIFY(translucentFormat != opaqueFormat);
}
class MaskResizeTestWidget : public QWidget