-
Bug
-
Resolution: Out of scope
-
P2: Important
-
4.7.0
-
None
This test case fails:
void TestQtAPI::slotAboutToShowMenu() {
if (menu != NULL) {
menu->clear();
menu->addAction("Dummy", &loop, SLOT(quit()));
}
}
void TestQtAPI::testSubmenuWorksWithoutWindows() {
QMenuBar mb;
menu = mb.addMenu("Dummy");
menu->addAction("Dummy", &loop, SLOT(quit()));
connect(menu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowMenu()));
QPoint inside1(150, 10);
QPoint inside2 = inside1 + QPoint(0, 30);
// Post a click to press the menu item:
NativeEventList native;
native.append(new QNativeMouseButtonEvent(inside1, Qt::LeftButton, 1, Qt::NoModifier));
native.append(new QNativeMouseButtonEvent(inside1, Qt::LeftButton, 0, Qt::NoModifier));
native.append(new QNativeMouseButtonEvent(inside2, Qt::LeftButton, 1, Qt::NoModifier));
native.append(new QNativeMouseButtonEvent(inside2, Qt::LeftButton, 0, Qt::NoModifier));
// Add a backup timer to end the test if we fail:
QTimer dontHang;
dontHang.setSingleShot(true);
connect(&dontHang, SIGNAL(timeout()), &loop, SLOT(quit()));
dontHang.start(3000);
native.play(NativeEventList::ReturnImmediately);
loop.exec();
QVERIFY2(dontHang.isActive(), "The item was not triggered!");
}
Replacing the call to connect() with slotAboutToShowMenu() results in the test passing.
Being able to clear and repopulate a menu is useful when implementing a Recent Items list for an application.