From 276079b9843ca5f2f894c1b65fc337b40a7b2a5c Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Tue, 22 May 2012 21:58:55 +0300 Subject: Fix the broken tests with Qt4 due to the QSKIP API change QSKIP went through a source incompatible change from Qt4 migration to Qt5. Therefore, the customers cannot build the project with tests (default build) without such a fix like this. Change-Id: I376e88db723c61358d00cb737a30cde46e03c3a1 Reviewed-by: Sergey Belyashov Reviewed-by: Debao Zhang Reviewed-by: Denis Shienkov --- tests/manual/serialport/tst_serialport.cpp | 45 +++++++++--------------------- 1 file changed, 13 insertions(+), 32 deletions(-) (limited to 'tests') diff --git a/tests/manual/serialport/tst_serialport.cpp b/tests/manual/serialport/tst_serialport.cpp index f021708..4009fe6 100644 --- a/tests/manual/serialport/tst_serialport.cpp +++ b/tests/manual/serialport/tst_serialport.cpp @@ -52,22 +52,33 @@ class tst_SerialPort : public QObject Q_OBJECT private slots: + void initTestCase(); void open(); void rate(); void dataBits(); void parity(); void stopBits(); void flowControl(); + +private: + QList ports; }; -void tst_SerialPort::open() +void tst_SerialPort::initTestCase() { - const QList ports = SerialPortInfo::availablePorts(); + ports = SerialPortInfo::availablePorts(); if (ports.isEmpty()) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QSKIP("Test doesn't work because the serial ports are not detected."); +#else + QSKIP("Test doesn't work because the serial ports are not detected.", SkipAll); +#endif } +} +void tst_SerialPort::open() +{ foreach (const SerialPortInfo &info, ports) { if (info.isBusy()) @@ -103,12 +114,6 @@ void tst_SerialPort::open() void tst_SerialPort::rate() { - const QList 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; @@ -138,12 +143,6 @@ void tst_SerialPort::rate() void tst_SerialPort::dataBits() { - const QList 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; @@ -159,12 +158,6 @@ void tst_SerialPort::dataBits() void tst_SerialPort::parity() { - const QList 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; @@ -188,12 +181,6 @@ void tst_SerialPort::parity() void tst_SerialPort::stopBits() { - const QList 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; @@ -212,12 +199,6 @@ void tst_SerialPort::stopBits() void tst_SerialPort::flowControl() { - const QList 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; -- cgit v1.2.1