qtestlib

How can I get access to a QMessageBox by QTest

一曲冷凌霜 提交于 2019-12-10 10:37:24
问题 I am creating some automated GUI tests in my application using QTest . I can access the widgets from my application using the command: savePushButton = mainWindow->findChild<QPushButton *>("savePushButton"); It is working fine, but now I have to click on the OK button of a QMessageBox . I created the QMessageBox in my application like this: if( something_wrong ) { QMessageBox::warning(new Widget(), "Title", "Something wrong!"); } How can I have access to this QMessageBox , and its buttons?

How to run multiple QTest classes?

巧了我就是萌 提交于 2019-12-09 09:10:38
问题 I have a subproject where I put all my QTest unit tests and build a stand-alone test application that runs the tests (i.e. I run it from within Qt Creator). I have multiple test classes that I can execute with qExec() . However I don't know what is the proper way to execute multiple test classes. Currently I do it in this way (MVCE): tests.pro QT -= gui QT += core \ testlib CONFIG += console CONFIG -= app_bundle TEMPLATE = app TARGET = testrunner HEADERS += test_foo.h SOURCES += main.cpp main

Showing the result of QTestlib with Jenkins xUnit plug-in

送分小仙女□ 提交于 2019-12-06 20:15:50
问题 I am trying to use Jenkins xUnit plug-in for my Qt unit test project, but I cannot make it work... Here is What I've done so far: First of all, I build my unit test project with qmakebuilder plug-in (providing the .pro to the qmakebuilder plug-in), then I add an Execute Shell build section where I first rm -f the testResult xml file, following to that, I run the test binary with -xunitxml flag to have it generate the xml file for me And I name the xml file testResult.xml , in other word: rm

How can I get access to a QMessageBox by QTest

醉酒当歌 提交于 2019-12-06 03:47:44
I am creating some automated GUI tests in my application using QTest . I can access the widgets from my application using the command: savePushButton = mainWindow->findChild<QPushButton *>("savePushButton"); It is working fine, but now I have to click on the OK button of a QMessageBox . I created the QMessageBox in my application like this: if( something_wrong ) { QMessageBox::warning(new Widget(), "Title", "Something wrong!"); } How can I have access to this QMessageBox , and its buttons? I found a solution on the following link: http://www.qtcentre.org/threads/31239-Testing-modal-dialogs

How do you get a widget's children in Qt?

こ雲淡風輕ζ 提交于 2019-12-05 09:25:09
问题 I'm simulating keyPresses to an application through Qt's KeyPress function. All the KeyPresses work fine. However when I pass a QT::Key_Enter which is supposed to press the OK button of the currently active window, or QT::Key_Cancel for the cancel button, it does nothing. I'm thinking maybe, because these buttons don't have the focus, and the parent window itself has it. How do you get the children of a window? or rather find the OK or Cancel button on it so you could set it as the

Showing the result of QTestlib with Jenkins xUnit plug-in

跟風遠走 提交于 2019-12-05 01:21:21
I am trying to use Jenkins xUnit plug-in for my Qt unit test project, but I cannot make it work... Here is What I've done so far: First of all, I build my unit test project with qmakebuilder plug-in (providing the .pro to the qmakebuilder plug-in), then I add an Execute Shell build section where I first rm -f the testResult xml file, following to that, I run the test binary with -xunitxml flag to have it generate the xml file for me And I name the xml file testResult.xml , in other word: rm -f /home/guest/QT/unitTest/testResult.xml cd /home/guest/QT/unitTest ./tst_unittesttest -xunitxml >

QTcpClient successfully connects, but not to my server. Where is it connecting?

泄露秘密 提交于 2019-12-04 13:18:23
问题 I have successfully built a thin client/server using Qt's Tcp Sockets API. I know it works very well, because I have sent plenty of data over the wire and verified it. However, my project manager wants a suite of unit-tests, and I'm implementing them using Qt's Test Library. Anyhow, I'm trying to set up some dummy server to simply receive data from a QTcpSocket to verify a sendData() method in a unit test. When I connect the test socket, is shows that it is connected, but the slot for

Problems with QTest::mouseClick on QListWidget

冷暖自知 提交于 2019-12-04 04:04:01
I am trying to use QTest to do some testing. I have a QListWidget that I would like to click on to get a selection. But after the click, nothing is selected. Does anyone have any ideas? Here is my test class void TestGui::List() { TestDialog dlg; dlg.show (); // Click on the centre of the second object QListWidget *list = dlg.ListWidget (); QListWidgetItem *item = list->item ( 1 ); QRect rect = list->visualItemRect ( item ); QTest::mouseClick ( list, Qt::LeftButton, 0, rect.center() ); // Check if something was selected QCOMPARE ( list->currentRow (), 1 ); QVERIFY ( list->currentItem () !=

QTcpClient successfully connects, but not to my server. Where is it connecting?

纵然是瞬间 提交于 2019-12-03 08:42:15
I have successfully built a thin client/server using Qt's Tcp Sockets API. I know it works very well, because I have sent plenty of data over the wire and verified it. However, my project manager wants a suite of unit-tests, and I'm implementing them using Qt's Test Library. Anyhow, I'm trying to set up some dummy server to simply receive data from a QTcpSocket to verify a sendData() method in a unit test. When I connect the test socket, is shows that it is connected, but the slot for connecting the dummy server and its dummy socket is never called! Can anyone see what I'm doing wrong here? (

Qt UI testing: How to simulate a click on a QMenuBar item using QTest?

一世执手 提交于 2019-12-03 06:27:57
I am trying to simulate a mouse click on a QMenu item from a QMenuBar, for example clicking on "Save As" QAction using the QTestLib framework. I am triyng this under Windows XP 32 bit and Qt 5.0.2. Any Ideas? Probably this question is not relevant for question owner, but I suppose it could be helpful for others. Unlike QToolBar , QMenu doesn't have method widgetForAction . I found a simple workaround for this case. Try popup menu with QTest::mouseClick if nothing happens try to use QTest::keyClick(..., first_char_in_menu_tite, Qt::AltModifier) . To simulate action execution you can navigate