QmlProfiler: Run flamegraph view context menu test on a timer

Apparently the popup window is not automatically activated.

Change-Id: I12e952568630d5ffe5d5dab9012b617a28ef9285
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Ulf Hermann
2016-06-08 13:02:12 +02:00
parent 98207ae020
commit a41593c395

View File

@@ -116,12 +116,16 @@ void FlameGraphViewTest::testContextMenu()
targetHeight = (testMenu.height() + prevHeight) / 2; targetHeight = (testMenu.height() + prevHeight) / 2;
} }
connect(view.windowHandle(), &QWindow::activeChanged, this, [&]() { QTimer timer;
if (view.windowHandle()->isActive()) timer.setInterval(50);
timer.start();
connect(&timer, &QTimer::timeout, this, [&]() {
auto activePopup = qApp->activePopupWidget();
if (!activePopup || !activePopup->windowHandle()->isExposed())
return; return;
QTest::qWaitForWindowExposed(qApp->activePopupWidget()); QTest::mouseMove(activePopup, QPoint(targetWidth, targetHeight));
QTest::mouseMove(qApp->activePopupWidget(), QPoint(targetWidth, targetHeight)); QTest::mouseClick(activePopup, Qt::LeftButton, Qt::NoModifier,
QTest::mouseClick(qApp->activePopupWidget(), Qt::LeftButton, Qt::NoModifier,
QPoint(targetWidth, targetHeight)); QPoint(targetWidth, targetHeight));
if (!manager.isRestrictedToRange()) { if (!manager.isRestrictedToRange()) {