summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDenis Shienkov <scapig@yandex.ru>2012-05-03 23:00:06 +0400
committerDenis Shienkov <scapig@yandex.ru>2012-05-18 10:09:41 +0200
commit0ae8aba9d485a2e0f677e3ef3bcb4eaa5336a7a8 (patch)
treee341eb2840481876fab96189b84c18b96705cc2b /tests
parent77ab1d775ade00bb39ddb04949f728e20bfa2a8a (diff)
Prepared a first manual test example.
This test checks access to the all available ports, as well do the validation a configuring each port. Change-Id: Ic3f58b43d9427be9164fae431f4775fb26afc5ca Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Denis Shienkov <scapig@yandex.ru>
Diffstat (limited to 'tests')
-rw-r--r--tests/EMPTYFILE0
-rw-r--r--tests/manual/manual.pro3
-rw-r--r--tests/manual/serialport/serialport.pro11
-rw-r--r--tests/manual/serialport/tst_serialport.cpp239
-rw-r--r--tests/manual/serialportinfo/serialportinfo.pro11
-rw-r--r--tests/manual/serialportinfo/tst_serialportinfo.cpp87
-rw-r--r--tests/tests.pro3
7 files changed, 354 insertions, 0 deletions
diff --git a/tests/EMPTYFILE b/tests/EMPTYFILE
deleted file mode 100644
index e69de29b..00000000
--- a/tests/EMPTYFILE
+++ /dev/null
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
new file mode 100644
index 00000000..b8ca5dab
--- /dev/null
+++ b/tests/manual/manual.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+CONFIG = ordered
+SUBDIRS += serialportinfo serialport
diff --git a/tests/manual/serialport/serialport.pro b/tests/manual/serialport/serialport.pro
new file mode 100644
index 00000000..3e5e0d2e
--- /dev/null
+++ b/tests/manual/serialport/serialport.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_serialport
+
+QT = core testlib
+greaterThan(QT_MAJOR_VERSION, 4) {
+ QT += serialport
+} else {
+ include($$SERIALPORT_PROJECT_ROOT/src/qt4support/serialport.prf)
+}
+
+SOURCES += tst_serialport.cpp
diff --git a/tests/manual/serialport/tst_serialport.cpp b/tests/manual/serialport/tst_serialport.cpp
new file mode 100644
index 00000000..f0217080
--- /dev/null
+++ b/tests/manual/serialport/tst_serialport.cpp
@@ -0,0 +1,239 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Denis Shienkov <scapig2@yandex.ru>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtSerialPort module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/QDebug>
+
+#include <QtAddOnSerialPort/serialportinfo.h>
+#include <QtAddOnSerialPort/serialport.h>
+
+QT_USE_NAMESPACE_SERIALPORT
+
+class tst_SerialPort : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void open();
+ void rate();
+ void dataBits();
+ void parity();
+ void stopBits();
+ void flowControl();
+};
+
+void tst_SerialPort::open()
+{
+ const QList<SerialPortInfo> ports = SerialPortInfo::availablePorts();
+
+ if (ports.isEmpty()) {
+ QSKIP("Test doesn't work because the serial ports are not detected.");
+ }
+
+ foreach (const SerialPortInfo &info, ports) {
+
+ if (info.isBusy())
+ continue;
+
+ SerialPort object1;
+
+ // Try open and check access to port by Info
+ object1.setPort(info);
+ QCOMPARE(object1.portName(), info.portName());
+ QCOMPARE(object1.open(QIODevice::ReadWrite), true);
+ QCOMPARE(object1.isOpen(), true);
+ object1.close();
+ QCOMPARE(object1.isOpen(), false);
+
+ // Try open and check access to port by Name
+ object1.setPort(info.portName());
+ QCOMPARE(object1.portName(), info.portName());
+ QCOMPARE(object1.open(QIODevice::ReadWrite), true);
+ QCOMPARE(object1.isOpen(), true);
+ object1.close();
+ QCOMPARE(object1.isOpen(), false);
+
+ // Try open and check access to port by Location
+ object1.setPort(info.systemLocation());
+ QCOMPARE(object1.portName(), info.portName());
+ QCOMPARE(object1.open(QIODevice::ReadWrite), true);
+ QCOMPARE(object1.isOpen(), true);
+ object1.close();
+ QCOMPARE(object1.isOpen(), false);
+ }
+}
+
+void tst_SerialPort::rate()
+{
+ const QList<SerialPortInfo> ports = SerialPortInfo::availablePorts();
+
+ if (ports.isEmpty()) {
+ QSKIP("Test doesn't work because the serial ports are not detected.");
+ }
+
+ foreach (const SerialPortInfo &info, ports) {
+
+ SerialPort object1;
+ object1.setPort(info.portName());
+ QCOMPARE(object1.open(QIODevice::ReadWrite), true);
+
+ QCOMPARE(object1.setRate(SerialPort::Rate1200), true);
+ QCOMPARE(object1.rate(), static_cast<qint32>(SerialPort::Rate1200));
+ QCOMPARE(object1.setRate(SerialPort::Rate2400), true);
+ QCOMPARE(object1.rate(), static_cast<qint32>(SerialPort::Rate2400));
+ QCOMPARE(object1.setRate(SerialPort::Rate4800), true);
+ QCOMPARE(object1.rate(), static_cast<qint32>(SerialPort::Rate4800));
+ QCOMPARE(object1.setRate(SerialPort::Rate9600), true);
+ QCOMPARE(object1.rate(), static_cast<qint32>(SerialPort::Rate9600));
+ QCOMPARE(object1.setRate(SerialPort::Rate19200), true);
+ QCOMPARE(object1.rate(), static_cast<qint32>(SerialPort::Rate19200));
+ QCOMPARE(object1.setRate(SerialPort::Rate38400), true);
+ QCOMPARE(object1.rate(), static_cast<qint32>(SerialPort::Rate38400));
+ QCOMPARE(object1.setRate(SerialPort::Rate57600), true);
+ QCOMPARE(object1.rate(), static_cast<qint32>(SerialPort::Rate57600));
+ QCOMPARE(object1.setRate(SerialPort::Rate115200), true);
+ QCOMPARE(object1.rate(), static_cast<qint32>(SerialPort::Rate115200));
+
+ object1.close();
+ }
+}
+
+void tst_SerialPort::dataBits()
+{
+ const QList<SerialPortInfo> ports = SerialPortInfo::availablePorts();
+
+ if (ports.isEmpty()) {
+ QSKIP("Test doesn't work because the serial ports are not detected.");
+ }
+
+ foreach (const SerialPortInfo &info, ports) {
+
+ SerialPort object1;
+ object1.setPort(info.portName());
+ QCOMPARE(object1.open(QIODevice::ReadWrite), true);
+
+ QCOMPARE(object1.setDataBits(SerialPort::Data8), true);
+ QCOMPARE(object1.dataBits(), SerialPort::Data8);
+
+ object1.close();
+ }
+}
+
+void tst_SerialPort::parity()
+{
+ const QList<SerialPortInfo> ports = SerialPortInfo::availablePorts();
+
+ if (ports.isEmpty()) {
+ QSKIP("Test doesn't work because the serial ports are not detected.");
+ }
+
+ foreach (const SerialPortInfo &info, ports) {
+
+ SerialPort object1;
+ object1.setPort(info.portName());
+ QCOMPARE(object1.open(QIODevice::ReadWrite), true);
+
+ QCOMPARE(object1.setParity(SerialPort::NoParity), true);
+ QCOMPARE(object1.parity(), SerialPort::NoParity);
+ QCOMPARE(object1.setParity(SerialPort::EvenParity), true);
+ QCOMPARE(object1.parity(), SerialPort::EvenParity);
+ QCOMPARE(object1.setParity(SerialPort::OddParity), true);
+ QCOMPARE(object1.parity(), SerialPort::OddParity);
+ QCOMPARE(object1.setParity(SerialPort::MarkParity), true);
+ QCOMPARE(object1.parity(), SerialPort::MarkParity);
+ QCOMPARE(object1.setParity(SerialPort::SpaceParity), true);
+ QCOMPARE(object1.parity(), SerialPort::SpaceParity);
+
+ object1.close();
+ }
+}
+
+void tst_SerialPort::stopBits()
+{
+ const QList<SerialPortInfo> ports = SerialPortInfo::availablePorts();
+
+ if (ports.isEmpty()) {
+ QSKIP("Test doesn't work because the serial ports are not detected.");
+ }
+
+ foreach (const SerialPortInfo &info, ports) {
+
+ SerialPort object1;
+ object1.setPort(info.portName());
+ QCOMPARE(object1.open(QIODevice::ReadWrite), true);
+
+ QCOMPARE(object1.setStopBits(SerialPort::OneStop), true);
+ QCOMPARE(object1.stopBits(), SerialPort::OneStop);
+ // skip 1.5 stop bits
+ QCOMPARE(object1.setStopBits(SerialPort::TwoStop), true);
+ QCOMPARE(object1.stopBits(), SerialPort::TwoStop);
+
+ object1.close();
+ }
+}
+
+void tst_SerialPort::flowControl()
+{
+ const QList<SerialPortInfo> ports = SerialPortInfo::availablePorts();
+
+ if (ports.isEmpty()) {
+ QSKIP("Test doesn't work because the serial ports are not detected.");
+ }
+
+ foreach (const SerialPortInfo &info, ports) {
+
+ SerialPort object1;
+ object1.setPort(info.portName());
+ QCOMPARE(object1.open(QIODevice::ReadWrite), true);
+
+ QCOMPARE(object1.setFlowControl(SerialPort::NoFlowControl), true);
+ QCOMPARE(object1.flowControl(), SerialPort::NoFlowControl);
+ QCOMPARE(object1.setFlowControl(SerialPort::HardwareControl), true);
+ QCOMPARE(object1.flowControl(), SerialPort::HardwareControl);
+ QCOMPARE(object1.setFlowControl(SerialPort::SoftwareControl), true);
+ QCOMPARE(object1.flowControl(), SerialPort::SoftwareControl);
+
+ object1.close();
+ }
+}
+
+QTEST_MAIN(tst_SerialPort)
+#include "tst_serialport.moc"
diff --git a/tests/manual/serialportinfo/serialportinfo.pro b/tests/manual/serialportinfo/serialportinfo.pro
new file mode 100644
index 00000000..941cfb76
--- /dev/null
+++ b/tests/manual/serialportinfo/serialportinfo.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_serialportinfo
+
+QT = core testlib
+greaterThan(QT_MAJOR_VERSION, 4) {
+ QT += serialport
+} else {
+ include($$SERIALPORT_PROJECT_ROOT/src/qt4support/serialport.prf)
+}
+
+SOURCES += tst_serialportinfo.cpp
diff --git a/tests/manual/serialportinfo/tst_serialportinfo.cpp b/tests/manual/serialportinfo/tst_serialportinfo.cpp
new file mode 100644
index 00000000..b17f97ce
--- /dev/null
+++ b/tests/manual/serialportinfo/tst_serialportinfo.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Denis Shienkov <scapig2@yandex.ru>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtSerialPort module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/QDebug>
+
+#include <QtAddOnSerialPort/serialportinfo.h>
+#include <QtAddOnSerialPort/serialport.h>
+
+QT_USE_NAMESPACE_SERIALPORT
+
+class tst_SerialPortInfo : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void ports();
+ void constructors();
+ void assignment();
+};
+
+void tst_SerialPortInfo::ports()
+{
+ QList<SerialPortInfo> list(SerialPortInfo::availablePorts());
+ QCOMPARE(list.isEmpty(), false);
+}
+
+void tst_SerialPortInfo::constructors()
+{
+ // FIXME
+}
+
+void tst_SerialPortInfo::assignment()
+{
+ QList<SerialPortInfo> list(SerialPortInfo::availablePorts());
+
+ for (int c = 0; c < list.size(); ++c) {
+ SerialPortInfo info = list[c];
+ QCOMPARE(info.portName(), list[c].portName());
+ QCOMPARE(info.systemLocation(), list[c].systemLocation());
+ QCOMPARE(info.description(), list[c].description());
+ QCOMPARE(info.manufacturer(), list[c].manufacturer());
+ QCOMPARE(info.vendorIdentifier(), list[c].vendorIdentifier());
+ QCOMPARE(info.productIdentifier(), list[c].productIdentifier());
+ }
+}
+
+QTEST_MAIN(tst_SerialPortInfo)
+#include "tst_serialportinfo.moc"
diff --git a/tests/tests.pro b/tests/tests.pro
new file mode 100644
index 00000000..3ae66f38
--- /dev/null
+++ b/tests/tests.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS = \
+ manual