summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDenis Shienkov <scapig@yandex.ru>2012-02-11 20:46:02 +0400
committerDenis Shienkov <scapig@yandex.ru>2012-02-29 18:36:49 +0100
commitb8af6f604cd86897c8a04825700892fd9970a616 (patch)
tree818754c16460a321cb5fa2c212ef6e7bbf3dbd79 /tests
parenta5183e74811fd23b2de1f30053fb39f1d3083d9f (diff)
downloadqtserialport-b8af6f604cd86897c8a04825700892fd9970a616.tar.gz
The first prepare QtSerialPort to the form of add-on, with the requirements of "Creating a new module or tool for Qt"
Change-Id: I62bba3590a8873bfd03ed6836ac105e0a30d35ba Reviewed-by: Denis Shienkov <scapig@yandex.ru>
Diffstat (limited to 'tests')
-rw-r--r--tests/consolewaitreader/consolewaitreader.pro25
-rw-r--r--tests/consolewaitreader/main.cpp89
-rw-r--r--tests/consolewriter/consolewriter.pro25
-rw-r--r--tests/consolewriter/main.cpp81
-rw-r--r--tests/guiapp/guiapp.pro33
-rw-r--r--tests/guiapp/main.cpp11
-rw-r--r--tests/guiapp/maindialog.cpp173
-rw-r--r--tests/guiapp/maindialog.h48
-rw-r--r--tests/guiapp/maindialog.ui275
-rw-r--r--tests/guiapp/optionsdialog.cpp249
-rw-r--r--tests/guiapp/optionsdialog.h39
-rw-r--r--tests/guiapp/optionsdialog.ui91
-rw-r--r--tests/guiapp/tracedialog.cpp81
-rw-r--r--tests/guiapp/tracedialog.h34
-rw-r--r--tests/guiapp/tracedialog.ui70
-rw-r--r--tests/guidevtest/guidevtest.pro45
-rw-r--r--tests/guidevtest/main.cpp17
-rw-r--r--tests/guidevtest/maindialog.cpp381
-rw-r--r--tests/guidevtest/maindialog.h82
-rw-r--r--tests/guidevtest/maindialog.ui152
-rw-r--r--tests/guidevtest/unittestinfo.cpp64
-rw-r--r--tests/guidevtest/unittestio.cpp308
-rw-r--r--tests/guidevtest/unittests.h168
-rw-r--r--tests/guidevtest/unittestsignals.cpp218
-rw-r--r--tests/guidevtest/unittestwaitforx.cpp33
25 files changed, 0 insertions, 2792 deletions
diff --git a/tests/consolewaitreader/consolewaitreader.pro b/tests/consolewaitreader/consolewaitreader.pro
deleted file mode 100644
index 4418216..0000000
--- a/tests/consolewaitreader/consolewaitreader.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-TEMPLATE = app
-CONFIG += console
-QT -= gui
-OBJECTS_DIR = obj
-MOC_DIR = moc
-
-INCLUDEPATH += \
- ../../include \
- ../../src
-
-HEADERS += \
- ../../include/serialport.h \
- ../../include/serialportinfo.h
-
-include(../../src/src.pri)
-
-SOURCES += main.cpp
-
-CONFIG(debug, debug|release) {
- DESTDIR = debug
- TARGET = consolewaitreaderd
-} else {
- DESTDIR = release
- TARGET = consolewaitreader
-}
diff --git a/tests/consolewaitreader/main.cpp b/tests/consolewaitreader/main.cpp
deleted file mode 100644
index a06fa3e..0000000
--- a/tests/consolewaitreader/main.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-* ConsoleWaitReader
-*
-* This application is part of the examples on the use of the library QSerialDevice.
-*
-* ConsoleWaitReader - a test console application to read data from the port using the method
-* of expectations waitForReadyRead().
-*
-* Copyright (C) 2011 Denis Shienkov
-*
-* Contact Denis Shienkov:
-* e-mail: <scapig2@yandex.ru>
-* ICQ: 321789831
-*/
-
-#include <iostream>
-#include <QtCore/QCoreApplication>
-
-#include "serialport.h"
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
-
- // 1. First - create an instance of an object.
- SerialPort port;
-
- char inbuf[30];
-
- std::cout << "Please enter serial device name,\n"
- "specific by OS, example\n"
- "- in Windows: COMn\n"
- "- in GNU/Linux: ttyXYZn\n"
- ":";
- std::cin >> inbuf;
-
- // 2. Second - set the device name.
- port.setPort(QString(inbuf));
-
- std::cout << "The port will be opened in read-only mode (QIODevice::ReadOnly).\n"
- "But you can choose to buffered or not (QIODevice::Unbuffered).\n"
- "To understand what is the difference - try to change these modes!\n"
- "Disable buffering [y/N] ?:";
- std::cin >> inbuf;
-
- QIODevice::OpenMode mode = QIODevice::ReadOnly;
- if (inbuf[0] == 'y')
- mode |= QIODevice::Unbuffered;
-
- // 3. Third - open the device.
- if (port.open(mode)) {
-
- // 4. Fourth - now you can configure it (only after successfully opened!).
- if (port.setRate(115200) && port.setDataBits(SerialPort::Data8)
- && port.setParity(SerialPort::NoParity) && port.setStopBits(SerialPort::OneStop)
- && port.setFlowControl(SerialPort::NoFlowControl)) {
-
- int msecs = 0;
- std::cout << "Please enter wait timeout for ready read, msec: ";
- std::cin >> msecs;
-
- int len = 0;
- std::cout << "Please enter len data for read, bytes: ";
- std::cin >> len;
-
- // 5. Fifth - you can now read/write device, or further modify its settings, etc.
- while (1) {
-
- std::cout << "Now starting wait data ..." << std::endl;
-
- if ((port.bytesAvailable() > 0) || port.waitForReadyRead(msecs)) {
-
- QByteArray data = port.read(len);
-
- std::cout << "Readed " << data.size() << " bytes" << std::endl;
- } else {
- std::cout << "Wait timeout expired." << std::endl;
- }
- }
- } else {
- std::cout << "Configure " << port.portName().toLocal8Bit().constData() << " fail.";
- port.close();
- }
- } else {
- std::cout << "Open " << port.portName().toLocal8Bit().constData() << " fail.";
- }
-
- return app.exec();
-}
diff --git a/tests/consolewriter/consolewriter.pro b/tests/consolewriter/consolewriter.pro
deleted file mode 100644
index 335d92c..0000000
--- a/tests/consolewriter/consolewriter.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-TEMPLATE = app
-CONFIG += console
-QT -= gui
-OBJECTS_DIR = obj
-MOC_DIR = moc
-
-INCLUDEPATH += \
- ../../include \
- ../../src
-
-HEADERS += \
- ../../include/serialport.h \
- ../../include/serialportinfo.h
-
-include(../../src/src.pri)
-
-SOURCES += main.cpp
-
-CONFIG(debug, debug|release) {
- DESTDIR = debug
- TARGET = consolewriterd
-} else {
- DESTDIR = release
- TARGET = consolewriter
-}
diff --git a/tests/consolewriter/main.cpp b/tests/consolewriter/main.cpp
deleted file mode 100644
index e2e47d1..0000000
--- a/tests/consolewriter/main.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-* ConsoleWriter
-*
-* This application is part of the examples on the use of the library QSerialDevice.
-*
-* ConsoleWriter - a test console application to write data to the port.
-*
-* Copyright (C) 2011 Denis Shienkov
-*
-* Contact Denis Shienkov:
-* e-mail: <scapig2@yandex.ru>
-* ICQ: 321789831
-*/
-
-#include <iostream>
-#include <QtCore/QCoreApplication>
-
-#include "serialport.h"
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
-
- // 1. First - create an instance of an object.
- SerialPort port;
-
- char inbuf[30];
-
- std::cout << "Please enter serial device name,\n"
- "specific by OS, example\n"
- "- in Windows: COMn\n"
- "- in GNU/Linux: ttyXYZn\n"
- ":";
- std::cin >> inbuf;
-
- // 2. Second - set the device name.
- port.setPort(QString(inbuf));
-
- std::cout << "The port will be opened in write-only mode (QIODevice::WriteOnly).\n"
- "But you can choose to buffered or not (QIODevice::Unbuffered).\n"
- "To understand what is the difference - try to change these modes!\n"
- "Disable buffering [y/N] ?:";
- std::cin >> inbuf;
-
- QIODevice::OpenMode mode = QIODevice::WriteOnly;
- if (inbuf[0] == 'y')
- mode |= QIODevice::Unbuffered;
-
- // 3. Third - open the device.
- if (port.open(mode)) {
-
- // 4. Fourth - now you can configure it (only after successfully opened!).
- if (port.setRate(115200) && port.setDataBits(SerialPort::Data8)
- && port.setParity(SerialPort::NoParity) && port.setStopBits(SerialPort::OneStop)
- && port.setFlowControl(SerialPort::NoFlowControl)) {
-
- // 5. Fifth - you can now read/write device, or further modify its settings, etc.
- while (1) {
-
- int len = 0;
- std::cout << "Please enter len data for write, bytes: ";
- std::cin >> len;
-
- QByteArray data(len, 0);
-
- if (port.write(data)) {
- std::cout << "Writed " << data.size() << " bytes" << std::endl;
- } else {
- std::cout << "Write fail." << std::endl;
- }
- }
- } else {
- std::cout << "Configure " << port.portName().toLocal8Bit().constData() << " fail.";
- port.close();
- }
- } else {
- std::cout << "Open " << port.portName().toLocal8Bit().constData() << " fail.";
- }
-
- return app.exec();
-}
diff --git a/tests/guiapp/guiapp.pro b/tests/guiapp/guiapp.pro
deleted file mode 100644
index fd750b7..0000000
--- a/tests/guiapp/guiapp.pro
+++ /dev/null
@@ -1,33 +0,0 @@
-QT += core gui
-TEMPLATE = app
-
-linux*:DEFINES += HAVE_LIBUDEV
-
-INCLUDEPATH += \
- ../../include \
- ../../src
-
-HEADERS += \
- ../../include/serialport.h \
- ../../include/serialportinfo.h
-
-include(../../src/src.pri)
-
-SOURCES += main.cpp\
- maindialog.cpp \
- optionsdialog.cpp \
- tracedialog.cpp
-HEADERS += maindialog.h \
- optionsdialog.h \
- tracedialog.h
-FORMS += maindialog.ui \
- optionsdialog.ui \
- tracedialog.ui
-
-CONFIG(debug, debug|release) {
- DESTDIR = debug
- TARGET = guiappd
-} else {
- DESTDIR = release
- TARGET = guiapp
-}
diff --git a/tests/guiapp/main.cpp b/tests/guiapp/main.cpp
deleted file mode 100644
index 494c410..0000000
--- a/tests/guiapp/main.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <QtGui/QApplication>
-#include "maindialog.h"
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
- MainDialog dlg;
- dlg.show();
-
- return a.exec();
-}
diff --git a/tests/guiapp/maindialog.cpp b/tests/guiapp/maindialog.cpp
deleted file mode 100644
index aafcc46..0000000
--- a/tests/guiapp/maindialog.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-#include <QtCore/QStringList>
-#include <QtCore/QTimer>
-//#include <QtCore/QDebug>
-
-#include "maindialog.h"
-#include "ui_maindialog.h"
-#include "optionsdialog.h"
-#include "tracedialog.h"
-
-#include "serialportinfo.h"
-#include "serialport.h"
-
-
-/* Public methods */
-
-
-MainDialog::MainDialog(QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::MainDialog)
- , m_port(0)
- , m_timer(0)
- , m_rts(false)
- , m_dtr(false)
-{
- ui->setupUi(this);
- fillOpenModeComboBox();
-
- m_port = new SerialPort(this);
- m_timer = new QTimer(this);
- m_timer->setInterval(500);
-
- connect(m_timer, SIGNAL(timeout()), this, SLOT(procUpdateLines()));
-
- procShowPorts();
- int idx = ui->boxName->currentIndex();
- if (idx >= 0)
- procItemPortChanged(idx);
-
- connect(ui->boxName, SIGNAL(currentIndexChanged(int)), this, SLOT(procItemPortChanged(int)));
- connect(ui->controlButton, SIGNAL(clicked()), this, SLOT(procControlButtonClick()));
- connect(ui->optionsButton, SIGNAL(clicked()), this, SLOT(procOptionsButtonClick()));
- connect(ui->ioButton, SIGNAL(clicked()), this, SLOT(procIOButtonClick()));
- connect(ui->rtsButton, SIGNAL(clicked()), this, SLOT(procRtsButtonClick()));
- connect(ui->dtrButton, SIGNAL(clicked()), this, SLOT(procDtrButtonClick()));
-}
-
-MainDialog::~MainDialog()
-{
- if (m_port->isOpen())
- m_port->close();
- delete ui;
-}
-
-
-/* Protected methods */
-
-
-void MainDialog::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-
-/* Private slots */
-
-
-void MainDialog::procShowPorts()
-{
- ui->boxName->clear();
- foreach(SerialPortInfo inf, SerialPortInfo::availablePorts()) {
- QStringList sl;
- sl << inf.systemLocation() << inf.description() << inf.manufacturer();
- ui->boxName->addItem(inf.portName(), QVariant(sl));
- }
-}
-
-void MainDialog::procItemPortChanged(int idx)
-{
- QStringList sl = ui->boxName->itemData(idx).toStringList();
- ui->lbLocation->setText(sl.at(0));
- ui->lbDescr->setText(sl.at(1));
- ui->lbMfg->setText(sl.at(2));
-}
-
-void MainDialog::procControlButtonClick()
-{
- if (m_port->isOpen()) {
- m_timer->stop();
- m_port->close();
- ui->controlButton->setText(tr("Open"));
- ui->optionsButton->setEnabled(false);
- ui->ioButton->setEnabled(false);
- ui->rtsButton->setEnabled(false);
- ui->dtrButton->setEnabled(false);
- ui->boxName->setEnabled(true);
- ui->modeGroupBox->setEnabled(true);
- } else {
- m_port->setPort(ui->boxName->currentText());
- int idx = ui->modeComboBox->currentIndex();
- bool ok = false;
- idx = ui->modeComboBox->itemData(idx).toInt(&ok);
- if (ok && m_port->open((QIODevice::OpenMode)idx)) {
- ui->controlButton->setText(tr("Close"));
- ui->optionsButton->setEnabled(true);
- ui->ioButton->setEnabled(true);
- ui->rtsButton->setEnabled(true);
- ui->dtrButton->setEnabled(true);
- ui->boxName->setEnabled(false);
- ui->modeGroupBox->setEnabled(false);
- m_timer->start();
- }
- }
-}
-
-void MainDialog::procOptionsButtonClick()
-{
- OptionsDialog dlg(m_port);
- dlg.exec();
-}
-
-void MainDialog::procIOButtonClick()
-{
- TraceDialog dlg(m_port);
- dlg.exec();
-}
-
-void MainDialog::procRtsButtonClick()
-{
- m_port->setRts(!m_rts);
-}
-
-void MainDialog::procDtrButtonClick()
-{
- m_port->setDtr(!m_dtr);
-}
-
-void MainDialog::procUpdateLines()
-{
- SerialPort::Lines lines = m_port->lines();
- m_rts = SerialPort::Rts & lines;
- m_dtr = SerialPort::Dtr & lines;
-
- ui->leLabel->setEnabled(SerialPort::Le & lines);
- ui->dtrLabel->setEnabled(m_dtr);
- ui->rtsLabel->setEnabled(m_rts);
- //ui->stLabel->setEnabled(SerialPort::St & lines);
- //ui->srLabel->setEnabled(SerialPort::Sr & lines);
- ui->ctsLabel->setEnabled(SerialPort::Cts & lines);
- ui->dcdLabel->setEnabled(SerialPort::Dcd & lines);
- ui->ringLabel->setEnabled(SerialPort::Ri & lines);
- ui->dsrLabel->setEnabled(SerialPort::Dsr & lines);
-
- ui->rtsButton->setText((m_rts) ? tr("Clear RTS") : tr("Set RTS"));
- ui->dtrButton->setText((m_dtr) ? tr("Clear DTR") : tr("Set DTR"));
-}
-
-
-/* Private methods */
-
-
-void MainDialog::fillOpenModeComboBox()
-{
- ui->modeComboBox->addItem(QString(tr("Read and write")), QVariant(QIODevice::ReadWrite));
- ui->modeComboBox->addItem(QString(tr("Read only")), QVariant(QIODevice::ReadOnly));
- ui->modeComboBox->addItem(QString(tr("Write only")), QVariant(QIODevice::WriteOnly));
-}
diff --git a/tests/guiapp/maindialog.h b/tests/guiapp/maindialog.h
deleted file mode 100644
index 889c8ce..0000000
--- a/tests/guiapp/maindialog.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef MAINDIALOG_H
-#define MAINDIALOG_H
-
-#include <QtGui/QDialog>
-
-namespace Ui {
-class MainDialog;
-}
-
-class SerialPort;
-class QTimer;
-
-class MainDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit MainDialog(QWidget *parent = 0);
- ~MainDialog();
-
-protected:
- void changeEvent(QEvent *e);
-
-private slots:
- void procShowPorts();
- void procItemPortChanged(int idx);
-
- void procControlButtonClick();
- void procOptionsButtonClick();
- void procIOButtonClick();
- void procRtsButtonClick();
- void procDtrButtonClick();
-
- void procUpdateLines();
-
-private:
- Ui::MainDialog *ui;
-
- SerialPort *m_port;
- QTimer *m_timer;
-
- bool m_rts;
- bool m_dtr;
-
- void fillOpenModeComboBox();
-
-};
-
-#endif // MAINDIALOG_H
diff --git a/tests/guiapp/maindialog.ui b/tests/guiapp/maindialog.ui
deleted file mode 100644
index ed54e13..0000000
--- a/tests/guiapp/maindialog.ui
+++ /dev/null
@@ -1,275 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainDialog</class>
- <widget class="QDialog" name="MainDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>411</width>
- <height>240</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Simple GUI application for demonstrating the use of QSerialDevice.</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QGroupBox" name="modeGroupBox">
- <property name="title">
- <string>Open mode:</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QComboBox" name="modeComboBox"/>
- </item>
- </layout>
- </widget>
- </item>
- <item row="0" column="1" rowspan="5">
- <widget class="QGroupBox" name="infoGroupBox">
- <property name="title">
- <string>Available ports:</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_1">
- <property name="text">
- <string>Name:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="boxName"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Location:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="lbLocation">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Description:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="lbDescr">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Manufacturer:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QLabel" name="lbMfg">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Busy:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QLabel" name="lbBusy">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="controlButton">
- <property name="text">
- <string>Open</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="optionsButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Options</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QPushButton" name="ioButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Input/Output</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0" rowspan="2">
- <widget class="QPushButton" name="rtsButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Set RTS</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QLabel" name="lineLabel">
- <property name="text">
- <string>Serial lines states</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QPushButton" name="dtrButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Set DTR</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="Line" name="line1">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="dsrLabel">
- <property name="text">
- <string>DSR</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="dtrLabel">
- <property name="text">
- <string>DTR</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="ctsLabel">
- <property name="text">
- <string>CTS</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="rtsLabel">
- <property name="text">
- <string>RTS</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="dcdLabel">
- <property name="text">
- <string>DCD</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="ringLabel">
- <property name="text">
- <string>RING</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_4">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="leLabel">
- <property name="text">
- <string>LE</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_5">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
diff --git a/tests/guiapp/optionsdialog.cpp b/tests/guiapp/optionsdialog.cpp
deleted file mode 100644
index 0af227e..0000000
--- a/tests/guiapp/optionsdialog.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-#include <QtGui/QMessageBox>
-
-#include "optionsdialog.h"
-#include "ui_optionsdialog.h"
-
-#include "serialport.h"
-
-
-/* Public methods */
-
-
-OptionsDialog::OptionsDialog(SerialPort *port, QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::OptionsDialog)
- , m_port(port)
- , m_rate(0), m_data(0), m_parity(0), m_stop(0), m_flow(0), m_policy(0)
-{
- ui->setupUi(this);
- procFillingOptions();
-
- connect(ui->applyButton, SIGNAL(clicked()), this, SLOT(procApplyButtonClick()));
-}
-
-OptionsDialog::~OptionsDialog()
-{
- delete ui;
-}
-
-
-/* Protected methods. */
-
-
-void OptionsDialog::showEvent(QShowEvent *e)
-{
- Q_UNUSED(e)
- detectOptions();
-}
-
-
-/* Private slots */
-
-
-void OptionsDialog::procFillingOptions()
-{
- ui->baudBox->addItem(tr("9600"), SerialPort::Rate9600);
- ui->baudBox->addItem(tr("19200"), SerialPort::Rate19200);
- ui->baudBox->addItem(tr("38400"), SerialPort::Rate38400);
- ui->baudBox->addItem(tr("57600"), SerialPort::Rate57600);
- ui->baudBox->addItem(tr("115200"), SerialPort::Rate115200);
- ui->baudBox->addItem(tr("Unknown"), SerialPort::UnknownRate);
-
- ui->dataBox->addItem(tr("5"), SerialPort::Data5);
- ui->dataBox->addItem(tr("6"), SerialPort::Data6);
- ui->dataBox->addItem(tr("7"), SerialPort::Data7);
- ui->dataBox->addItem(tr("8"), SerialPort::Data8);
- ui->dataBox->addItem(tr("Unknown"), SerialPort::UnknownDataBits);
-
- ui->parityBox->addItem(tr("None"), SerialPort::NoParity);
- ui->parityBox->addItem(tr("Even"), SerialPort::EvenParity);
- ui->parityBox->addItem(tr("Odd"), SerialPort::OddParity);
- ui->parityBox->addItem(tr("Mark"), SerialPort::MarkParity);
- ui->parityBox->addItem(tr("Space"), SerialPort::SpaceParity);
- ui->parityBox->addItem(tr("Unknown"), SerialPort::UnknownParity);
-
- ui->stopBox->addItem(tr("1"), SerialPort::OneStop);
- ui->stopBox->addItem(tr("1.5"), SerialPort::OneAndHalfStop);
- ui->stopBox->addItem(tr("2"), SerialPort::TwoStop);
- ui->stopBox->addItem(tr("Unknown"), SerialPort::UnknownStopBits);
-
- ui->flowBox->addItem(tr("Off"), SerialPort::NoFlowControl);
- ui->flowBox->addItem(tr("Hardware"), SerialPort::HardwareControl);
- ui->flowBox->addItem(tr("Software"), SerialPort::SoftwareControl);
- ui->flowBox->addItem(tr("Unknown"), SerialPort::UnknownFlowControl);
-
- ui->policyBox->addItem(tr("Skip"), SerialPort::SkipPolicy);
- ui->policyBox->addItem(tr("PassZero"), SerialPort::PassZeroPolicy);
- ui->policyBox->addItem(tr("Ignore"), SerialPort::IgnorePolicy);
- ui->policyBox->addItem(tr("StopReceiving"), SerialPort::StopReceivingPolicy);
- ui->policyBox->addItem(tr("Unknown"), SerialPort::UnknownPolicy);
-}
-
-void OptionsDialog::procApplyButtonClick()
-{
- bool ok;
- bool hasChanged = false;
-
- int val = ui->baudBox->itemData(ui->baudBox->currentIndex()).toInt(&ok);
- if (val != m_rate) {
- m_port->setRate(SerialPort::Rate(val));
- hasChanged = true;
- }
-
- val = ui->dataBox->itemData(ui->dataBox->currentIndex()).toInt(&ok);
- if (val != m_data) {
- m_port->setDataBits(SerialPort::DataBits(val));
- hasChanged = true;
- }
-
- val = ui->parityBox->itemData(ui->parityBox->currentIndex()).toInt(&ok);
- if (val != m_parity) {
- m_port->setParity(SerialPort::Parity(val));
- hasChanged = true;
- }
-
- val = ui->stopBox->itemData(ui->stopBox->currentIndex()).toInt(&ok);
- if (val != m_stop) {
- m_port->setStopBits(SerialPort::StopBits(val));
- hasChanged = true;
- }
-
- val = ui->flowBox->itemData(ui->flowBox->currentIndex()).toInt(&ok);
- if (val != m_flow) {
- m_port->setFlowControl(SerialPort::FlowControl(val));
- hasChanged = true;
- }
-
- val = ui->policyBox->itemData(ui->policyBox->currentIndex()).toInt(&ok);
- if (val != m_policy) {
- m_port->setDataErrorPolicy(SerialPort::DataErrorPolicy(val));
- hasChanged = true;
- }
-
- if (hasChanged)
- detectOptions();
-}
-
-
-/* Private methods */
-
-
-void OptionsDialog::detectOptions()
-{
- m_rate = m_port->rate();
- switch (m_rate) {
- case SerialPort::Rate9600:
- case SerialPort::Rate19200:
- case SerialPort::Rate38400:
- case SerialPort::Rate57600:
- case SerialPort::Rate115200:
- break;
- default: m_rate = SerialPort::UnknownRate;
- }
- int count = ui->baudBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->baudBox->itemData(i).toInt(&ok) == m_rate) {
- ui->baudBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_data = m_port->dataBits();
- switch (m_data) {
- case SerialPort::Data5:
- case SerialPort::Data6:
- case SerialPort::Data7:
- case SerialPort::Data8:
- break;
- default: m_data = SerialPort::UnknownDataBits;
- }
- count = ui->dataBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->dataBox->itemData(i).toInt(&ok) == m_data) {
- ui->dataBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_parity = m_port->parity();
- switch (m_parity) {
- case SerialPort::NoParity:
- case SerialPort::EvenParity:
- case SerialPort::OddParity:
- case SerialPort::MarkParity:
- case SerialPort::SpaceParity:
- break;
- default: m_parity = SerialPort::UnknownParity;
- }
- count = ui->parityBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->parityBox->itemData(i).toInt(&ok) == m_parity) {
- ui->parityBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_stop = m_port->stopBits();
- switch (m_stop) {
- case SerialPort::OneStop:
- case SerialPort::OneAndHalfStop:
- case SerialPort::TwoStop:
- break;
- default: m_stop = SerialPort::UnknownStopBits;
- }
- count = ui->stopBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->stopBox->itemData(i).toInt(&ok) == m_stop) {
- ui->stopBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_flow = m_port->flowControl();
- switch (m_flow) {
- case SerialPort::NoFlowControl:
- case SerialPort::HardwareControl:
- case SerialPort::SoftwareControl:
- break;
- default: m_flow = SerialPort::UnknownFlowControl;
- }
- count = ui->flowBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->flowBox->itemData(i).toInt(&ok) == m_flow) {
- ui->flowBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_policy = m_port->dataErrorPolicy();
- switch (m_policy) {
- case SerialPort::PassZeroPolicy:
- case SerialPort::IgnorePolicy:
- case SerialPort::StopReceivingPolicy:
- break;
- default: m_flow = SerialPort::UnknownPolicy;
- }
- count = ui->policyBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->policyBox->itemData(i).toInt(&ok) == m_policy) {
- ui->policyBox->setCurrentIndex(i);
- break;
- }
- }
-}
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/guiapp/optionsdialog.h b/tests/guiapp/optionsdialog.h
deleted file mode 100644
index c4ac69d..0000000
--- a/tests/guiapp/optionsdialog.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef OPTIONSDIALOG_H
-#define OPTIONSDIALOG_H
-
-#include <QtGui/QDialog>
-
-namespace Ui {
-class OptionsDialog;
-}
-
-class SerialPort;
-
-class OptionsDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit OptionsDialog(SerialPort *port, QWidget *parent = 0);
- ~OptionsDialog();
-
-protected:
- void showEvent(QShowEvent *e);
-
-private slots:
- void procFillingOptions();
- void procApplyButtonClick();
-
-private:
- Ui::OptionsDialog *ui;
- SerialPort *m_port;
- int m_rate;
- int m_data;
- int m_parity;
- int m_stop;
- int m_flow;
- int m_policy;
-
- void detectOptions();
-};
-
-#endif // OPTIONSDIALOG_H
diff --git a/tests/guiapp/optionsdialog.ui b/tests/guiapp/optionsdialog.ui
deleted file mode 100644
index 6f5b065..0000000
--- a/tests/guiapp/optionsdialog.ui
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OptionsDialog</class>
- <widget class="QDialog" name="OptionsDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>161</width>
- <height>197</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Options</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="Label1">
- <property name="text">
- <string>Baud rate:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="baudBox"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="Label2">
- <property name="text">
- <string>Data bits:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="dataBox"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="Label3">
- <property name="text">
- <string>Parity:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QComboBox" name="parityBox"/>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="Label4">
- <property name="text">
- <string>Stop bits:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QComboBox" name="stopBox"/>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="Label5">
- <property name="text">
- <string>Flow control:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QComboBox" name="flowBox"/>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="Label6">
- <property name="text">
- <string>Policy:</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QComboBox" name="policyBox"/>
- </item>
- <item row="6" column="1">
- <widget class="QPushButton" name="applyButton">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Apply</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/tests/guiapp/tracedialog.cpp b/tests/guiapp/tracedialog.cpp
deleted file mode 100644
index f8d6d3e..0000000
--- a/tests/guiapp/tracedialog.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <QtGui/QScrollBar>
-
-#include "tracedialog.h"
-#include "ui_tracedialog.h"
-
-#include "serialport.h"
-
-
-/* Public methods */
-
-
-TraceDialog::TraceDialog(SerialPort *port, QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::TraceDialog)
- , m_port(port)
-{
- ui->setupUi(this);
- ui->textEdit->document()->setMaximumBlockCount(100);
-
- connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(procSendButtonClick()));
- connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(procClearButtonClick()));
-
- connect(m_port, SIGNAL(readyRead()), this, SLOT(procReadyRead()));
-}
-
-TraceDialog::~TraceDialog()
-{
- delete ui;
-}
-
-
-/* Protected methods */
-
-
-void TraceDialog::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-
-/* Private slots */
-
-
-void TraceDialog::printTrace(const QByteArray &data, bool directionRx)
-{
- ui->textEdit->setTextColor((directionRx) ? Qt::darkBlue : Qt::darkGreen);
- ui->textEdit->insertPlainText(QString(data));
-
- QScrollBar *bar = ui->textEdit->verticalScrollBar();
- bar->setValue(bar->maximum());
-}
-
-void TraceDialog::procSendButtonClick()
-{
- QByteArray data;
- data.append(ui->lineEdit->text());
- if (data.size() > 0) {
- m_port->write(data);
- printTrace(data, false);
- ui->lbError->setText(QString::number(m_port->error()));
- }
-}
-
-void TraceDialog::procClearButtonClick()
-{
- ui->textEdit->clear();
-}
-
-void TraceDialog::procReadyRead()
-{
- QByteArray data = m_port->readAll();
- printTrace(data, true);
- ui->lbError->setText(QString::number(m_port->error()));
-}
diff --git a/tests/guiapp/tracedialog.h b/tests/guiapp/tracedialog.h
deleted file mode 100644
index 8d5c58a..0000000
--- a/tests/guiapp/tracedialog.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef TRACEDIALOG_H
-#define TRACEDIALOG_H
-
-#include <QtGui/QDialog>
-
-namespace Ui {
-class TraceDialog;
-}
-
-class SerialPort;
-
-class TraceDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit TraceDialog(SerialPort *port, QWidget *parent = 0);
- ~TraceDialog();
-
-protected:
- void changeEvent(QEvent *e);
-
-private slots:
- void printTrace(const QByteArray &data, bool directionRx);
- void procSendButtonClick();
- void procClearButtonClick();
- void procReadyRead();
-
-private:
- Ui::TraceDialog *ui;
-
- SerialPort *m_port;
-};
-
-#endif // TRACEDIALOG_H
diff --git a/tests/guiapp/tracedialog.ui b/tests/guiapp/tracedialog.ui
deleted file mode 100644
index eef1a98..0000000
--- a/tests/guiapp/tracedialog.ui
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>TraceDialog</class>
- <widget class="QDialog" name="TraceDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>322</width>
- <height>276</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Trace</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="2">
- <widget class="QTextEdit" name="textEdit">
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="sendButton">
- <property name="text">
- <string>Send</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="lineEdit"/>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="clearButton">
- <property name="text">
- <string>Clear trace</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="label_1">
- <property name="text">
- <string>(Here enter a line in text a format for sending,
- for example: I will be transferred)</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Last error:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QLabel" name="lbError">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/tests/guidevtest/guidevtest.pro b/tests/guidevtest/guidevtest.pro
deleted file mode 100644
index b07e6f9..0000000
--- a/tests/guidevtest/guidevtest.pro
+++ /dev/null
@@ -1,45 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2011-10-15T16:26:56
-#
-#-------------------------------------------------
-
-QT += core gui
-
-TARGET = guidevtest
-TEMPLATE = app
-
-INCLUDEPATH += \
- ../../include \
- ../../src
-
-HEADERS += \
- ../../include/serialport.h \
- ../../include/serialportinfo.h
-
-include(../../src/src.pri)
-
-SOURCES += \
- main.cpp \
- maindialog.cpp \
- unittestinfo.cpp \
- unittestsignals.cpp \
- unittestwaitforx.cpp \
- unittestio.cpp
-
-HEADERS += \
- maindialog.h \
- unittests.h
-
-FORMS += \
- maindialog.ui
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/guidevtest/main.cpp b/tests/guidevtest/main.cpp
deleted file mode 100644
index 44b9ad1..0000000
--- a/tests/guidevtest/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <QtGui/QApplication>
-
-#include "maindialog.h"
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
-
- QCoreApplication::setOrganizationName("Kuzulis");
- QCoreApplication::setOrganizationDomain("kuzulis.com");
- QCoreApplication::setApplicationName("QSerialDevice unit test");
-
- MainDialog w;
- w.show();
-
- return a.exec();
-}
diff --git a/tests/guidevtest/maindialog.cpp b/tests/guidevtest/maindialog.cpp
deleted file mode 100644
index 1e3b767..0000000
--- a/tests/guidevtest/maindialog.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-#include "maindialog.h"
-#include "ui_maindialog.h"
-
-#include <QtGui/QTextEdit>
-#include <QtCore/QSettings>
-#include <QtCore/QTimer>
-#include <QtCore/QFile>
-
-#include "unittests.h"
-#include "serialportinfo.h"
-
-
-// Logger
-
-/* Public methods */
-
-Logger::Logger(QObject *parent)
- : QObject(parent), m_file(new QFile(this))
-{
-}
-
-void Logger::setFileName(const QString &name)
-{
- m_file->setFileName(name);
-}
-
-void Logger::addContent(const QString &content, bool clearAll)
-{
- QIODevice::OpenMode mode =
- QIODevice::WriteOnly | QIODevice::Text;
- mode |= (clearAll) ?
- QIODevice::Truncate : QIODevice::Append;
-
- if (m_file->open(mode)) {
- m_file->write(content.toLocal8Bit());
- m_file->close();
- }
-}
-
-
-// UnitTestBase
-
-/* Public methods */
-
-UnitTestBase::UnitTestBase(UnitID id, Logger *logger, QObject *parent)
- : QObject(parent), m_id(id), m_logger(logger)
- , m_srcPort(0), m_dstPort(0)
-{
- Q_ASSERT(logger);
- m_enableParam = "TestID%1/enable";
- m_enableParam = m_enableParam.arg(id);
-}
-
-void UnitTestBase::setPair(const QString &src, const QString &dst)
-{
- m_srcPortName = src;
- m_dstPortName = dst;
-}
-
-void UnitTestBase::setEnable(bool enable)
-{
- QSettings settings;
- settings.setValue(m_enableParam, enable);
-}
-
-bool UnitTestBase::isEnabled() const
-{
- QSettings settings;
- return settings.value(m_enableParam).toBool();
-}
-
-int UnitTestBase::id() const
-{
- return m_id;
-}
-
-QString UnitTestBase::name() const
-{
- return m_name;
-}
-
-QString UnitTestBase::description() const
-{
- return m_description;
-}
-
-
-// UnitTestFactory
-
-/* Public methods */
-
-UnitTestBase *UnitTestFactory::create(UnitTestBase::UnitID id, Logger *logger)
-{
- switch (id) {
- case UnitTestBase::InfoUnitId:
- return new UnitTestInfo(logger);
- case UnitTestBase::SignalsUnitId:
- return new UnitTestSignals(logger);
- case UnitTestBase::WaitForXUnitId:
- return new UnitTestWaitForX(logger);
- case UnitTestBase::IOUnitId:
- return new UnitTestIO(logger);
- default:;
- }
-
- return 0;
-}
-
-
-// TestsViewModel
-
-/* Public methods */
-
-TestsViewModel::TestsViewModel(const QList<UnitTestBase *> &list, QObject *parent)
- : QAbstractListModel(parent)
-{
- m_testsList = list;
-}
-
-int TestsViewModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- return m_testsList.count();
-}
-
-QVariant TestsViewModel::data(const QModelIndex &index, int role) const
-{
- if (index.isValid()
- && (index.row() < m_testsList.count())) {
- UnitTestBase *item = m_testsList.at(index.row());
- if (role == Qt::DisplayRole)
- return item->name();
- if (role == Qt::CheckStateRole)
- return item->isEnabled() ? Qt::Checked : Qt::Unchecked;
- }
- return QVariant();
-}
-
-QVariant TestsViewModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- Q_UNUSED(section);
- Q_UNUSED(orientation);
- Q_UNUSED(role);
- return QVariant();
-}
-
-Qt::ItemFlags TestsViewModel::flags(const QModelIndex &index) const
-{
- Qt::ItemFlags flag = Qt::ItemIsEnabled;
- if (index.isValid())
- flag |= Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
- return flag;
-}
-
-bool TestsViewModel::setData(const QModelIndex &index, const QVariant &value, int role)
-{
- if (index.isValid()) {
- UnitTestBase *item = m_testsList.at(index.row());
- if (role == Qt::CheckStateRole) {
- bool enable = value.toBool();
- if (item->isEnabled() != enable) {
- item->setEnable(enable);
- emit dataChanged(index, index);
- return true;
- }
- }
- }
- return false;
-}
-
-QModelIndex TestsViewModel::index(int row, int column, const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- if (row < m_testsList.count())
- return createIndex(row, column, m_testsList.at(row));
- return QModelIndex();
-}
-
-
-// DescriptionDialog
-
-/* Public methods */
-
-DescriptionDialog::DescriptionDialog(const QString &content, QWidget *parent)
- : QDialog(parent)
-{
- QTextEdit *widget = new QTextEdit;
- widget->setReadOnly(true);
- widget->setText(content);
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(widget);
- setLayout(layout);
-}
-
-
-// MainDialog
-
-/* Public methods */
-
-MainDialog::MainDialog(QWidget *parent)
- : QDialog(parent), ui(new Ui::MainDialog)
- , m_enabledTestsCount(0), m_it(0)
-{
- ui->setupUi(this);
-
- m_logger = new Logger(this);
-
- fillPairs();
- showSettings();
- createAvailableTests();
-
- m_model = new TestsViewModel(m_testsList, this);
- ui->listView->setModel(m_model);
-
- connect(ui->logLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(procLogChanged(QString)));
- connect(ui->clearLogCheckBox, SIGNAL(clicked(bool)),
- this, SLOT(procClearLogOnStartChanged(bool)));
- connect(ui->breakAllCheckBox, SIGNAL(clicked(bool)),
- this, SLOT(procBreakAllOnErrorChanged(bool)));
-
- connect(ui->startButton, SIGNAL(clicked()),
- this, SLOT(procStartButtonClick()));
-
- connect(ui->listView, SIGNAL(doubleClicked(QModelIndex)),
- this, SLOT(procItemDoubleClick(QModelIndex)));
-}
-
-MainDialog::~MainDialog()
-{
- delete ui;
-}
-
-/* Private slots */
-
-void MainDialog::procLogChanged(const QString &log)
-{
- QSettings settings;
- settings.setValue(logFileSettingsKey, log);
-}
-
-void MainDialog::procClearLogOnStartChanged(bool enable)
-{
- QSettings settings;
- settings.setValue(clearLogOnStartSettingsKey, enable);
-}
-
-void MainDialog::procBreakAllOnErrorChanged(bool enable)
-{
- QSettings settings;
- settings.setValue(breakOnErrorSettingsKey, enable);
-}
-
-void MainDialog::procStartButtonClick()
-{
- // Check pair
- if (ui->srcComboBox->currentText() == ui->dstComboBox->currentText())
- return;
-
- // Get enabled tests num
- m_enabledTestsCount = 0;
- foreach (UnitTestBase *test, m_testsList) {
- if (test->isEnabled())
- ++m_enabledTestsCount;
- }
- if (!m_enabledTestsCount)
- return;
-
- ui->progressBar->setValue(0);
- ui->progressBar->setMaximum(m_enabledTestsCount);
-
- m_logger->setFileName(qApp->applicationDirPath()
- + "/"
- + ui->logLineEdit->text());
-
- // Start run
- QString header(tr("\n*** S T A R T E D ***\n"));
- m_logger->addContent(header, ui->clearLogCheckBox->isChecked());
- procTestStarted();
- enableUi(false);
-}
-
-void MainDialog::procTestStarted()
-{
- UnitTestBase *test = m_testsList.at(m_it++);
- if (test->isEnabled()) {
- test->setPair(ui->srcComboBox->currentText(),
- ui->dstComboBox->currentText());
- QTimer::singleShot(1000, test, SLOT(start()));
- }
- else
- procTestStarted();
-}
-
-void MainDialog::procTestFinished()
-{
- ui->progressBar->setValue(ui->progressBar->maximum() - (--m_enabledTestsCount));
- if (m_enabledTestsCount == 0) {
- enableUi(true);
- m_it = 0;
-
- QString trailer(tr("\n*** S T O P P E D ***\n"));
- m_logger->addContent(trailer);
- return;
- }
- else
- procTestStarted();
-}
-
-void MainDialog::procTestError()
-{
- if (ui->breakAllCheckBox->isChecked()) {
- m_enabledTestsCount = 0;
- m_it = 0;
- enableUi(true);
- QString trailer(tr("\n*** B R E A K ***\n"));
- m_logger->addContent(trailer);
- } else {
- procTestFinished();
- }
-}
-
-void MainDialog::procItemDoubleClick(const QModelIndex &index)
-{
- QString title(tr("About: <%1>"));
- title = title.arg(index.data().toString());
- DescriptionDialog w(static_cast<UnitTestBase *>(index.internalPointer())->description());
- w.setWindowTitle(title);
- w.exec();
-}
-
-/* Private methods */
-
-const QString MainDialog::logFileSettingsKey = "MainDialog/logFileName";
-const QString MainDialog::breakOnErrorSettingsKey = "MainDialog/breakOnError";
-const QString MainDialog::clearLogOnStartSettingsKey = "MainDialog/clearLogOnStart";
-
-void MainDialog::showSettings()
-{
- QSettings settings;
- ui->logLineEdit->setText(settings.value(logFileSettingsKey).toString());
- ui->clearLogCheckBox->setChecked(settings.value(clearLogOnStartSettingsKey).toBool());
- ui->breakAllCheckBox->setChecked(settings.value(breakOnErrorSettingsKey).toBool());
-}
-
-// Called only in constructor!
-void MainDialog::createAvailableTests()
-{
- // Create "Info test"
- m_testsList.append(UnitTestFactory::create(UnitTestBase::InfoUnitId, m_logger));
- // Create "Signals test"
- m_testsList.append(UnitTestFactory::create(UnitTestBase::SignalsUnitId, m_logger));
- // Create "WaitForX test"
- m_testsList.append(UnitTestFactory::create(UnitTestBase::WaitForXUnitId, m_logger));
- // Create "IO test"
- m_testsList.append(UnitTestFactory::create(UnitTestBase::IOUnitId, m_logger));
-
-
- foreach(UnitTestBase *test, m_testsList) {
- connect(test, SIGNAL(finished()), this, SLOT(procTestFinished()));
- connect(test, SIGNAL(error()), this, SLOT(procTestError()));
- }
-}
-
-// Called only in constructor!
-void MainDialog::fillPairs()
-{
- QStringList list;
- foreach (SerialPortInfo inf, SerialPortInfo::availablePorts()) {
- if (inf.isValid() && !inf.isBusy())
- list.append(inf.portName());
- }
- ui->srcComboBox->addItems(list);
- ui->dstComboBox->addItems(list);
-}
-
-void MainDialog::enableUi(bool enable)
-{
- ui->scrollArea->setEnabled(enable);
- ui->startButton->setEnabled(enable);
-}
diff --git a/tests/guidevtest/maindialog.h b/tests/guidevtest/maindialog.h
deleted file mode 100644
index 3e1a261..0000000
--- a/tests/guidevtest/maindialog.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef MAINDIALOG_H
-#define MAINDIALOG_H
-
-#include <QtGui/QDialog>
-#include <QtCore/QAbstractListModel>
-
-
-
-namespace Ui {
-class MainDialog;
-}
-
-class UnitTestBase;
-
-class TestsViewModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- explicit TestsViewModel(const QList<UnitTestBase *> &list, QObject *parent = 0);
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
- virtual QVariant data(const QModelIndex &index, int role) const;
- virtual QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
- virtual Qt::ItemFlags flags(const QModelIndex &index) const;
- virtual bool setData(const QModelIndex &index, const QVariant &value,
- int role = Qt::EditRole);
- virtual QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex()) const;
-
-private:
- QList<UnitTestBase *> m_testsList;
-};
-
-
-class DescriptionDialog : public QDialog
-{
-public:
- explicit DescriptionDialog(const QString &content, QWidget *parent = 0);
-};
-
-
-class Logger;
-class QModelIndex;
-
-class MainDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit MainDialog(QWidget *parent = 0);
- ~MainDialog();
-
-private slots:
- void procLogChanged(const QString &log);
- void procClearLogOnStartChanged(bool enable);
- void procBreakAllOnErrorChanged(bool enable);
-
- void procStartButtonClick();
- void procTestStarted();
- void procTestFinished();
- void procTestError();
-
- void procItemDoubleClick(const QModelIndex &index);
-
-private:
- Ui::MainDialog *ui;
- TestsViewModel *m_model;
- QList<UnitTestBase *> m_testsList;
- Logger *m_logger;
- int m_enabledTestsCount;
- int m_it;
-
- static const QString logFileSettingsKey;
- static const QString breakOnErrorSettingsKey;
- static const QString clearLogOnStartSettingsKey;
-
- void showSettings();
- void createAvailableTests();
- void fillPairs();
- void enableUi(bool enable);
-};
-
-#endif // MAINDIALOG_H
diff --git a/tests/guidevtest/maindialog.ui b/tests/guidevtest/maindialog.ui
deleted file mode 100644
index a86bd72..0000000
--- a/tests/guidevtest/maindialog.ui
+++ /dev/null
@@ -1,152 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainDialog</class>
- <widget class="QDialog" name="MainDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>172</width>
- <height>307</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Quick test</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QScrollArea" name="scrollArea">
- <property name="widgetResizable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="scrollAreaWidgetContents">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>158</width>
- <height>248</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QListView" name="listView">
- <property name="toolTip">
- <string>Double Click by test item for get a description.</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="srcLabel">
- <property name="text">
- <string>Src:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="srcComboBox">
- <property name="toolTip">
- <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:7pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Select source port for pair.&lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2';&quot;&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; text-decoration: underline; color:#ff0000;&quot;&gt;Note:&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; color:#ff0000;&quot;&gt; &lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; color:#ff0000;&quot;&gt;Source port and destination port should be different!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="dstLabel">
- <property name="text">
- <string>Dst:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="dstComboBox">
- <property name="toolTip">
- <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:7pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Select destination port for pair.&lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2';&quot;&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; text-decoration: underline; color:#ff0000;&quot;&gt;Note:&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; color:#ff0000;&quot;&gt; &lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; color:#ff0000;&quot;&gt;Source port and destination port should be different!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="logLabel">
- <property name="text">
- <string>Log:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLineEdit" name="logLineEdit">
- <property name="toolTip">
- <string>Write here the name of the log file.</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QCheckBox" name="clearLogCheckBox">
- <property name="toolTip">
- <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:7pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Clears the log file before starting the queue test.&lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Otherwise, all subsequent entries will be appended to the end of file.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="text">
- <string>Clear log on start.</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="2">
- <widget class="QCheckBox" name="breakAllCheckBox">
- <property name="toolTip">
- <string>Terminates all the tests, if at least one test failed.
-Error condition is given by the developer within the test manually.
-Change the condition on which an error, can only change your test code and recompiling the application again.</string>
- </property>
- <property name="text">
- <string>Break all on error</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="startButton">
- <property name="text">
- <string>Start tests</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QProgressBar" name="progressBar">
- <property name="value">
- <number>0</number>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
diff --git a/tests/guidevtest/unittestinfo.cpp b/tests/guidevtest/unittestinfo.cpp
deleted file mode 100644
index 08bcc26..0000000
--- a/tests/guidevtest/unittestinfo.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "unittests.h"
-#include "serialportinfo.h"
-
-
-
-/* Public methods */
-
-UnitTestInfo::UnitTestInfo(Logger *logger, QObject *parent)
- : UnitTestBase(UnitTestBase::InfoUnitId, logger, parent)
-{
- m_name = QString(tr("Info Test"));
- m_description = QString(tr("\"Info Test\" tested class SerialPortInfo,\n"
- "by calling its methods and write the results to a log.\n\n"
- "In the log lists all serial ports that were discovered,\n"
- "their properties, states, and supported standard rates."));
-}
-
-/* Public slots */
-
-void UnitTestInfo::start(bool first)
-{
- Q_UNUSED (first);
-
- QString header(tr("\n[ Test: ID#%1, Name: %2 ]\n%3\n\n"));
- header = header
- .arg(m_id)
- .arg(m_name)
- .arg(QString("timestamp"));/*.arg(UnitTestManager::timestamp());*/
-
- m_logger->addContent(header);
-
- int it = 0;
- foreach (SerialPortInfo inf, SerialPortInfo::availablePorts()) {
- QString body(tr("Port# %1, name : %2\n"
- " location : %3\n"
- " description : %4\n"
- " valid : %5\n"
- " busy : %6\n"
- " rates : %7\n"));
-
- QString r;
- foreach (qint32 rate, inf.standardRates()) {
- r.append(QString::number(rate));
- r.append(';');
- }
-
- body = body
- .arg(it++)
- .arg(inf.portName())
- .arg(inf.systemLocation())
- .arg(inf.description())
- .arg(inf.isValid())
- .arg(inf.isBusy())
- .arg(r);
-
- m_logger->addContent(body);
- }
-
- QString trailer(tr("\nFound %1 ports.\n"));
- trailer = trailer.arg(it);
- m_logger->addContent(trailer);
-
- emit finished();
-}
diff --git a/tests/guidevtest/unittestio.cpp b/tests/guidevtest/unittestio.cpp
deleted file mode 100644
index 2aff9c0..0000000
--- a/tests/guidevtest/unittestio.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-#include "unittests.h"
-#include "serialport.h"
-
-#include <QtCore/QTimer>
-#include <QtCore/QStringList>
-
-
-enum {
- RATES_COUNT = 2,
- DATABITS_COUNT = 1,
- PARITY_COUNT = 5,
- STOPBITS_COUNT = 2,
- FLOW_COUNT = 3
-};
-
-static const SerialPort::Rate vratesarray[RATES_COUNT] = {
- SerialPort::Rate9600,
- SerialPort::Rate115200
-};
-static const char *sratesarray[] = {
- "9600\0",
- "115200\0"
-};
-
-static const SerialPort::DataBits vdatabitsarray[DATABITS_COUNT] = {
- SerialPort::Data8
-};
-static const char *sdatabitsarray[] = {
- "8\0"
-};
-
-static const SerialPort::Parity vparitysarray[PARITY_COUNT] = {
- SerialPort::NoParity,
- SerialPort::EvenParity,
- SerialPort::OddParity,
- SerialPort::SpaceParity,
- SerialPort::MarkParity
-};
-static const char *sparitysarray[] = {
- "none\0",
- "even\0",
- "odd\0",
- "space\0",
- "mark\0"
-};
-
-static const SerialPort::StopBits vstopbitsarray[STOPBITS_COUNT] = {
- SerialPort::OneStop,
- SerialPort::TwoStop
-};
-static const char *sstopbitsarray[] = {
- "one\0",
- "two\0"
-};
-
-static const SerialPort::FlowControl vflowsarray[FLOW_COUNT] = {
- SerialPort::NoFlowControl,
- SerialPort::HardwareControl,
- SerialPort::SoftwareControl
-};
-static const char *sflowsarray[] = {
- "none\0",
- "hardware\0",
- "software\0"
-};
-
-static QString split_on_table(const QByteArray &data, int tablewidth)
-{
- QString result;
- int datacount = data.count();
- int i = 0;
-
- while (i < datacount) {
- result.append(data.mid(i, tablewidth).toHex());
- result.append('\n');
- i += tablewidth;
- }
- return result;
-}
-
-static QByteArray random_data_array(int arraysize)
-{
- QByteArray result;
- while (arraysize--) {
- // Here, protection of control characters 11h, 13h
- // with software flow control.
- char c;
- do {
- c = qrand();
- } while ((c == 0x11) || (c == 0x13));
-
- result.append(c);
- }
- return result;
-}
-
-
-
-/* Public methods */
-
-UnitTestIO::UnitTestIO(Logger *logger, QObject *parent)
- : UnitTestBase(UnitTestBase::IOUnitId, logger, parent)
- , m_rateIterator(0)
- , m_databitsIterator(0)
- , m_parityIterator(0)
- , m_stopbitsIterator(0)
- , m_flowIterator(0)
- , m_bytesWrite(0)
- , m_bytesRead(0)
-{
- m_name = QString(tr("IO Test"));
- m_description = QString(tr("\"IO Test\" designed to test the I/O between the two ports\n"
- "Source port sends a data packet to the destination port,\n"
- "that reads the packet.\n"
- " The default packet size is 500 bytes, the size can be changed\n"
- "programmatically by changing the value of the\n"
- "variable TransferBytesCount. Also, before sending the package\n"
- "is filled with a random value.\n"
- " Both ports after each transaction, change their parameters:\n"
- "speed, number of data bits, parity, number of stop bits,\n"
- "flow regime, until the end all enumerated parameters.\n"
- "After each transaction is recorded in a log the contents of the\n"
- "sent and received packet, and check their size. If the packet\n"
- "sizes are different, the test is aborted with an error which is\n"
- "recorded in the log.\n"
- ));
-
- m_srcPort = new SerialPort(this);
- m_dstPort = new SerialPort(this);
-}
-
-/* Public slots */
-
-void UnitTestIO::start(bool first)
-{
- if (first) {
- QString header(tr("\n[ Test: ID#%1, Name: %2 ]\n%3\n\n"));
- header = header
- .arg(m_id)
- .arg(m_name)
- .arg(QString("timestamp"));/*.arg(UnitTestManager::timestamp());*/
-
- m_logger->addContent(header);
-
- m_srcPort->setPort(m_srcPortName);
- m_dstPort->setPort(m_dstPortName);
-
- if (!(open(UnitTestBase::SrcPort) && open(UnitTestBase::DstPort))) {
- emit error();
- return;
- } else {
- QString content(tr("\nSource and destination ports is opened.\n"));
- m_logger->addContent(content);
- }
-
- m_rateIterator = 0;
- m_databitsIterator = 0;
- m_parityIterator = 0;
- m_stopbitsIterator = 0;
- m_flowIterator = 0;
- }
-
- transaction();
-}
-
-/* Private slots */
-
-void UnitTestIO::procSingleShot()
-{
- QByteArray data = m_dstPort->readAll();
-
- QString content("r:\n%1\n");
- content = content.arg(split_on_table(data, 32));
- m_logger->addContent(content);
-
- m_bytesRead = data.count();
-
- content = QString(tr("= write: %1 read: %2 =\n"));
- content = content
- .arg(m_bytesWrite)
- .arg(m_bytesRead);
- m_logger->addContent(content);
-
- if (m_bytesWrite != m_bytesRead) {
- content = QString(tr("\nError: Mismatch of write and read bytes.\n"));
- m_logger->addContent(content);
- close(UnitTestBase::SrcPort);
- close(UnitTestBase::DstPort);
- emit error();
- return;
- }
-
- ++m_rateIterator;
- if (m_rateIterator == RATES_COUNT) {
- m_rateIterator = 0;
-
- ++m_databitsIterator;
- if (m_databitsIterator == DATABITS_COUNT) {
- m_databitsIterator = 0;
-
- ++m_parityIterator;
- if (m_parityIterator == PARITY_COUNT) {
- m_parityIterator = 0;
-
- ++m_stopbitsIterator;
- if (m_stopbitsIterator == STOPBITS_COUNT) {
- m_stopbitsIterator = 0;
-
- ++m_flowIterator;
- if (m_flowIterator == FLOW_COUNT) {
- m_flowIterator = 0;
-
- close(UnitTestBase::SrcPort);
- close(UnitTestBase::DstPort);
- emit finished();
- return;
- }
- }
- }
- }
- }
-
- transaction();
-}
-
-void UnitTestIO::transaction()
-{
- if (!(configure(UnitTestBase::SrcPort) && configure(UnitTestBase::DstPort))) {
- emit error();
- return;
- }
-
- QString content(tr("\nrate : %1"
- "\ndatabits: %2"
- "\npatity : %3"
- "\nstopbits: %4"
- "\nflow : %5\n\n"));
-
- content = content
- .arg(QString(sratesarray[m_rateIterator]))
- .arg(QString(sdatabitsarray[m_databitsIterator]))
- .arg(QString(sparitysarray[m_parityIterator]))
- .arg(QString(sstopbitsarray[m_stopbitsIterator]))
- .arg(QString(sflowsarray[m_flowIterator]));
-
- m_logger->addContent(content);
-
- QByteArray data = random_data_array(TransferBytesCount);
- m_bytesWrite = m_srcPort->write(data);
-
- content = "w:\n%1\n";
- content = content.arg(split_on_table(data, 32));
- m_logger->addContent(content);
-
- QTimer::singleShot(TransactionMsecDelay, this, SLOT(procSingleShot()));
-}
-
-/* Private */
-
-bool UnitTestIO::open(DirPorts dir)
-{
- SerialPort *port = (dir == UnitTestBase::SrcPort) ?
- m_srcPort : m_dstPort;
- QIODevice::OpenMode mode = (dir == UnitTestBase::SrcPort) ?
- QIODevice::WriteOnly : QIODevice::ReadOnly;
-
- QString error("\nError: Can\'t open port %1\n");
- if (!port->open(mode)) {
- error = error.arg(port->portName());
- m_logger->addContent(error);
- return false;
- }
- return true;
-}
-
-bool UnitTestIO::configure(DirPorts dir)
-{
- SerialPort *port = (dir == UnitTestBase::SrcPort) ?
- m_srcPort : m_dstPort;
-
- if (!(port->setRate(vratesarray[m_rateIterator])
- && port->setDataBits(vdatabitsarray[m_databitsIterator])
- && port->setParity(vparitysarray[m_parityIterator])
- && port->setStopBits(vstopbitsarray[m_stopbitsIterator])
- && port->setFlowControl(vflowsarray[m_flowIterator]))) {
-
- QString error("\nError: Can\'t configure port %1\n");
- error = error.arg(port->portName());
- m_logger->addContent(error);
- return false;
- }
- return true;
-}
-
-void UnitTestIO::close(DirPorts dir)
-{
- if (dir == UnitTestBase::SrcPort) {
- if (m_srcPort->isOpen())
- m_srcPort->close();
- } else {
- if (m_dstPort->isOpen())
- m_dstPort->close();
- }
-}
-
-
-
-
diff --git a/tests/guidevtest/unittests.h b/tests/guidevtest/unittests.h
deleted file mode 100644
index 0b2fd94..0000000
--- a/tests/guidevtest/unittests.h
+++ /dev/null
@@ -1,168 +0,0 @@
-#ifndef UNITTESTS_H
-#define UNITTESTS_H
-
-#include <QtCore/QObject>
-
-
-class QFile;
-
-class Logger : public QObject
-{
- Q_OBJECT
-public:
- explicit Logger(QObject *parent = 0);
- void setFileName(const QString &name);
- void addContent(const QString &content, bool clearAll = false);
-
-private:
- QFile *m_file;
-};
-
-class SerialPort;
-
-class UnitTestBase : public QObject
-{
- Q_OBJECT
-signals:
- void finished();
- void error();
-
-public:
- enum UnitID {
- InfoUnitId,
- SignalsUnitId,
- WaitForXUnitId,
- IOUnitId,
-
- };
-
- explicit UnitTestBase(UnitID id, Logger *logger, QObject *parent = 0);
- void setPair(const QString &src, const QString &dst);
- void setEnable(bool enable);
- bool isEnabled() const;
- int id() const;
- QString name() const;
- QString description() const;
-
-public slots:
- virtual void start(bool first = true) = 0;
-
-protected:
- enum DirPorts { SrcPort, DstPort };
- int m_id;
- QString m_name;
- QString m_description;
- QString m_enableParam;
- Logger *m_logger;
- SerialPort *m_srcPort;
- SerialPort *m_dstPort;
- QString m_srcPortName;
- QString m_dstPortName;
-};
-
-
-class UnitTestInfo : public UnitTestBase
-{
- Q_OBJECT
-public:
- explicit UnitTestInfo(Logger *logger, QObject *parent = 0);
-
-public slots:
- virtual void start(bool first);
-};
-
-class UnitTestSignals : public UnitTestBase
-{
- Q_OBJECT
-public:
- explicit UnitTestSignals(Logger *logger, QObject *parent = 0);
-
-public slots:
- virtual void start(bool first);
-
-private slots:
- void procSignalBytesWritten(qint64 bw);
- void procSignalReadyRead();
- void procSingleShot();
- void transaction();
-
-private:
- enum {
- TransactionLimit = 5,
- TransactionMsecDelay = 1000,
- MinBytesToWrite = 1,
- StepBytesToWrite = 100
- };
-
- bool m_started;
- int m_transactionNum;
- qint64 m_bytesToWrite;
- qint64 m_bytesReallyWrited;
- int m_countSignalsBytesWritten;
- int m_countSignalsReadyRead;
-
-
- bool open(DirPorts dir);
- bool configure(DirPorts dir);
- void close(DirPorts dir);
-};
-
-class UnitTestWaitForX : public UnitTestBase
-{
- Q_OBJECT
-public:
- explicit UnitTestWaitForX(Logger *logger, QObject *parent = 0);
-
-public slots:
- virtual void start(bool first);
-};
-
-class UnitTestIO : public UnitTestBase
-{
- Q_OBJECT
-public:
- explicit UnitTestIO(Logger *logger, QObject *parent = 0);
-
-public slots:
- virtual void start(bool first);
-
-private slots:
- void procSingleShot();
- void transaction();
-
-private:
- enum {
- TransferBytesCount = 500,
- TransactionMsecDelay = 700
- };
-
- int m_rateIterator;
- int m_databitsIterator;
- int m_parityIterator;
- int m_stopbitsIterator;
- int m_flowIterator;
-
- qint64 m_bytesWrite;
- qint64 m_bytesRead;
-
- bool open(DirPorts dir);
- bool configure(DirPorts dir);
- void close(DirPorts dir);
-};
-
-
-
-
-
-
-
-
-
-class UnitTestFactory
-{
-public:
- static UnitTestBase *create(UnitTestBase::UnitID id, Logger *logger);
-};
-
-
-#endif // UNITTESTS_H
diff --git a/tests/guidevtest/unittestsignals.cpp b/tests/guidevtest/unittestsignals.cpp
deleted file mode 100644
index ade4877..0000000
--- a/tests/guidevtest/unittestsignals.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-#include "unittests.h"
-#include "serialport.h"
-
-#include <QtCore/QTimer>
-//#include <QtCore/QByteArray>
-
-
-/* Public methods */
-
-UnitTestSignals::UnitTestSignals(Logger *logger, QObject *parent)
- : UnitTestBase(UnitTestBase::SignalsUnitId, logger, parent)
- , m_started(false), m_transactionNum(0), m_bytesToWrite(0)
- , m_bytesReallyWrited(0), m_countSignalsBytesWritten(0)
- , m_countSignalsReadyRead(0)
-{
- m_name = QString(tr("Signals Test"));
- m_description = QString(tr("\"Signals Test\" monitors and verifies the correctness of the\n"
- "emission signals bytesWritten() and readyRead().\n\n"
- "This test uses the source port and destination port.\n\n"
- "The source port is opened only as write-only, and this\n"
- "test from the port set control a signal bytesWritten().\n"
- "In this case, count the number of emit signals bytesWritten()\n"
- "and the number of bytes of data transmitted in the signal for\n"
- "a single emit.\n\n"
- "The destination port is opened as read-only, and this\n"
- "test from the port set control a signal readyRead().\n"
- "At the same time count the number of signals readyRead().\n\n"
- "By default ports are opened in the mode: 9600 8 N 1, no flow control.\n"
- "The testing process consists of several stages:\n\n"
- " Stage1. Opened and initialized ports. If an error occurs, it is\n"
- "recorded in the log and testing is completed with failure. If\n"
- "everything goes well, then go to stage 2.\n\n"
- " Stage2. Run single shot the timer interval to 1 second, and\n"
- "further, the source port sends a byte, at the same time are tracked\n"
- "and logged signals from the ports. Further, when the timer works,\n"
- "there is a processing of the results of the signals. Compares the\n"
- "number of bytes sent and received, and these results or an error is\n"
- "generated with the termination of the test, or go to stage 3.\n\n"
- " Stage3. No different from stage 2 with the exception of the number\n"
- "of bytes transmitted. Now write not one but several bytes. The number\n"
- "of bytes transmitted is now increasing, according to the formula:\n"
- "NumCurr = NumPrev + K, where K - some constant. Further, the\n"
- "termination of a test or go to stage 4.\n\n"
- " Stage4. Does not differ from step 3, except the number of bytes.\n\n"
- " StageN. No different from the previous steps.\n\n"
- "By default, the number of transactions (steps) for the transfer of\n"
- "data is five, but this value can be changed by editing the source\n"
- "code of the test. In the source code you can change settings such as:\n"
- "- timeout of timer (by default 1 sec)\n"
- "- number of steps (by default 5)\n"
- "- initial number of bytes transmitted (by default 1 byte)\n"
- "- constant growth rate K of transmitted bytes (by default 100 byte)."));
-
- m_srcPort = new SerialPort(this);
- m_dstPort = new SerialPort(this);
-
- connect(m_srcPort, SIGNAL(bytesWritten(qint64)),
- this, SLOT(procSignalBytesWritten(qint64)));
- connect(m_dstPort, SIGNAL(readyRead()),
- this, SLOT(procSignalReadyRead()));
-}
-
-/* Public slots */
-
-void UnitTestSignals::start(bool first)
-{
- if (first) {
- QString header(tr("\n[ Test: ID#%1, Name: %2 ]\n%3\n\n"));
- header = header
- .arg(m_id)
- .arg(m_name)
- .arg(QString("timestamp"));/*.arg(UnitTestManager::timestamp());*/
-
- m_logger->addContent(header);
-
- m_srcPort->setPort(m_srcPortName);
- m_dstPort->setPort(m_dstPortName);
-
- if (!(open(UnitTestBase::SrcPort) && open(UnitTestBase::DstPort)
- && configure(UnitTestBase::SrcPort) && configure(UnitTestBase::DstPort))) {
-
- close(UnitTestBase::SrcPort);
- close(UnitTestBase::DstPort);
- emit error();
- return;
- } else {
- QString content(tr("\nSource and destination ports\n"
- "opened as 9600 8 N 1 by default.\n"));
- m_logger->addContent(content);
- }
-
- // Prepare transaction begin.
- m_transactionNum = 0;
- m_bytesToWrite = MinBytesToWrite;
- m_bytesReallyWrited = 0;
- m_countSignalsBytesWritten = 0;
- m_countSignalsReadyRead = 0;
- }
-
- transaction();
-}
-
-/* Private slots */
-
-void UnitTestSignals::procSignalBytesWritten(qint64 bw)
-{
- QString content(">signal bytesWritten(%1)\n");
- content = content.arg(bw);
- m_logger->addContent(content);
- ++m_countSignalsBytesWritten;
- m_bytesReallyWrited += bw;
-}
-
-void UnitTestSignals::procSignalReadyRead()
-{
- ++m_countSignalsReadyRead;
-}
-
-void UnitTestSignals::procSingleShot()
-{
- QByteArray data = m_dstPort->readAll();
- qint64 reallyRead = data.count();
-
- QString content(tr("- count signals bytesWritten : %1\n"
- "- count signals readyRead : %2\n"
- "- bytes really write : %3\n"
- "- bytes really read : %4\n"));
- content = content
- .arg(m_countSignalsBytesWritten)
- .arg(m_countSignalsReadyRead)
- .arg(m_bytesReallyWrited)
- .arg(reallyRead);
-
- m_logger->addContent(content);
-
- m_countSignalsBytesWritten = 0;
- m_countSignalsReadyRead = 0;
-
- if ((m_bytesReallyWrited != m_bytesToWrite)
- || (m_bytesToWrite != reallyRead)) {
-
- content = QString(tr("\nError: Mismatch of sent and received bytes.\n"));
- m_logger->addContent(content);
- close(UnitTestBase::SrcPort);
- close(UnitTestBase::DstPort);
- emit error();
- }
-
- m_bytesReallyWrited = 0;
- m_bytesToWrite += StepBytesToWrite;
-
- transaction();
-}
-
-void UnitTestSignals::transaction()
-{
- if (m_transactionNum++ != TransactionLimit) {
- QString content(tr("\nTransaction #%1, bytes to write: %2\n"));
- content = content.arg(m_transactionNum).arg(m_bytesToWrite);
- m_logger->addContent(content);
-
- QByteArray data(m_bytesToWrite, qrand());
- QTimer::singleShot(TransactionMsecDelay, this, SLOT(procSingleShot()));
- m_srcPort->write(data);
- } else {
- close(UnitTestBase::SrcPort);
- close(UnitTestBase::DstPort);
- emit finished();
- }
-}
-
-/* Private */
-
-bool UnitTestSignals::open(DirPorts dir)
-{
- SerialPort *port = (dir == UnitTestBase::SrcPort) ?
- m_srcPort : m_dstPort;
- QIODevice::OpenMode mode = (dir == UnitTestBase::SrcPort) ?
- QIODevice::WriteOnly : QIODevice::ReadOnly;
-
- QString error("\nError: Can\'t open port %1\n");
- if (!port->open(mode)) {
- error = error.arg(port->portName());
- m_logger->addContent(error);
- return false;
- }
- return true;
-}
-
-bool UnitTestSignals::configure(DirPorts dir)
-{
- SerialPort *port = (dir == UnitTestBase::SrcPort) ?
- m_srcPort : m_dstPort;
-
- if (!(port->setRate(9600) && port->setDataBits(SerialPort::Data8)
- && port->setParity(SerialPort::NoParity) && port->setStopBits(SerialPort::OneStop)
- && port->setFlowControl(SerialPort::NoFlowControl))) {
-
- QString error("\nError: Can\'t configure port %1\n");
- error = error.arg(port->portName());
- m_logger->addContent(error);
- return false;
- }
- return true;
-}
-
-void UnitTestSignals::close(DirPorts dir)
-{
- if (dir == UnitTestBase::SrcPort) {
- if (m_srcPort->isOpen())
- m_srcPort->close();
- } else {
- if (m_dstPort->isOpen())
- m_dstPort->close();
- }
-}
-
-
diff --git a/tests/guidevtest/unittestwaitforx.cpp b/tests/guidevtest/unittestwaitforx.cpp
deleted file mode 100644
index a9dd3cb..0000000
--- a/tests/guidevtest/unittestwaitforx.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "unittests.h"
-#include "serialport.h"
-
-
-
-/* Public methods */
-
-UnitTestWaitForX::UnitTestWaitForX(Logger *logger, QObject *parent)
- : UnitTestBase(UnitTestBase::WaitForXUnitId, logger, parent)
-{
- m_name = QString(tr("WaitForX Test"));
- m_description = QString(tr("\"WaitForX Test\" ..."));
-}
-
-/* Public slots */
-
-void UnitTestWaitForX::start(bool first)
-{
- Q_UNUSED(first);
-
- QString header(tr("\n[ Test: ID#%1, Name: %2 ]\n%3\n\n"));
- header = header
- .arg(m_id)
- .arg(m_name)
- .arg(QString("timestamp"));/*.arg(UnitTestManager::timestamp());*/
-
- m_logger->addContent(header);
-
- ////
-
- emit finished();
-}
-