我需要使用qt、c++和qtest(在eclipse中)自动化GUI测试。
我有一个动态创建的菜单,里面包含动态创建的QAction。我需要测试“新建选项卡”QAction(在菜单中)。下面是它的创建方式:
m_pNewTabAction = new QAction(QIcon(":/images/add.png"), tr("&New Tab"), this);
m_pNewTabAction->setShortcut(tr("Ctrl+N"));
m_pNewTabAction->setStatusTip(tr("Open a new tab"));
connect(m_pNewTabAction, SIGNAL(triggered()), this, SLOT(NewTab()));
在我的测试类中,我使用“findChildren”函数成功访问了私有的QAction对象(m_pNewTabAction),现在我不知道如何“执行”QAction(或者换句话说,“添加一个新选项卡”)
我的测试类:
//Get the actions available for the filemenu
QList<QAction *> fileactions = filemenu->findChildren<QAction *>();
//Execute an action??
fileactions.front()-> //how do I execute my QAction?
triggered()
明确说明它在调用activate(Trigger)
时被调用。作为一个健全性检查,当用户触发操作时,选项卡是否出现? - Angew is no longer proud of SOQAction
对象,而不是使用findChildren
方法。 - thuga