summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-03-28 10:43:53 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-28 22:52:19 +0100
commit27fa02e29d873db4fdf1e77feee600f1e15e94f4 (patch)
tree0f75904089151b8a5d71365129bc3af1be85b8e3 /tests/auto
parentb980df3f3ced07f35bc9e817c53ae13d48f84994 (diff)
tst_qgraphicsproxywidget: Fix hang in actionsContextMenu().
Change the test widget to use a non-single-shot timer to hide the menu once it has become visible. The test shows hangs on Windows 8.1 CI nodes. Task-number: QTBUG-37822 Change-Id: I8fc782e53256616119920aef714f89f25863b39f Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp41
1 files changed, 31 insertions, 10 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index d3f6c2db00..5b178903cf 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -3065,21 +3065,30 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
delete boxProxy;
}
-class ContextMenuWidget : public QWidget
+class ContextMenuWidget : public QLabel
{
Q_OBJECT
public:
ContextMenuWidget()
- : embeddedPopup(false),
- gotContextMenuEvent(false)
+ : QLabel(QStringLiteral("ContextMenuWidget"))
+ , embeddedPopup(false)
+ , gotContextMenuEvent(false)
+ , m_embeddedPopupSet(false)
+ , m_timer(0)
{ }
bool embeddedPopup;
bool gotContextMenuEvent;
protected:
bool event(QEvent *event)
{
- if (event->type() == QEvent::ContextMenu)
- QTimer::singleShot(0, this, SLOT(checkMenu()));
+ if (event->type() == QEvent::ContextMenu) {
+ if (!m_timer) {
+ m_timer = new QTimer(this);
+ m_timer->setInterval(10);
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(checkMenu()));
+ m_timer->start();
+ }
+ }
return QWidget::event(event);
}
void contextMenuEvent(QContextMenuEvent *)
@@ -3090,10 +3099,19 @@ protected:
private slots:
void checkMenu()
{
- if (this->findChild<QMenu *>())
- embeddedPopup = true;
+ QMenu *menu = findChild<QMenu *>();
+ if (!m_embeddedPopupSet) {
+ m_embeddedPopupSet = true;
+ embeddedPopup = menu != 0;
+ }
+ if (menu && menu->isVisible())
+ menu->hide();
hide();
}
+
+private:
+ bool m_embeddedPopupSet;
+ QTimer *m_timer;
};
void tst_QGraphicsProxyWidget::actionsContextMenu_data()
@@ -3120,8 +3138,11 @@ void tst_QGraphicsProxyWidget::actionsContextMenu()
widget->setContextMenuPolicy(Qt::ActionsContextMenu);
}
QGraphicsScene scene;
-
+ QGraphicsProxyWidget *proxyWidget = scene.addWidget(widget);
QGraphicsView view(&scene);
+ view.setWindowTitle(QStringLiteral("actionsContextMenu"));
+ view.resize(200, 200);
+ view.move(QGuiApplication::primaryScreen()->geometry().center() - QPoint(100, 100));
view.show();
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -3129,9 +3150,9 @@ void tst_QGraphicsProxyWidget::actionsContextMenu()
QTRY_VERIFY(view.hasFocus());
if (hasFocus)
- scene.addWidget(widget)->setFocus();
+ proxyWidget->setFocus();
else
- scene.addWidget(widget)->clearFocus();
+ proxyWidget->clearFocus();
QApplication::processEvents();