qttest

How to control a QFileDialog using Qt Test?

久未见 提交于 2021-01-29 04:21:38
问题 I have 2 questions: How can I access a QFileDialog and write the path of a file in the "File name" field using the Qt Test module? I am asking that because I am developing some GUI tests in Qt and now I need to open a text file. The following code creates the QFileDialog and gets the file path: QString filePath = QFileDialog::getOpenFileName( this, "Open", "", tr("Text Files (*.txt)") ); If I am using a thread ( QThread ) to load the content in this text file, how can I wait for this thread

Functional Test for QMessageBox… why does not work?

左心房为你撑大大i 提交于 2020-06-28 08:41:10
问题 I would develop some functional tests for a pyqt application that uses PyQt (or PySide) as GUI library. The tests use Unittest and Qttest library, as reported in many resources, for example this stackoverflow question: Unit and functional testing a PySide-based application? For the main window all works fine, and the code simulate perfectly Keyboard Types and Mouse Clicks and Movements, but the " devil is in the details "... and this method does not work for a QMessageBox. In the class of the

Functional Test for QMessageBox… why does not work?

天大地大妈咪最大 提交于 2020-06-28 08:41:08
问题 I would develop some functional tests for a pyqt application that uses PyQt (or PySide) as GUI library. The tests use Unittest and Qttest library, as reported in many resources, for example this stackoverflow question: Unit and functional testing a PySide-based application? For the main window all works fine, and the code simulate perfectly Keyboard Types and Mouse Clicks and Movements, but the " devil is in the details "... and this method does not work for a QMessageBox. In the class of the

Unit testing for Qt Quick

ⅰ亾dé卋堺 提交于 2020-01-02 01:35:53
问题 I am very new to Qt and Qt Quick. I am validating the Qt Test unit testing framework for Qt Quick and I am not able to understand how to run the tests. Here's what I have, I have created a SUBDIRS project with the following structure: ProjectSolution ProjectSolution.pro Project Project.pro Sources/main.cpp Resources/qml.qrc/main.qml ProjectTest ProjectTest.pro Sources/main.cpp Resources/qml.qrc/main.qml Resources/qml.qrc/tst_gui.qml "Project" is the application to be tested and my test cases

Qt: run unit tests from multiple test classes and summarize the output from all of them

旧城冷巷雨未停 提交于 2020-01-01 04:10:07
问题 Qt comes with QTest , and there are some docs: for example, an official tutorial. However, QTest encourages you to organize unit tests as separate executables. There is special macro for this, that generates main() : QTEST_MAIN() To be honest, I really dislike this approach: generally, it is much more useful to run all tests at once, in order to make sure that recent changes haven't broken anything. Sometimes , it is useful to mask out some test or execute some individual test, but this is an

How to send a keyboard shortcut for a menu item with QTest?

浪尽此生 提交于 2019-12-31 04:01:08
问题 In a unit test, I'm trying to send the keyboard shortcut Command+N (on Mac OS), which corresponds to a menu item in my app. I'm using the PySide.QtTest module. In the code below, I'm using QTest.keyClicks , which doesn't produce what I'm expecting. The action corresponding to the shortcut is not called. class AppTestCase(TestCase): def setUp(self): qApp = QApplication.instance() if qApp is None: self.app = QApplication([]) else: self.app = qApp class IdfEditorTestCase(th.AppTestCase): def

Testing with Qt's QTestLib module

一个人想着一个人 提交于 2019-12-20 19:57:32
问题 I started writing some tests with Qt's unit testing system. How do you usually organize the tests? It is one test class per one module class, or do you test the whole module with a single test class? Qt docs suggest to follow the former strategy. I want to write tests for a module. The module provides only one class that is going to be used by the module user, but there is a lot of logic abstracted in other classes, which I would also like to test, besides testing the public class. The

How to access a QAction using the QtTest lib?

蹲街弑〆低调 提交于 2019-12-12 04:22:43
问题 I have a pop-up menu in a QTableWidget (resultTable). In the constructor of my class I set the context menu policy: resultTable->setContextMenuPolicy(Qt::CustomContextMenu); connect(resultTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popUpMenuResultTable(QPoint))); The popUpMenuResultTable function: void MyClass::popUpMenuResultTable(QPoint pos) { QMenu menu; QAction* actionExport = menu.addAction(QIcon(":/new/prefix1/FileIcon.png"), tr("Export")); connect(actionExport, SIGNAL

Unit testing for Qt Quick

耗尽温柔 提交于 2019-12-05 02:22:55
I am very new to Qt and Qt Quick. I am validating the Qt Test unit testing framework for Qt Quick and I am not able to understand how to run the tests. Here's what I have, I have created a SUBDIRS project with the following structure: ProjectSolution ProjectSolution.pro Project Project.pro Sources/main.cpp Resources/qml.qrc/main.qml ProjectTest ProjectTest.pro Sources/main.cpp Resources/qml.qrc/main.qml Resources/qml.qrc/tst_gui.qml "Project" is the application to be tested and my test cases are in "ProjectTest/Resources/qml.qrc/tst_gui.qml". tst_gui.qml: import QtQuick 2.5 import QtTest 1.0