Unskip QToolTip::keyEvent test on macOS
The test was failing because it didn't account for the platform behavior. Task-number: QTBUG-30040 Pick-to: 6.2 Change-Id: I7c523c06f0bfa459c1532cee721718bebc1858c4 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
ba8d1da4a9
commit
2b8a6d026d
@ -43,8 +43,8 @@ class tst_QToolTip : public QObject
|
|||||||
private slots:
|
private slots:
|
||||||
void init();
|
void init();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void task183679_data();
|
void keyEvent_data();
|
||||||
void task183679();
|
void keyEvent();
|
||||||
void whatsThis();
|
void whatsThis();
|
||||||
void setPalette();
|
void setPalette();
|
||||||
void qtbug64550_stylesheet();
|
void qtbug64550_stylesheet();
|
||||||
@ -62,11 +62,11 @@ void tst_QToolTip::cleanup()
|
|||||||
qApp->setStyleSheet(QString());
|
qApp->setStyleSheet(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
class Widget_task183679 : public QWidget
|
class Widget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Widget_task183679(QWidget *parent = nullptr) : QWidget(parent) {}
|
Widget(QWidget *parent = nullptr) : QWidget(parent) {}
|
||||||
|
|
||||||
void showDelayedToolTip(int msecs)
|
void showDelayedToolTip(int msecs)
|
||||||
{
|
{
|
||||||
@ -78,25 +78,32 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void showToolTip()
|
void showToolTip()
|
||||||
{
|
{
|
||||||
QToolTip::showText(mapToGlobal(QPoint(0, 0)), Widget_task183679::toolTipText(), this);
|
QToolTip::showText(mapToGlobal(QPoint(0, 0)), Widget::toolTipText(), this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Qt::Key)
|
Q_DECLARE_METATYPE(Qt::Key)
|
||||||
|
|
||||||
void tst_QToolTip::task183679_data()
|
void tst_QToolTip::keyEvent_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<Qt::Key>("key");
|
QTest::addColumn<Qt::Key>("key");
|
||||||
QTest::addColumn<bool>("visible");
|
QTest::addColumn<bool>("visible");
|
||||||
|
|
||||||
QTest::newRow("non-modifier") << Qt::Key_A << true;
|
QTest::newRow("non-modifier") << Qt::Key_A <<
|
||||||
|
#if defined(Q_OS_MACOS)
|
||||||
|
// macOS natively hides tooltips on non-modifier key events,
|
||||||
|
// so QTipLabel::eventFilter does the same. Match that here.
|
||||||
|
false;
|
||||||
|
#else
|
||||||
|
true;
|
||||||
|
#endif
|
||||||
QTest::newRow("Shift") << Qt::Key_Shift << true;
|
QTest::newRow("Shift") << Qt::Key_Shift << true;
|
||||||
QTest::newRow("Control") << Qt::Key_Control << true;
|
QTest::newRow("Control") << Qt::Key_Control << true;
|
||||||
QTest::newRow("Alt") << Qt::Key_Alt << true;
|
QTest::newRow("Alt") << Qt::Key_Alt << true;
|
||||||
QTest::newRow("Meta") << Qt::Key_Meta << true;
|
QTest::newRow("Meta") << Qt::Key_Meta << true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QToolTip::task183679()
|
void tst_QToolTip::keyEvent()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
||||||
QSKIP("Wayland: This fails. Figure out why.");
|
QSKIP("Wayland: This fails. Figure out why.");
|
||||||
@ -104,11 +111,7 @@ void tst_QToolTip::task183679()
|
|||||||
QFETCH(Qt::Key, key);
|
QFETCH(Qt::Key, key);
|
||||||
QFETCH(bool, visible);
|
QFETCH(bool, visible);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
Widget widget;
|
||||||
QSKIP("This test fails in the CI system, QTBUG-30040");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Widget_task183679 widget;
|
|
||||||
widget.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(50, 50));
|
widget.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(50, 50));
|
||||||
// Ensure cursor is not over tooltip, which causes it to hide
|
// Ensure cursor is not over tooltip, which causes it to hide
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
@ -208,7 +211,7 @@ void tst_QToolTip::qtbug64550_stylesheet()
|
|||||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
||||||
QSKIP("Wayland: This fails. Figure out why.");
|
QSKIP("Wayland: This fails. Figure out why.");
|
||||||
|
|
||||||
Widget_task183679 widget;
|
Widget widget;
|
||||||
widget.setStyleSheet(QStringLiteral("* { font-size: 48pt; }\n"));
|
widget.setStyleSheet(QStringLiteral("* { font-size: 48pt; }\n"));
|
||||||
widget.show();
|
widget.show();
|
||||||
QApplication::setActiveWindow(&widget);
|
QApplication::setActiveWindow(&widget);
|
||||||
@ -220,7 +223,7 @@ void tst_QToolTip::qtbug64550_stylesheet()
|
|||||||
QVERIFY(toolTip);
|
QVERIFY(toolTip);
|
||||||
QTRY_VERIFY(toolTip->isVisible());
|
QTRY_VERIFY(toolTip->isVisible());
|
||||||
|
|
||||||
const QRect boundingRect = QFontMetrics(widget.font()).boundingRect(Widget_task183679::toolTipText());
|
const QRect boundingRect = QFontMetrics(widget.font()).boundingRect(Widget::toolTipText());
|
||||||
const QSize toolTipSize = toolTip->size();
|
const QSize toolTipSize = toolTip->size();
|
||||||
QVERIFY2(toolTipSize.width() >= boundingRect.width()
|
QVERIFY2(toolTipSize.width() >= boundingRect.width()
|
||||||
&& toolTipSize.height() >= boundingRect.height(),
|
&& toolTipSize.height() >= boundingRect.height(),
|
||||||
|
Loading…
Reference in New Issue
Block a user