pop up menu from unit test
-
I'm writing a test and need to verify the action around a popup (context) menu.
I tried to do it via right-click, but I think I'm running into https://bugreports.qt.io/browse/QTBUG-52552
I'm trying to work around that limitation by using the keyboard, but I don't see the menu pop up. I even added a qWarning() into the slot that pops up the menu, and I don't see that output when the test case runs. Note that I do see the qWarning() and the context menu when I perform these actions manually.
QTest::keyClick(pd.ui->repTable, Qt::Key_Down); QTest::keyClick(pd.ui->repTable, Qt::Key_Right); QTest::keyClick(pd.ui->repTable, Qt::Key_Menu); QTest::qWait(1000);
The widget is visible when the test is running, and I can see the effects of the down/right keys are behaving as expected. But there is no context menu.
-
Simply use QComboBox::showPopup() as it's done in tst_qcombobox: https://code.woboq.org/qt5/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp.html#932
-
@Christian-Ehrlicher The widget that needs to show the context menu is a QTableView, not a QComboBox.