diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2019-11-14 13:03:46 +0100 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2019-11-19 13:53:21 +0100 |
commit | 26e876912435bdafbca2b425af43824d7ec5b876 (patch) | |
tree | b7ee83cdd9de18ce5970bab0bb217a972d3d2445 /tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp | |
parent | 7a6c6da2ebbfef33f7284ce5c96aa0c3acabc6bc (diff) | |
parent | bac999f38ca10147832846f6d7df1e4a051d3760 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: Ifecc2d9db396d783124df8567553ba5f846f30bb
Diffstat (limited to 'tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp')
-rw-r--r-- | tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp index e77faa1e75..e5a891912f 100644 --- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp +++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp @@ -34,11 +34,16 @@ #include <qapplication.h> #include <qpainter.h> #include <qstyleoption.h> -#include <qkeysequence.h> +#if QT_CONFIG(shortcut) +# include <qkeysequence.h> +#endif #include <qevent.h> #include <qgridlayout.h> #include <qabstractbutton.h> +#include <private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> + class tst_QAbstractButton : public QObject { Q_OBJECT @@ -56,7 +61,9 @@ private slots: void setText(); void setIcon(); +#if QT_CONFIG(shortcut) void setShortcut(); +#endif void animateClick(); @@ -65,7 +72,9 @@ private slots: void isChecked(); void toggled(); void setEnabled(); +#if QT_CONFIG(shortcut) void shortcutEvents(); +#endif void stopRepeatTimer(); void mouseReleased(); // QTBUG-53244 @@ -161,8 +170,10 @@ void tst_QAbstractButton::init() testWidget->setEnabled( true ); testWidget->setDown( false ); testWidget->setAutoRepeat( false ); +#if QT_CONFIG(shortcut) QKeySequence seq; testWidget->setShortcut( seq ); +#endif toggle_count = 0; press_count = 0; @@ -333,17 +344,17 @@ void tst_QAbstractButton::setText() QCOMPARE( testWidget->text(), QString("simple") ); testWidget->setText("&ersand"); QCOMPARE( testWidget->text(), QString("&ersand") ); -#ifndef Q_OS_MAC // no mneonics on Mac. +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac. QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+A")); #endif testWidget->setText("te&st"); QCOMPARE( testWidget->text(), QString("te&st") ); -#ifndef Q_OS_MAC // no mneonics on Mac. +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac. QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+S")); #endif testWidget->setText("foo"); QCOMPARE( testWidget->text(), QString("foo") ); -#ifndef Q_OS_MAC // no mneonics on Mac. +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac. QCOMPARE( testWidget->shortcut(), QKeySequence()); #endif } @@ -468,8 +479,12 @@ void tst_QAbstractButton::toggled() testWidget->setCheckable(false); } +#if QT_CONFIG(shortcut) void tst_QAbstractButton::setShortcut() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + QKeySequence seq( Qt::Key_A ); testWidget->setShortcut( seq ); QApplication::setActiveWindow(testWidget); @@ -496,6 +511,7 @@ void tst_QAbstractButton::setShortcut() // qDebug() << click_count; } +#endif // QT_CONFIG(shortcut) void tst_QAbstractButton::animateClick() { @@ -506,6 +522,8 @@ void tst_QAbstractButton::animateClick() QTRY_VERIFY( !testWidget->isDown() ); } +#if QT_CONFIG(shortcut) + void tst_QAbstractButton::shortcutEvents() { MyButton button; @@ -529,6 +547,8 @@ void tst_QAbstractButton::shortcutEvents() QCOMPARE(clickedSpy.count(), 3); } +#endif // QT_CONFIG(shortcut) + void tst_QAbstractButton::stopRepeatTimer() { MyButton button; |