Qt Testlib 测试GUI(2)
2014-01-01 08:19
225 查看
通过eventlist模拟多个event,测试widget对event的处理情况。
classTestGui:
public
QObject
和之前测试function的方式一样,创建testcase和添加数据函数。
voidTestGui::testGui_data()
classTestGui:
public
QObject
{
Q_OBJECT
privateslots:
voidtestGui_data();
voidtestGui();
};
和之前测试function的方式一样,创建testcase和添加数据函数。
voidTestGui::testGui_data()
{
QTest::addColumn<QTestEventList>("events");
QTest::addColumn<QString>("expected");
//通过QTestEventList保存模拟的输入按键
QTestEventListlist1;
list1.addKeyClick('a');
QTest::newRow("char")<<list1<<"a";
QTestEventListlist2;
list2.addKeyClick('a');
list2.addKeyClick(Qt::Key_Backspace);
QTest::newRow("thereandbackagain")<<list2<<"";
}
voidTestGui::testGui()
{
QFETCH(QTestEventList,events);
QFETCH(QString,expected);
QLineEditlineEdit;
events.simulate(&lineEdit);
QCOMPARE(lineEdit.text(),expected);
}
处理一组输入按键,简化测试程序。
相关文章推荐
- Qt Testlib 测试GUI(1)
- RFT(Rational Functional Test)是IBM开发的一套自动化测试工具,可以测试web, GUI和console。
- DrawTest for QT GUI Application(QT波形绘制实例)
- 基于Qt Test的单体测试方法(一)
- Qt Testlib 基本使用 (1)
- 基于Qt_Test的单体测试方法(二)
- 编译QT时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法
- 编译QT时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法
- 软件测试自动化之路(7)----在Web GUI Automation Test中使用JavaScript应注意的问题
- GUI Automation Test Distilled 图形用户界面自动化测试精粹
- libts-1.0.so.0, needed by /myroot/qt/qtlib/lib/libQtGui.so, not found (try using -rpath or -rpath-li
- 利用google test 与QTest进行GUI 测试
- 利用google test 与QTest进行GUI 测试
- /opt/qtsdk-2010.02/qt/lib/libQtGui.so: undefined reference to `FcFreeTypeQueryFace'
- Qt Testlib 基本使用 (2)
- Qt 5.9.1 参考手册 QtTest 第3章 模拟GUI事件
- 编译QT时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法
- arm编译QT4.8.5时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法
- Qt编译时出错为:warning: libts-1.0.so.0, needed by /myroot/qt/qtlib/lib/libQtGui.so, not found (try using
- Qt实现GUI的二进制文件读写操作(源码分析+工程打包+测试例子)