For all those that would like to see what is actually happening during their GUI tests while using QtTestLib. All you have to do is show the widget and start an event loop at the points you want to see or after some sequence has happened. Note that you can interact with the widget during the event loops and change the test results. This could be used to auto replay a sequence you find yourself doing over and over during testing or create an executable demo....simply drop the following code into the two files indicated and load in QtCreator or build and run from the command line as you prefer.

tst_hello.cpp
Qt Code:
  1. #include <QtGui>
  2. #include <QtTest/QtTest>
  3.  
  4. /**
  5.   * Provides a Hello Qt World Gui/Integration test.
  6.   */
  7. class tst_Hello : public QObject
  8. {
  9. Q_OBJECT
  10.  
  11. void eventLoop(const int msec);
  12.  
  13. private slots:
  14. void testGUI();
  15. };
  16.  
  17. /**
  18.   * The event loop.
  19.   */
  20. void tst_Hello::eventLoop(const int msec)
  21. {
  22. QEventLoop loop;
  23. QTimer timer;
  24. QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
  25. timer.setSingleShot(true);
  26. timer.start(msec);
  27. loop.exec();
  28. }
  29.  
  30. /**
  31.   * The test method.
  32.   */
  33. void tst_Hello::testGUI()
  34. {
  35. QLineEdit lineEdit;
  36. lineEdit.show();
  37. eventLoop(1200);
  38.  
  39. QTest::keyClicks(&lineEdit, "Hello Qt World");
  40. eventLoop(1200);
  41.  
  42. QCOMPARE(lineEdit.text(), QString("Hello Qt World"));
  43. }
  44.  
  45. QTEST_MAIN(tst_Hello)
  46. #include "tst_hello.moc"
To copy to clipboard, switch view to plain text mode 


GuiTest.pro
Qt Code:
  1. TEMPLATE = app
  2. TARGET = guitest
  3. SOURCES += tst_hello.cpp
  4. QT += testlib
To copy to clipboard, switch view to plain text mode