GUI测试
最后更新于:2022-04-02 02:09:56
[TOC]
## GUI测试
对于GUI交互操作的测试,则将数据设置为事件列表,供模拟测试。QTestlib提供了模拟鼠标和键盘事件的功能。
事件
```
QTest::keyClick()
QTest::keyPress()
QTest::keyRelease()
QTest::mouseClick()
QTest::mouseDClick()
QTest::mouseMove()
QTest::mousePress()
QTest::mouseRelease()
```
示例
```
void TestGui::testGui()
{
QLineEdit lineEdit;
QTest::keyClicks(&lineEdit, "hello world");
QCOMPARE(lineEdit.text(), QString("hello world"));
}
```
';