summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp68
1 files changed, 58 insertions, 10 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 58c61d746a..a95d6e76b3 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -181,6 +181,8 @@ private slots:
void tabOrderWithCompoundWidgets();
void tabOrderNoChange();
void tabOrderNoChange2();
+ void appFocusWidgetWithFocusProxyLater();
+ void appFocusWidgetWhenLosingFocusProxy();
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void activation();
#endif
@@ -312,7 +314,9 @@ private slots:
void setMaskInResizeEvent();
void moveInResizeEvent();
- void immediateRepaintAfterInvalidateBuffer();
+#ifdef QT_BUILD_INTERNAL
+ void immediateRepaintAfterInvalidateBackingStore();
+#endif
void effectiveWinId();
void effectiveWinId2();
@@ -2029,6 +2033,51 @@ void tst_QWidget::tabOrderNoChange2()
QCOMPARE(focusChainBackward, getFocusChain(&w, false));
}
+void tst_QWidget::appFocusWidgetWithFocusProxyLater()
+{
+ // Given a lineedit without a focus proxy
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
+ QLineEdit *lineEditFocusProxy = new QLineEdit(&window);
+ QLineEdit *lineEdit = new QLineEdit(&window);
+ lineEdit->setFocus();
+ window.show();
+ QApplication::setActiveWindow(&window);
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+ QCOMPARE(QApplication::focusWidget(), lineEdit);
+
+ // When setting a focus proxy for the focus widget (like QWebEngineView does)
+ lineEdit->setFocusProxy(lineEditFocusProxy);
+
+ // Then the focus widget should be updated
+ QCOMPARE(QApplication::focusWidget(), lineEditFocusProxy);
+
+ // So that deleting the lineEdit and later the window, doesn't crash
+ delete lineEdit;
+ QCOMPARE(QApplication::focusWidget(), nullptr);
+}
+
+void tst_QWidget::appFocusWidgetWhenLosingFocusProxy()
+{
+ // Given a lineedit with a focus proxy
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
+ QLineEdit *lineEditFocusProxy = new QLineEdit(&window);
+ QLineEdit *lineEdit = new QLineEdit(&window);
+ lineEdit->setFocusProxy(lineEditFocusProxy);
+ lineEdit->setFocus();
+ window.show();
+ QApplication::setActiveWindow(&window);
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+ QCOMPARE(QApplication::focusWidget(), lineEditFocusProxy);
+
+ // When unsetting the focus proxy
+ lineEdit->setFocusProxy(nullptr);
+
+ // Then the application focus widget should be back to the lineedit
+ QCOMPARE(QApplication::focusWidget(), lineEdit);
+}
+
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void tst_QWidget::activation()
{
@@ -7742,9 +7791,6 @@ void tst_QWidget::updateWhileMinimized()
// Restore window.
widget.showNormal();
- QTest::qWait(30);
- if (m_platform == QStringLiteral("xcb"))
- QSKIP("QTBUG-26424");
QTRY_COMPARE(widget.numPaintEvents, 1);
QCOMPARE(widget.paintedRegion, QRegion(0, 0, 50, 50));
}
@@ -8296,7 +8342,7 @@ void tst_QWidget::resizeInPaintEvent()
widget.resizeInPaintEvent = true;
// This will call resize in the paintEvent, which in turn will call
- // invalidateBuffer() and a new update request should be posted.
+ // invalidateBackingStore() and a new update request should be posted.
widget.repaint();
QCOMPARE(widget.numPaintEvents, 1);
widget.numPaintEvents = 0;
@@ -8449,7 +8495,8 @@ void tst_QWidget::moveInResizeEvent()
QTRY_COMPARE(testWidget.geometry(), expectedGeometry);
}
-void tst_QWidget::immediateRepaintAfterInvalidateBuffer()
+#ifdef QT_BUILD_INTERNAL
+void tst_QWidget::immediateRepaintAfterInvalidateBackingStore()
{
if (m_platform != QStringLiteral("xcb") && m_platform != QStringLiteral("windows"))
QSKIP("We don't support immediate repaint right after show on other platforms.");
@@ -8464,7 +8511,7 @@ void tst_QWidget::immediateRepaintAfterInvalidateBuffer()
// Marks the area covered by the widget as dirty in the backing store and
// posts an UpdateRequest event.
- qt_widget_private(widget.data())->invalidateBuffer(widget->rect());
+ qt_widget_private(widget.data())->invalidateBackingStore(widget->rect());
QCOMPARE(widget->numPaintEvents, 0);
// The entire widget is already dirty, but this time we want to update immediately
@@ -8473,6 +8520,7 @@ void tst_QWidget::immediateRepaintAfterInvalidateBuffer()
widget->repaint();
QCOMPARE(widget->numPaintEvents, 1);
}
+#endif
void tst_QWidget::effectiveWinId()
{
@@ -9536,7 +9584,7 @@ QWidgetBackingStore* backingStore(QWidget &widget)
void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
{
#ifndef QT_NO_CURSOR
- QApplication::setOverrideCursor(Qt::BlankCursor); //keep the cursor out of screen grabs
+ QGuiApplication::setOverrideCursor(Qt::BlankCursor); //keep the cursor out of screen grabs
#endif
QWidget main(nullptr, Qt::FramelessWindowHint); //don't get confused by the size of the window frame
main.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
@@ -9574,7 +9622,7 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
QTRY_COMPARE(mainPixmap.toImage().convertToFormat(QImage::Format_RGB32),
correct.toImage().convertToFormat(QImage::Format_RGB32));
#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
+ QGuiApplication::restoreOverrideCursor();
#endif
}
@@ -9733,7 +9781,7 @@ public:
{
if (!static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) {
static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStoreTracker.create(this);
- static_cast<QWidgetPrivate*>(d_ptr.data())->invalidateBuffer(this->rect());
+ static_cast<QWidgetPrivate*>(d_ptr.data())->invalidateBackingStore(this->rect());
repaint();
}
}