diff options
author | Denis Shienkov <scapig2@yandex.ru> | 2011-10-15 20:05:56 +0400 |
---|---|---|
committer | Denis Shienkov <scapig2@yandex.ru> | 2011-10-15 20:05:56 +0400 |
commit | e62663a65cbf33c16320688a1c29098e73a2fbda (patch) | |
tree | 7762bbe4e3324b2b7d081f6087f27ad2289f5337 /tests | |
parent | 1fc2ba5735d4bea741946f7f0be61191ec4268c6 (diff) | |
download | qtserialport-e62663a65cbf33c16320688a1c29098e73a2fbda.tar.gz |
Modify unit test application
Diffstat (limited to 'tests')
-rw-r--r-- | tests/guidevtest/guidevtest.pro | 8 | ||||
-rw-r--r-- | tests/guidevtest/maindialog.cpp | 15 | ||||
-rw-r--r-- | tests/guidevtest/maindialog.h | 5 | ||||
-rw-r--r-- | tests/guidevtest/testsdialog.cpp | 7 | ||||
-rw-r--r-- | tests/guidevtest/testsdialog.h | 8 | ||||
-rw-r--r-- | tests/guidevtest/testsdialog.ui | 30 | ||||
-rw-r--r-- | tests/guidevtest/unittestmanager.cpp | 51 | ||||
-rw-r--r-- | tests/guidevtest/unittestmanager.h | 52 |
8 files changed, 158 insertions, 18 deletions
diff --git a/tests/guidevtest/guidevtest.pro b/tests/guidevtest/guidevtest.pro index 389c0f6..9ed3d0b 100644 --- a/tests/guidevtest/guidevtest.pro +++ b/tests/guidevtest/guidevtest.pro @@ -15,14 +15,16 @@ INCLUDEPATH += \ HEADERS += \ ../../include/serialport.h \ - ../../include/serialportinfo.h + ../../include/serialportinfo.h \ + unittestmanager.h include(../../src/src.pri) SOURCES += \ main.cpp \ maindialog.cpp \ - testsdialog.cpp + testsdialog.cpp \ + unittestmanager.cpp HEADERS += \ maindialog.h \ @@ -34,3 +36,5 @@ FORMS += \ + + diff --git a/tests/guidevtest/maindialog.cpp b/tests/guidevtest/maindialog.cpp index 91614bf..75cdb4b 100644 --- a/tests/guidevtest/maindialog.cpp +++ b/tests/guidevtest/maindialog.cpp @@ -5,6 +5,8 @@ #include <QtGui/QMessageBox> #include "serialportinfo.h" +#include "unittestmanager.h" +#include "testsdialog.h" /* Public methods */ @@ -13,6 +15,7 @@ MainDialog::MainDialog(QWidget *parent) , ui(new Ui::MainDialog) { ui->setupUi(this); + m_utManager = new UnitTestManager(this); m_idleState = new QState(); m_optionsState = new QState(); @@ -27,12 +30,11 @@ MainDialog::MainDialog(QWidget *parent) m_idleState->addTransition(ui->ctrlButton, SIGNAL(clicked()), m_runningState); // From Options State to ... - //... - //... + m_optionsState->addTransition(this, SIGNAL(toIdle()), m_idleState); // From Running State to ... m_runningState->addTransition(ui->ctrlButton, SIGNAL(clicked()), m_idleState); - m_runningState->addTransition(this, SIGNAL(hasError()), m_idleState); + m_runningState->addTransition(this, SIGNAL(toIdle()), m_idleState); m_stateMachine = new QStateMachine(this); m_stateMachine->addState(m_idleState); @@ -61,9 +63,10 @@ void MainDialog::procIdleState() void MainDialog::procOptionsState() { + TestsDialog dlg(m_utManager);//(); + dlg.exec(); - - + emit toIdle(); } void MainDialog::procRunningState() @@ -74,7 +77,7 @@ void MainDialog::procRunningState() msgBox.setText(tr("You can not choose the source and\n" "destination the same name.")); msgBox.exec(); - emit hasError(); + emit toIdle(); return; } ui->ctrlButton->setText(tr("Stop")); diff --git a/tests/guidevtest/maindialog.h b/tests/guidevtest/maindialog.h index 3de4014..ebbb058 100644 --- a/tests/guidevtest/maindialog.h +++ b/tests/guidevtest/maindialog.h @@ -10,13 +10,13 @@ class MainDialog; class QState; class QStateMachine; +class UnitTestManager; class MainDialog : public QDialog { Q_OBJECT - signals: - void hasError(); + void toIdle(); public: explicit MainDialog(QWidget *parent = 0); @@ -35,6 +35,7 @@ private: QState *m_optionsState; QState *m_runningState; QStateMachine *m_stateMachine; + UnitTestManager *m_utManager; }; #endif // MAINDIALOG_H diff --git a/tests/guidevtest/testsdialog.cpp b/tests/guidevtest/testsdialog.cpp index 80e46e0..3b4faa5 100644 --- a/tests/guidevtest/testsdialog.cpp +++ b/tests/guidevtest/testsdialog.cpp @@ -1,9 +1,10 @@ #include "testsdialog.h" #include "ui_testsdialog.h" +#include "unittestmanager.h" -TestsDialog::TestsDialog(QWidget *parent) - : QDialog(parent) - , ui(new Ui::TestsDialog) +TestsDialog::TestsDialog(UnitTestManager *manager) + : ui(new Ui::TestsDialog) + , m_utManager(manager) { ui->setupUi(this); } diff --git a/tests/guidevtest/testsdialog.h b/tests/guidevtest/testsdialog.h index 8a9db7b..a728229 100644 --- a/tests/guidevtest/testsdialog.h +++ b/tests/guidevtest/testsdialog.h @@ -1,22 +1,24 @@ #ifndef TESTSDIALOG_H #define TESTSDIALOG_H -#include <QDialog> +#include <QtGui/QDialog> namespace Ui { class TestsDialog; } +class UnitTestManager; + class TestsDialog : public QDialog { Q_OBJECT - public: - explicit TestsDialog(QWidget *parent = 0); + explicit TestsDialog(UnitTestManager *manager); ~TestsDialog(); private: Ui::TestsDialog *ui; + UnitTestManager *m_utManager; }; #endif // TESTSDIALOG_H diff --git a/tests/guidevtest/testsdialog.ui b/tests/guidevtest/testsdialog.ui index 5685bbd..f78fd5c 100644 --- a/tests/guidevtest/testsdialog.ui +++ b/tests/guidevtest/testsdialog.ui @@ -6,13 +6,39 @@ <rect> <x>0</x> <y>0</y> - <width>246</width> - <height>300</height> + <width>132</width> + <height>172</height> </rect> </property> <property name="windowTitle"> <string>Available tests</string> </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QListWidget" name="listWidget"/> + </item> + <item> + <widget class="QCheckBox" name="brkBox"> + <property name="text"> + <string>Break tests on error</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="optButton"> + <property name="text"> + <string>Test options</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="aplButton"> + <property name="text"> + <string>Apply</string> + </property> + </widget> + </item> + </layout> </widget> <resources/> <connections/> diff --git a/tests/guidevtest/unittestmanager.cpp b/tests/guidevtest/unittestmanager.cpp new file mode 100644 index 0000000..610d299 --- /dev/null +++ b/tests/guidevtest/unittestmanager.cpp @@ -0,0 +1,51 @@ +#include "unittestmanager.h" + +#include <QtCore/QTimer> + +/* Public methods */ + +bool UnitTestBase::isUse() const +{ + return false; +} + +UnitTestBase *UnitTestFactory::create(UnitTypes unit) +{ + return 0; +} + +UnitTestManager::UnitTestManager(QObject *parent) + : QObject(parent) + , m_count(0) + , m_it(0) +{ + m_timer = new QTimer(this); + m_timer->setInterval(1000); + connect(m_timer, SIGNAL(timeout()), this, SLOT(step())); + + // Create units. + m_unitList.append(UnitTestFactory::create(UnitTestFactory::InfoTestUnit)); + + + m_count = m_unitList.count(); +} + +/* Public slots */ + +void UnitTestManager::start() +{ + m_it = 0; + m_timer->start(); +} + +void UnitTestManager::stop() +{ + m_timer->stop(); +} + +/* Private slots */ + + void UnitTestManager::step() + { + + } diff --git a/tests/guidevtest/unittestmanager.h b/tests/guidevtest/unittestmanager.h new file mode 100644 index 0000000..399a106 --- /dev/null +++ b/tests/guidevtest/unittestmanager.h @@ -0,0 +1,52 @@ +#ifndef UNITTESTMANAGER_H +#define UNITTESTMANAGER_H + +#include <QtCore/QObject> + +class QTimer; +class UnitTestManager; + +class UnitTestBase +{ +public: + bool isUse() const; + +}; + +class UnitTestFactory +{ +public: + enum UnitTypes { + InfoTestUnit, + + }; + + static UnitTestBase *create(UnitTypes unit); +}; + +class UnitTestManager : public QObject +{ + Q_OBJECT +public: + explicit UnitTestManager(QObject *parent = 0); + +signals: + void started(); + void stopped(); + +public slots: + void start(); + void stop(); + +private slots: + void step(); + +private: + int m_count; + int m_it; + QTimer *m_timer; + QList<UnitTestBase *> m_unitList; + +}; + +#endif // UNITTESTMANAGER_H |