summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST9
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp361
2 files changed, 184 insertions, 186 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 254ca784ab..880ec6f9b4 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -12,8 +12,6 @@ ubuntu
opensuse-leap
# QTBUG-68175
opensuse-42.3
-[childEvents]
-macos
[renderInvisible]
macos
[optimizedResizeMove]
@@ -24,8 +22,6 @@ osx
macos arm
[render_systemClip]
osx
-[showMinimizedKeepsFocus]
-macos
[maskedUpdate]
opensuse
opensuse-leap
@@ -38,11 +34,6 @@ opensuse-leap
ubuntu
sles-15
-[syntheticEnterLeave]
-macos # Can't move cursor (QTBUG-76312)
-[taskQTBUG_4055_sendSyntheticEnterLeave]
-macos # Can't move cursor (QTBUG-76312)
-
# QTBUG-87668
[reparent]
android
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 74e37c8b04..63fe196459 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -296,6 +296,8 @@ private slots:
void childEvents();
void render();
+ void renderChildFillsBackground();
+ void renderTargetOffset();
void renderInvisible();
void renderWithPainter();
void render_task188133();
@@ -437,8 +439,6 @@ private slots:
void activateWhileModalHidden();
private:
- bool ensureScreenSize(int width, int height);
-
const QString m_platform;
QSize m_testWidgetSize;
QPoint m_availableTopLeft;
@@ -448,12 +448,6 @@ private:
const int m_fuzz;
};
-bool tst_QWidget::ensureScreenSize(int width, int height)
-{
- const QSize available = QGuiApplication::primaryScreen()->availableGeometry().size();
- return (available.width() >= width && available.height() >= height);
-}
-
// Testing get/set functions
void tst_QWidget::getSetCheck()
{
@@ -468,18 +462,24 @@ void tst_QWidget::getSetCheck()
QVERIFY(var1.data() != obj1.style());
QVERIFY(obj1.style() != nullptr); // style can never be 0 for a widget
+ const QRegularExpression negativeNotPossible(u"^.*Negative sizes \\(.*\\) are not possible$"_qs);
+ const QRegularExpression largestAllowedSize(u"^.*The largest allowed size is \\(.*\\)$"_qs);
// int QWidget::minimumWidth()
// void QWidget::setMinimumWidth(int)
obj1.setMinimumWidth(0);
QCOMPARE(obj1.minimumWidth(), 0);
+ QTest::ignoreMessage(QtWarningMsg, negativeNotPossible);
obj1.setMinimumWidth(INT_MIN);
QCOMPARE(obj1.minimumWidth(), 0); // A widgets width can never be less than 0
+ QTest::ignoreMessage(QtWarningMsg, largestAllowedSize);
obj1.setMinimumWidth(INT_MAX);
child1.setMinimumWidth(0);
QCOMPARE(child1.minimumWidth(), 0);
+ QTest::ignoreMessage(QtWarningMsg, negativeNotPossible);
child1.setMinimumWidth(INT_MIN);
QCOMPARE(child1.minimumWidth(), 0); // A widgets width can never be less than 0
+ QTest::ignoreMessage(QtWarningMsg, largestAllowedSize);
child1.setMinimumWidth(INT_MAX);
QCOMPARE(child1.minimumWidth(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium
@@ -487,14 +487,18 @@ void tst_QWidget::getSetCheck()
// void QWidget::setMinimumHeight(int)
obj1.setMinimumHeight(0);
QCOMPARE(obj1.minimumHeight(), 0);
+ QTest::ignoreMessage(QtWarningMsg, negativeNotPossible);
obj1.setMinimumHeight(INT_MIN);
QCOMPARE(obj1.minimumHeight(), 0); // A widgets height can never be less than 0
+ QTest::ignoreMessage(QtWarningMsg, largestAllowedSize);
obj1.setMinimumHeight(INT_MAX);
child1.setMinimumHeight(0);
QCOMPARE(child1.minimumHeight(), 0);
+ QTest::ignoreMessage(QtWarningMsg, negativeNotPossible);
child1.setMinimumHeight(INT_MIN);
QCOMPARE(child1.minimumHeight(), 0); // A widgets height can never be less than 0
+ QTest::ignoreMessage(QtWarningMsg, largestAllowedSize);
child1.setMinimumHeight(INT_MAX);
QCOMPARE(child1.minimumHeight(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium
@@ -502,8 +506,10 @@ void tst_QWidget::getSetCheck()
// void QWidget::setMaximumWidth(int)
obj1.setMaximumWidth(0);
QCOMPARE(obj1.maximumWidth(), 0);
+ QTest::ignoreMessage(QtWarningMsg, negativeNotPossible);
obj1.setMaximumWidth(INT_MIN);
QCOMPARE(obj1.maximumWidth(), 0); // A widgets width can never be less than 0
+ QTest::ignoreMessage(QtWarningMsg, largestAllowedSize);
obj1.setMaximumWidth(INT_MAX);
QCOMPARE(obj1.maximumWidth(), QWIDGETSIZE_MAX); // QWIDGETSIZE_MAX is the abs max, not INT_MAX
@@ -511,8 +517,10 @@ void tst_QWidget::getSetCheck()
// void QWidget::setMaximumHeight(int)
obj1.setMaximumHeight(0);
QCOMPARE(obj1.maximumHeight(), 0);
+ QTest::ignoreMessage(QtWarningMsg, negativeNotPossible);
obj1.setMaximumHeight(INT_MIN);
QCOMPARE(obj1.maximumHeight(), 0); // A widgets height can never be less than 0
+ QTest::ignoreMessage(QtWarningMsg, largestAllowedSize);
obj1.setMaximumHeight(INT_MAX);
QCOMPARE(obj1.maximumHeight(), QWIDGETSIZE_MAX); // QWIDGETSIZE_MAX is the abs max, not INT_MAX
@@ -572,6 +580,7 @@ void tst_QWidget::getSetCheck()
QBoxLayout *var11 = new QBoxLayout(QBoxLayout::LeftToRight);
obj1.setLayout(var11);
QCOMPARE(static_cast<QLayout *>(var11), obj1.layout());
+ QTest::ignoreMessage(QtWarningMsg, "QWidget::setLayout: Cannot set layout to 0");
obj1.setLayout(nullptr);
QCOMPARE(static_cast<QLayout *>(var11), obj1.layout()); // You cannot set a 0-pointer layout, that keeps the current
delete var11; // This will remove the layout from the widget
@@ -3198,9 +3207,8 @@ void tst_QWidget::setGeometry()
tlw.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
QWidget child(&tlw);
- const QPoint topLeft = QGuiApplication::primaryScreen()->availableGeometry().topLeft();
const QSize initialSize = 2 * m_testWidgetSize;
- QRect tr(topLeft + QPoint(100,100), initialSize);
+ QRect tr(m_availableTopLeft + QPoint(100,100), initialSize);
QRect cr(50,50,50,50);
tlw.setGeometry(tr);
child.setGeometry(cr);
@@ -3209,15 +3217,14 @@ void tst_QWidget::setGeometry()
QCOMPARE(child.geometry(), cr);
tlw.setParent(nullptr, Qt::Window|Qt::FramelessWindowHint);
- tr = QRect(topLeft, initialSize / 2);
+ tr = QRect(m_availableTopLeft, initialSize / 2);
tlw.setGeometry(tr);
QCOMPARE(tlw.geometry(), tr);
tlw.showNormal();
- QTest::qWait(50);
- if (tlw.frameGeometry() != tlw.geometry())
+ if (!QTest::qWaitFor([&tlw]{ return tlw.frameGeometry() == tlw.geometry(); }))
QSKIP("Your window manager is too broken for this test");
- if (m_platform == QStringLiteral("xcb"))
- QSKIP("QTBUG-26424");
+ if (m_platform == QStringLiteral("xcb") && tlw.geometry() != tr)
+ QEXPECT_FAIL("", "QTBUG-26424", Continue);
QCOMPARE(tlw.geometry(), tr);
}
@@ -5118,7 +5125,7 @@ void tst_QWidget::scroll()
UpdateWidget updateWidget;
updateWidget.resize(w, h);
updateWidget.reset();
- updateWidget.move(QGuiApplication::primaryScreen()->geometry().center() - QPoint(250, 250));
+ updateWidget.move(m_availableTopLeft);
updateWidget.showNormal();
QApplication::setActiveWindow(&updateWidget);
QVERIFY(QTest::qWaitForWindowActive(&updateWidget));
@@ -5768,8 +5775,7 @@ void tst_QWidget::moveChild()
parent.setStyle(style.data());
ColorWidget child(&parent, Qt::Widget, Qt::blue);
- parent.setGeometry(QRect(parent.screen()->availableGeometry().topLeft() + QPoint(50, 50),
- QSize(200, 200)));
+ parent.setGeometry(QRect(m_availableTopLeft + QPoint(50, 50), QSize(200, 200)));
child.setGeometry(25, 25, 50, 50);
#ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting
QCursor::setPos(parent.geometry().topRight() + QPoint(50 , 50));
@@ -5805,10 +5811,10 @@ void tst_QWidget::moveChild()
QTRY_COMPARE(pos, child.pos());
QTRY_COMPARE(parent.r, QRegion(oldGeometry) - child.geometry());
-#if !defined(Q_OS_MACOS)
+ if (QGuiApplication::platformName() == "cocoa")
+ QEXPECT_FAIL("", "Cocoa backing store doesn't implement scroll", Abort);
// should be scrolled in backingstore
QCOMPARE(child.r, QRegion());
-#endif
VERIFY_COLOR(child, child.rect(), child.color);
VERIFY_COLOR(parent, QRegion(parent.rect()) - child.geometry(), parent.color);
}
@@ -6440,6 +6446,9 @@ void tst_QWidget::setToolTip()
QCOMPARE(widget.toolTip(), QString());
QCOMPARE(spy.count(), 2);
+ const int wakeUpDelay = widget.style()->styleHint(QStyle::SH_ToolTip_WakeUpDelay);
+ const int fallAsleepDelay = widget.style()->styleHint(QStyle::SH_ToolTip_FallAsleepDelay);
+
for (int pass = 0; pass < 2; ++pass) {
QCursor::setPos(m_safeCursorPos);
QScopedPointer<QWidget> popup(new QWidget(nullptr, Qt::Popup));
@@ -6459,12 +6468,12 @@ void tst_QWidget::setToolTip()
QWindow *popupWindow = popup->windowHandle();
QTest::qWait(10);
QTest::mouseMove(popupWindow, QPoint(25, 25));
- QTest::qWait(900); // delay is 700
+ QTest::qWait(wakeUpDelay + 200);
QCOMPARE(spy1.count(), 1);
QCOMPARE(spy2.count(), 0);
if (pass == 0)
- QTest::qWait(2200); // delay is 2000
+ QTest::qWait(fallAsleepDelay + 200);
QTest::mouseMove(popupWindow);
}
@@ -6719,7 +6728,6 @@ void tst_QWidget::clean_qt_x11_enforce_cursor()
QTest::qWait(100);
child->setFocus();
- QApplication::processEvents();
QTest::qWait(100);
delete w;
@@ -6755,8 +6763,19 @@ public:
bool eventFilter(QObject *object, QEvent *event) override
{
QWidget *widget = qobject_cast<QWidget *>(object);
- if (widget && !event->spontaneous())
- events.append(qMakePair(widget, event->type()));
+ if (widget && !event->spontaneous()) {
+ switch (event->type()) {
+ // we might get those events if we couldn't move the cursor
+ case QEvent::Enter:
+ case QEvent::Leave:
+ // we might get this on systems that have an input method installed
+ case QEvent::InputMethodQuery:
+ break;
+ default:
+ events.append(qMakePair(widget, event->type()));
+ break;
+ }
+ }
return false;
}
@@ -6798,11 +6817,6 @@ void tst_QWidget::childEvents()
{
EventRecorder::EventList expected;
- // Move away the cursor; otherwise it might result in an enter event if it's
- // inside the widget when the widget is shown.
- QCursor::setPos(m_safeCursorPos);
- QTest::qWait(100);
-
{
// no children created, not shown
QWidget widget;
@@ -7078,7 +7092,6 @@ private:
void tst_QWidget::render()
{
- return;
QCalendarWidget source;
source.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
// disable anti-aliasing to eliminate potential differences when subpixel antialiasing
@@ -7093,16 +7106,11 @@ void tst_QWidget::render()
RenderWidget target(&source);
target.resize(source.size());
target.show();
-
- QCoreApplication::processEvents();
- QCoreApplication::sendPostedEvents();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowExposed(&target));
const QImage sourceImage = source.grab(QRect(QPoint(0, 0), QSize(-1, -1))).toImage();
- QCoreApplication::processEvents();
QImage targetImage = target.grab(QRect(QPoint(0, 0), QSize(-1, -1))).toImage();
- QCoreApplication::processEvents();
- QCOMPARE(sourceImage, targetImage);
+ QTRY_COMPARE(sourceImage, targetImage);
// Fill target.rect() will Qt::red and render
// QRegion(0, 0, source->width(), source->height() / 2, QRegion::Ellipse)
@@ -7115,55 +7123,60 @@ void tst_QWidget::render()
QVERIFY(sourceImage != targetImage);
QCOMPARE(targetImage.pixel(target.width() / 2, 29), QColor(Qt::red).rgb());
+ if (targetImage.devicePixelRatioF() > 1)
+ QEXPECT_FAIL("", "This test fails on high-DPI displays", Continue);
QCOMPARE(targetImage.pixel(target.width() / 2, 30), sourceImage.pixel(source.width() / 2, 0));
+}
- // Test that a child widget properly fills its background
- {
- QWidget window;
- window.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- window.resize(100, 100);
- // prevent custom styles
- window.setStyle(QStyleFactory::create(QLatin1String("Windows")));
- window.show();
- QVERIFY(QTest::qWaitForWindowExposed(&window));
- QWidget child(&window);
- child.resize(window.size());
- child.show();
+// Test that a child widget properly fills its background
+void tst_QWidget::renderChildFillsBackground()
+{
+ QWidget window;
+ window.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
+ window.resize(100, 100);
+ // prevent custom styles
+ window.setStyle(QStyleFactory::create(QLatin1String("Windows")));
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QWidget child(&window);
+ child.resize(window.size());
+ child.show();
- QCoreApplication::processEvents();
- const QPixmap childPixmap = child.grab(QRect(QPoint(0, 0), QSize(-1, -1)));
- const QPixmap windowPixmap = window.grab(QRect(QPoint(0, 0), QSize(-1, -1)));
- QCOMPARE(childPixmap, windowPixmap);
- }
+ QCoreApplication::processEvents();
+ const QPixmap childPixmap = child.grab(QRect(QPoint(0, 0), QSize(-1, -1)));
+ const QPixmap windowPixmap = window.grab(QRect(QPoint(0, 0), QSize(-1, -1)));
+ QEXPECT_FAIL("", "This test fails on all platforms", Continue);
+ QCOMPARE(childPixmap, windowPixmap);
+}
- { // Check that the target offset is correct.
- QWidget widget;
- widget.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- widget.resize(200, 200);
- widget.setAutoFillBackground(true);
- widget.setPalette(Qt::red);
- // prevent custom styles
- widget.setStyle(QStyleFactory::create(QLatin1String("Windows")));
- widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QImage image(widget.size(), QImage::Format_RGB32);
- image.fill(QColor(Qt::blue).rgb());
+void tst_QWidget::renderTargetOffset()
+{ // Check that the target offset is correct.
+ QWidget widget;
+ widget.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
+ widget.resize(200, 200);
+ widget.setAutoFillBackground(true);
+ widget.setPalette(Qt::red);
+ // prevent custom styles
+ widget.setStyle(QStyleFactory::create(QLatin1String("Windows")));
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QImage image(widget.size(), QImage::Format_RGB32);
+ image.fill(QColor(Qt::blue).rgb());
- // Target offset (0, 0)
- widget.render(&image, QPoint(), QRect(20, 20, 100, 100));
- QCOMPARE(image.pixel(0, 0), QColor(Qt::red).rgb());
- QCOMPARE(image.pixel(99, 99), QColor(Qt::red).rgb());
- QCOMPARE(image.pixel(100, 100), QColor(Qt::blue).rgb());
+ // Target offset (0, 0)
+ widget.render(&image, QPoint(), QRect(20, 20, 100, 100));
+ QCOMPARE(image.pixel(0, 0), QColor(Qt::red).rgb());
+ QCOMPARE(image.pixel(99, 99), QColor(Qt::red).rgb());
+ QCOMPARE(image.pixel(100, 100), QColor(Qt::blue).rgb());
- // Target offset (20, 20).
- image.fill(QColor(Qt::blue).rgb());
- widget.render(&image, QPoint(20, 20), QRect(20, 20, 100, 100));
- QCOMPARE(image.pixel(0, 0), QColor(Qt::blue).rgb());
- QCOMPARE(image.pixel(19, 19), QColor(Qt::blue).rgb());
- QCOMPARE(image.pixel(20, 20), QColor(Qt::red).rgb());
- QCOMPARE(image.pixel(119, 119), QColor(Qt::red).rgb());
- QCOMPARE(image.pixel(120, 120), QColor(Qt::blue).rgb());
- }
+ // Target offset (20, 20).
+ image.fill(QColor(Qt::blue).rgb());
+ widget.render(&image, QPoint(20, 20), QRect(20, 20, 100, 100));
+ QCOMPARE(image.pixel(0, 0), QColor(Qt::blue).rgb());
+ QCOMPARE(image.pixel(19, 19), QColor(Qt::blue).rgb());
+ QCOMPARE(image.pixel(20, 20), QColor(Qt::red).rgb());
+ QCOMPARE(image.pixel(119, 119), QColor(Qt::red).rgb());
+ QCOMPARE(image.pixel(120, 120), QColor(Qt::blue).rgb());
}
// On Windows the active palette is used instead of the inactive palette even
@@ -7212,8 +7225,6 @@ void tst_QWidget::renderInvisible()
dummyFocusWidget.move(calendar->geometry().bottomLeft() + QPoint(0, 100));
dummyFocusWidget.show();
QVERIFY(QTest::qWaitForWindowExposed(&dummyFocusWidget));
- QCoreApplication::processEvents();
- QTest::qWait(120);
// Create normal reference image.
const QSize calendarSize = calendar->size();
@@ -7227,7 +7238,6 @@ void tst_QWidget::renderInvisible()
// Create resized reference image.
const QSize calendarSizeResized = calendar->size() + QSize(50, 50);
calendar->resize(calendarSizeResized);
- QCoreApplication::processEvents();
QTest::qWait(30);
QImage referenceImageResized(calendarSizeResized, QImage::Format_ARGB32);
calendar->render(&referenceImageResized);
@@ -7238,7 +7248,6 @@ void tst_QWidget::renderInvisible()
// Explicitly hide the calendar.
calendar->hide();
- QCoreApplication::processEvents();
QTest::qWait(30);
workaroundPaletteIssue(calendar.data());
@@ -7268,7 +7277,6 @@ void tst_QWidget::renderInvisible()
}
calendar->hide();
- QCoreApplication::processEvents();
QTest::qWait(30);
{ // Calendar explicitly hidden.
@@ -7336,7 +7344,6 @@ void tst_QWidget::renderInvisible()
// Navigation bar isn't explicitly hidden anymore.
navigationBar->show();
- QCoreApplication::processEvents();
QTest::qWait(30);
QVERIFY(!calendar->isVisible());
@@ -8047,7 +8054,7 @@ void tst_QWidget::moveWindowInShowEvent_data()
QTest::addColumn<QPoint>("initial");
QTest::addColumn<QPoint>("position");
- QPoint p = QGuiApplication::primaryScreen()->availableGeometry().topLeft();
+ QPoint p = m_availableTopLeft;
QTest::newRow("1") << p << (p + QPoint(10, 10));
QTest::newRow("2") << (p + QPoint(10,10)) << p;
@@ -8084,21 +8091,15 @@ void tst_QWidget::moveWindowInShowEvent()
// show it
widget.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QTest::qWait(100);
// it should have moved
QCOMPARE(widget.pos(), position);
}
void tst_QWidget::repaintWhenChildDeleted()
{
-#ifdef Q_OS_WIN
- QTest::qWait(1000);
-#endif
ColorWidget w(nullptr, Qt::FramelessWindowHint, Qt::red);
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- QPoint startPoint = w.screen()->availableGeometry().topLeft();
- startPoint.rx() += 50;
- startPoint.ry() += 50;
+ const QPoint startPoint = m_availableTopLeft + QPoint(50, 50);
w.setGeometry(QRect(startPoint, QSize(100, 100)));
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
@@ -8121,9 +8122,7 @@ void tst_QWidget::hideOpaqueChildWhileHidden()
{
ColorWidget w(nullptr, Qt::FramelessWindowHint, Qt::red);
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- QPoint startPoint = w.screen()->availableGeometry().topLeft();
- startPoint.rx() += 50;
- startPoint.ry() += 50;
+ const QPoint startPoint = m_availableTopLeft + QPoint(50, 50);
w.setGeometry(QRect(startPoint, QSize(100, 100)));
ColorWidget child(&w, Qt::Widget, Qt::blue);
@@ -8199,7 +8198,8 @@ void tst_QWidget::updateWhileMinimized()
qDebug() << "xcb: XDG_CURRENT_DESKTOP=" << desktop;
if (desktop == QStringLiteral("ubuntu:GNOME")
|| desktop == QStringLiteral("GNOME-Classic:GNOME")
- || desktop == QStringLiteral("GNOME"))
+ || desktop == QStringLiteral("GNOME")
+ || desktop.isEmpty()) // on local VMs
count = 1;
}
QCOMPARE(widget.numPaintEvents, count);
@@ -8848,6 +8848,8 @@ public:
paintedRegion += event->region();
for (const QRect &r : event->region())
p.fillRect(r, Qt::red);
+
+ repainted = true;
}
void resizeEvent(QResizeEvent *) override
@@ -8856,6 +8858,7 @@ public:
}
QRegion paintedRegion;
+ bool repainted = false;
public slots:
void resizeDown() { setGeometry(QRect(0, 50, 50, 50)); }
@@ -8882,19 +8885,19 @@ void tst_QWidget::setMaskInResizeEvent()
w.reset();
testWidget.paintedRegion = QRegion();
- QTimer::singleShot(0, &testWidget, SLOT(resizeDown()));
- QTest::qWait(100);
+ testWidget.resizeDown();
QRegion expectedParentUpdate(0, 0, 100, 10); // Old testWidget area.
expectedParentUpdate += testWidget.geometry(); // New testWidget area.
+ QTRY_VERIFY(testWidget.repainted);
QTRY_COMPARE(w.paintedRegion, expectedParentUpdate);
QTRY_COMPARE(testWidget.paintedRegion, testWidget.mask());
testWidget.paintedRegion = QRegion();
- // Now resize the widget again, but in the oposite direction
- QTimer::singleShot(0, &testWidget, SLOT(resizeUp()));
- QTest::qWait(100);
-
+ testWidget.repainted = false;
+ // Now resize the widget again, but in the opposite direction
+ testWidget.resizeUp();
+ QTRY_VERIFY(testWidget.repainted);
QTRY_COMPARE(testWidget.paintedRegion, testWidget.mask());
}
@@ -9328,17 +9331,12 @@ void tst_QWidget::translucentWidget()
label.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
label.setFixedSize(16,16);
label.setAttribute(Qt::WA_TranslucentBackground);
- const QPoint labelPos = QGuiApplication::primaryScreen()->availableGeometry().topLeft();
- label.move(labelPos);
+ label.move(m_availableTopLeft);
label.show();
QVERIFY(QTest::qWaitForWindowExposed(&label));
QPixmap widgetSnapshot =
-#ifdef Q_OS_WIN
- QGuiApplication::primaryScreen()->grabWindow(0, labelPos.x(), labelPos.y(), label.width(), label.height());
-#else
label.grab(QRect(QPoint(0, 0), label.size()));
-#endif
const QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32);
QImage expected = pm.toImage().scaled(label.devicePixelRatio() * pm.size());
expected.setDevicePixelRatio(label.devicePixelRatio());
@@ -9709,6 +9707,8 @@ void tst_QWidget::syntheticEnterLeave()
};
QCursor::setPos(m_safeCursorPos);
+ if (!QTest::qWaitFor([this]{ return QCursor::pos() == m_safeCursorPos; }))
+ QSKIP("Can't move cursor");
MyWidget window;
window.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
@@ -9749,7 +9749,8 @@ void tst_QWidget::syntheticEnterLeave()
// Position the cursor in the middle of the window.
const QPoint globalPos = window.mapToGlobal(QPoint(100, 100));
QCursor::setPos(globalPos); // Enter child2 and grandChild.
- QTest::qWait(300);
+ if (!QTest::qWaitFor([globalPos]{ return QCursor::pos() == globalPos; }))
+ QSKIP("Can't move cursor");
QCOMPARE(window.numLeaveEvents, 0);
QCOMPARE(child2->numLeaveEvents, 0);
@@ -9947,68 +9948,74 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
int numEnterEvents = 0, numMouseMoveEvents = 0;
};
- QCursor::setPos(m_safeCursorPos);
-
- SELParent parent;
- parent.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- parent.move(200, 200);
- parent.resize(200, 200);
- SELChild child(&parent);
- child.resize(200, 200);
- parent.show();
- QVERIFY(QTest::qWaitForWindowActive(&parent));
-
- QCursor::setPos(child.mapToGlobal(QPoint(100, 100)));
- // Make sure the cursor has entered the child.
- QTRY_VERIFY(child.numEnterEvents > 0);
-
- child.hide();
- child.reset();
- child.show();
-
- // Make sure the child gets enter event and no mouse move event.
- QTRY_COMPARE(child.numEnterEvents, 1);
- QCOMPARE(child.numMouseMoveEvents, 0);
-
- child.hide();
- child.reset();
- child.setMouseTracking(true);
- child.show();
-
- // Make sure the child gets enter event.
- // Note that we verify event->button() and event->buttons()
- // in SELChild::mouseMoveEvent().
- QTRY_COMPARE(child.numEnterEvents, 1);
- QCOMPARE(child.numMouseMoveEvents, 0);
-
- // Sending synthetic enter/leave trough the parent's mousePressEvent handler.
- parent.child = &child;
-
- child.hide();
- child.reset();
- QTest::mouseClick(&parent, Qt::LeftButton);
-
- // Make sure the child gets enter event.
- QTRY_COMPARE(child.numEnterEvents, 1);
- QCOMPARE(child.numMouseMoveEvents, 0);
-
- child.hide();
- child.reset();
- QTest::keyPress(&parent, Qt::Key_Shift);
- QTest::mouseClick(&parent, Qt::LeftButton);
-
- // Make sure the child gets enter event
- QTRY_COMPARE(child.numEnterEvents, 1);
- QCOMPARE(child.numMouseMoveEvents, 0);
- QTest::keyRelease(&child, Qt::Key_Shift);
- child.hide();
- child.reset();
- child.setMouseTracking(false);
- QTest::mouseClick(&parent, Qt::LeftButton);
-
- // Make sure the child gets enter event and no mouse move event.
- QTRY_COMPARE(child.numEnterEvents, 1);
- QCOMPARE(child.numMouseMoveEvents, 0);
+ QCursor::setPos(m_safeCursorPos);
+ if (!QTest::qWaitFor([this]{ return QCursor::pos() == m_safeCursorPos; }))
+ QSKIP("Can't move cursor");
+
+ SELParent parent;
+ parent.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
+ parent.move(200, 200);
+ parent.resize(200, 200);
+ SELChild child(&parent);
+ child.resize(200, 200);
+ parent.show();
+ QVERIFY(QTest::qWaitForWindowActive(&parent));
+
+ const QPoint childPos = child.mapToGlobal(QPoint(100, 100));
+ QCursor::setPos(childPos);
+ if (!QTest::qWaitFor([childPos]{ return QCursor::pos() == childPos; }))
+ QSKIP("Can't move cursor");
+
+ // Make sure the cursor has entered the child.
+ QTRY_VERIFY(child.numEnterEvents > 0);
+
+ child.hide();
+ child.reset();
+ child.show();
+
+ // Make sure the child gets enter event and no mouse move event.
+ QTRY_COMPARE(child.numEnterEvents, 1);
+ QCOMPARE(child.numMouseMoveEvents, 0);
+
+ child.hide();
+ child.reset();
+ child.setMouseTracking(true);
+ child.show();
+
+ // Make sure the child gets enter event.
+ // Note that we verify event->button() and event->buttons()
+ // in SELChild::mouseMoveEvent().
+ QTRY_COMPARE(child.numEnterEvents, 1);
+ QCOMPARE(child.numMouseMoveEvents, 0);
+
+ // Sending synthetic enter/leave trough the parent's mousePressEvent handler.
+ parent.child = &child;
+
+ child.hide();
+ child.reset();
+ QTest::mouseClick(&parent, Qt::LeftButton);
+
+ // Make sure the child gets enter event.
+ QTRY_COMPARE(child.numEnterEvents, 1);
+ QCOMPARE(child.numMouseMoveEvents, 0);
+
+ child.hide();
+ child.reset();
+ QTest::keyPress(&parent, Qt::Key_Shift);
+ QTest::mouseClick(&parent, Qt::LeftButton);
+
+ // Make sure the child gets enter event
+ QTRY_COMPARE(child.numEnterEvents, 1);
+ QCOMPARE(child.numMouseMoveEvents, 0);
+ QTest::keyRelease(&child, Qt::Key_Shift);
+ child.hide();
+ child.reset();
+ child.setMouseTracking(false);
+ QTest::mouseClick(&parent, Qt::LeftButton);
+
+ // Make sure the child gets enter event and no mouse move event.
+ QTRY_COMPARE(child.numEnterEvents, 1);
+ QCOMPARE(child.numMouseMoveEvents, 0);
}
#endif
@@ -10515,7 +10522,7 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy()
void tst_QWidget::movedAndResizedAttributes()
{
// Use Qt::Tool as fully decorated windows have a minimum width of 160 on
- QWidget w(nullptr, Qt::Tool);
+ QWidget w;
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
w.show();
@@ -10553,11 +10560,11 @@ void tst_QWidget::movedAndResizedAttributes()
QVERIFY(!w.testAttribute(Qt::WA_Resized));
w.showNormal();
- w.move(10,10);
+ w.move(m_availableTopLeft);
QVERIFY(w.testAttribute(Qt::WA_Moved));
QVERIFY(!w.testAttribute(Qt::WA_Resized));
- w.resize(100, 100);
+ w.resize(m_testWidgetSize);
QVERIFY(w.testAttribute(Qt::WA_Moved));
QVERIFY(w.testAttribute(Qt::WA_Resized));
}