summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST1
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp70
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST2
3 files changed, 73 insertions, 0 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
index e760042def..31dbb38a5d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
@@ -1,3 +1,4 @@
# QTBUG-74760
[sorting]
opensuse-42.3
+osx
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index a437b05479..8c2d89e34b 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -89,6 +89,7 @@ private slots:
void focusNextPrevChild();
void focusOutEvent_data();
void focusOutEvent();
+ void focusProxy_QTBUG_51856();
void hoverEnterLeaveEvent_data();
void hoverEnterLeaveEvent();
void hoverMoveEvent_data();
@@ -864,6 +865,75 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
}
}
+void tst_QGraphicsProxyWidget::focusProxy_QTBUG_51856()
+{
+ // QSpinBox has an internal QLineEdit; this QLineEdit has the spinbox
+ // as its focus proxy.
+ struct FocusedSpinBox : QSpinBox
+ {
+ int focusCount = 0;
+
+ bool event(QEvent *event) override
+ {
+ switch (event->type()) {
+ case QEvent::FocusIn:
+ ++focusCount;
+ break;
+ case QEvent::FocusOut:
+ --focusCount;
+ break;
+ default:
+ break;
+ }
+ return QSpinBox::event(event);
+ }
+ };
+
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
+ scene.addItem(proxy);
+ view.show();
+ view.raise();
+ view.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ FocusedSpinBox *spinBox = new FocusedSpinBox;
+
+ proxy->setWidget(spinBox);
+ proxy->show();
+ proxy->setFocus();
+ QVERIFY(proxy->hasFocus());
+ QEXPECT_FAIL("", "Widget should have focus but doesn't", Continue);
+ QVERIFY(spinBox->hasFocus());
+ QEXPECT_FAIL("", "Widget should have focus but doesn't", Continue);
+ QCOMPARE(spinBox->focusCount, 1);
+
+ enum { Count = 10 };
+
+ for (int i = 0; i < Count; ++i) {
+ for (int clickCount = 0; clickCount < Count; ++clickCount) {
+ auto proxyCenter = proxy->boundingRect().center();
+ auto proxyCenterInScene = proxy->mapToScene(proxyCenter);
+ auto proxyCenterInView = view.mapFromScene(proxyCenterInScene);
+
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, proxyCenterInView);
+ QTRY_COMPARE(spinBox->focusCount, 1);
+ }
+
+ QLineEdit *edit = new QLineEdit(&view);
+ edit->show();
+ QTRY_VERIFY(edit->isVisible());
+ edit->setFocus();
+ QTRY_VERIFY(edit->hasFocus());
+ QTRY_VERIFY(!proxy->hasFocus());
+ QTRY_COMPARE(proxy->focusOut, i + 1);
+ QTRY_VERIFY(!spinBox->hasFocus());
+ QTRY_COMPARE(spinBox->focusCount, 0);
+ delete edit;
+ }
+}
+
class EventLogger : public QWidget
{
public:
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
index 9b76ea02ff..f59544f336 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
@@ -16,3 +16,5 @@ opensuse-42.3
[itemsInRect_cosmeticAdjust]
# QTBUG-66815
ubuntu-16.04
+[fitInView]
+osx