summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp')
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 411c79030b..ad7ccf7d28 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -183,6 +183,7 @@ private slots:
void inputMethod();
void clickFocus();
void windowFrameMargins();
+ void QTBUG_6986_sendMouseEventToAlienWidget();
};
// Subclass that exposes the protected functions.
@@ -3583,6 +3584,70 @@ void tst_QGraphicsProxyWidget::windowFrameMargins()
QVERIFY(top > 0);
}
+class HoverButton : public QPushButton
+{
+public:
+ HoverButton(QWidget *parent = 0) : QPushButton(parent), hoverLeaveReceived(false)
+ {}
+
+ bool hoverLeaveReceived;
+
+ bool event(QEvent* e)
+ {
+ if(QEvent::HoverLeave == e->type())
+ hoverLeaveReceived = true;
+ return QPushButton::event(e);
+ }
+};
+
+class Scene : public QGraphicsScene
+{
+Q_OBJECT
+public:
+ Scene() {
+ QWidget *background = new QWidget;
+ background->setGeometry(0, 0, 500, 500);
+ hoverButton = new HoverButton;
+ hoverButton->setParent(background);
+ hoverButton->setText("Second button");
+ hoverButton->setGeometry(10, 10, 200, 50);
+ addWidget(background);
+
+ QPushButton *hideButton = new QPushButton("I'm a button with a very very long text");
+ hideButton->setGeometry(10, 10, 400, 50);
+ topButton = addWidget(hideButton);
+ connect(hideButton, SIGNAL(clicked()), this, SLOT(hideButton()));
+ topButton->setFocus();
+ }
+
+ QGraphicsProxyWidget *topButton;
+ HoverButton *hoverButton;
+
+public slots:
+ void hideButton() {
+ QCursor::setPos(600,600);
+ topButton->hide();
+ }
+};
+
+void tst_QGraphicsProxyWidget::QTBUG_6986_sendMouseEventToAlienWidget()
+{
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN) || defined(QT_NO_CURSOR)
+ QSKIP("Test case unstable on this platform", SkipAll);
+#endif
+ QGraphicsView view;
+ Scene scene;
+ view.setScene(&scene);
+ view.resize(600, 600);
+ QApplication::setActiveWindow(&view);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), &view);
+ QCursor::setPos(view.mapToGlobal(view.mapFromScene(scene.topButton->boundingRect().center())));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(scene.topButton->scenePos()));
+ QTRY_COMPARE(scene.hoverButton->hoverLeaveReceived, true);
+}
+
QTEST_MAIN(tst_QGraphicsProxyWidget)
#include "tst_qgraphicsproxywidget.moc"