Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
- index 2f221d2..25bde4a 100644
- --- a/tests/auto/qwidget/tst_qwidget.cpp
- +++ b/tests/auto/qwidget/tst_qwidget.cpp
- @@ -375,6 +375,7 @@ private slots:
- #endif
- void updateOnDestroyedSignal();
- void toplevelLineEditFocus();
- + void focusWidgetConsistency();
- void inputFocus_task257832();
- void focusWidget_task254563();
- @@ -9483,6 +9484,39 @@ void tst_QWidget::toplevelLineEditFocus()
- QTRY_COMPARE(QApplication::focusWidget(), (QWidget*)&w);
- }
- +void tst_QWidget::focusWidgetConsistency()
- +{
- + // The value returned by QWidget::focusWidget() was not consistent
- + // depending if the focus came from setFocus() or from the window activation:
- +
- + { // 1) Using set focus before showing anything.
- + QWidget topLevel;
- + topLevel.setFocusPolicy(Qt::StrongFocus);
- + topLevel.setFocus();
- + topLevel.show();
- + QTest::qWaitForWindowShown(&topLevel);
- +
- + topLevel.activateWindow();
- + QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&topLevel);
- + QTRY_COMPARE(QApplication::focusWidget(), (QWidget*)&topLevel);
- + QVERIFY(topLevel.hasFocus());
- + QCOMPARE(topLevel.focusWidget(), &topLevel);
- + }
- +
- + { // 2) Let the window activation define the focus, no call to setFocus().
- + QWidget topLevel;
- + topLevel.setFocusPolicy(Qt::StrongFocus);
- + topLevel.show();
- + QTest::qWaitForWindowShown(&topLevel);
- +
- + topLevel.activateWindow();
- + QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&topLevel);
- + QTRY_COMPARE(QApplication::focusWidget(), (QWidget*)&topLevel);
- + QVERIFY(topLevel.hasFocus());
- + QCOMPARE(topLevel.focusWidget(), &topLevel);
- + }
- +}
- +
- void tst_QWidget::focusWidget_task254563()
- {
- //having different visibility for widget is important
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement