Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
  2. index 2f221d2..25bde4a 100644
  3. --- a/tests/auto/qwidget/tst_qwidget.cpp
  4. +++ b/tests/auto/qwidget/tst_qwidget.cpp
  5. @@ -375,6 +375,7 @@ private slots:
  6. #endif
  7. void updateOnDestroyedSignal();
  8. void toplevelLineEditFocus();
  9. + void focusWidgetConsistency();
  10. void inputFocus_task257832();
  11.  
  12. void focusWidget_task254563();
  13. @@ -9483,6 +9484,39 @@ void tst_QWidget::toplevelLineEditFocus()
  14. QTRY_COMPARE(QApplication::focusWidget(), (QWidget*)&w);
  15. }
  16.  
  17. +void tst_QWidget::focusWidgetConsistency()
  18. +{
  19. + // The value returned by QWidget::focusWidget() was not consistent
  20. + // depending if the focus came from setFocus() or from the window activation:
  21. +
  22. + { // 1) Using set focus before showing anything.
  23. + QWidget topLevel;
  24. + topLevel.setFocusPolicy(Qt::StrongFocus);
  25. + topLevel.setFocus();
  26. + topLevel.show();
  27. + QTest::qWaitForWindowShown(&topLevel);
  28. +
  29. + topLevel.activateWindow();
  30. + QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&topLevel);
  31. + QTRY_COMPARE(QApplication::focusWidget(), (QWidget*)&topLevel);
  32. + QVERIFY(topLevel.hasFocus());
  33. + QCOMPARE(topLevel.focusWidget(), &topLevel);
  34. + }
  35. +
  36. + { // 2) Let the window activation define the focus, no call to setFocus().
  37. + QWidget topLevel;
  38. + topLevel.setFocusPolicy(Qt::StrongFocus);
  39. + topLevel.show();
  40. + QTest::qWaitForWindowShown(&topLevel);
  41. +
  42. + topLevel.activateWindow();
  43. + QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&topLevel);
  44. + QTRY_COMPARE(QApplication::focusWidget(), (QWidget*)&topLevel);
  45. + QVERIFY(topLevel.hasFocus());
  46. + QCOMPARE(topLevel.focusWidget(), &topLevel);
  47. + }
  48. +}
  49. +
  50. void tst_QWidget::focusWidget_task254563()
  51. {
  52. //having different visibility for widget is important
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement