In all examples write examples of a code for the description, and an example how to start it is not described for console programs all dares qExec, and here in case of GUI it is not clear. Especially in many examples in functions for tests create local objects and if for example I have to test objects to which I I can to address only through ui, how then to be?
I have simple example
#ifndef TESTGUI_H
#define TESTGUI_H
#include <QtGui/QMainWindow>
#include "ui_testgui.h"
#include <QtTest>
#include <QTest>
#include "test.h"
{
Q_OBJECT
public:
testGui
(QWidget *parent
= 0, Qt
::WFlags flags
= 0);
~testGui();
private:
Ui::testGuiClass ui;
private slots:
void on_click_button();
};
#endif // TESTGUI_H
#ifndef TESTGUI_H
#define TESTGUI_H
#include <QtGui/QMainWindow>
#include "ui_testgui.h"
#include <QtTest>
#include <QTest>
#include "test.h"
class testGui : public QMainWindow
{
Q_OBJECT
public:
testGui(QWidget *parent = 0, Qt::WFlags flags = 0);
~testGui();
private:
Ui::testGuiClass ui;
private slots:
void on_click_button();
};
#endif // TESTGUI_H
To copy to clipboard, switch view to plain text mode
#include "testgui.h"
testGui
::testGui(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
connect(ui.pushButton,SIGNAL(clicked()),this,SLOT(on_click_button()));
}
testGui::~testGui()
{
}
void testGui::on_click_button()
{
ui.
lineEdit->setText
(QString("Hello world!"));
}
#include "testgui.h"
testGui::testGui(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
connect(ui.pushButton,SIGNAL(clicked()),this,SLOT(on_click_button()));
}
testGui::~testGui()
{
}
void testGui::on_click_button()
{
ui.lineEdit->setText(QString("Hello world!"));
}
To copy to clipboard, switch view to plain text mode
#include "testgui.h"
#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
testGui w;
w.show();
return a.exec();
}
#include "testgui.h"
#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
testGui w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
What should I make to write tests for of this kind programs?
Bookmarks