diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-02-20 15:55:55 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-02-25 10:22:53 +0100 |
commit | a325de1910e6627e4d042114d22303cc68fae7a9 (patch) | |
tree | cabf88f9e4e42579e6695ecff5e6ab787f3922ab /tests/auto/qserialport/tst_qserialport.cpp | |
parent | d42d5838b9a4c3cbd6b0e67dabce658ba737eba8 (diff) | |
parent | b84fe7eb3d6d977a347bfbb82da724409b2eda69 (diff) | |
download | qtserialport-a325de1910e6627e4d042114d22303cc68fae7a9.tar.gz |
Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts:
.qmake.conf
src/serialport/qserialport_unix.cpp
src/serialport/qserialport_unix_p.h
src/serialport/qserialport_win.cpp
src/serialport/qserialport_win_p.h
src/serialport/qserialport_wince.cpp
src/serialport/qserialport_wince_p.h
Change-Id: Ibb917652b132e66fbb90f437bf762c1094911dc0
Diffstat (limited to 'tests/auto/qserialport/tst_qserialport.cpp')
-rw-r--r-- | tests/auto/qserialport/tst_qserialport.cpp | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/tests/auto/qserialport/tst_qserialport.cpp b/tests/auto/qserialport/tst_qserialport.cpp index a984e4a..627de6c 100644 --- a/tests/auto/qserialport/tst_qserialport.cpp +++ b/tests/auto/qserialport/tst_qserialport.cpp @@ -119,9 +119,7 @@ protected slots: void handleBytesWrittenAndExitLoopSlot2(qint64 bytesWritten); private: -#ifdef Q_OS_WIN void clearReceiver(const QString &customReceiverName = QString()); -#endif QString m_senderPortName; QString m_receiverPortName; @@ -141,9 +139,8 @@ tst_QSerialPort::tst_QSerialPort() { } -#ifdef Q_OS_WIN // This method is a workaround for the "com0com" virtual serial port -// driver, which is installed on CI. The problem is that the close/clear +// driver or for the SOCAT utility. The problem is that the close/clear // methods have no effect on sender serial port. If any data didn't manage // to be transferred before closing, then this data will continue to be // transferred at next opening of sender port. @@ -159,17 +156,30 @@ void tst_QSerialPort::clearReceiver(const QString &customReceiverName) if (receiver.open(QIODevice::ReadOnly)) enterLoopMsecs(100); } -#endif void tst_QSerialPort::initTestCase() { m_senderPortName = QString::fromLocal8Bit(qgetenv("QTEST_SERIALPORT_SENDER")); m_receiverPortName = QString::fromLocal8Bit(qgetenv("QTEST_SERIALPORT_RECEIVER")); if (m_senderPortName.isEmpty() || m_receiverPortName.isEmpty()) { + static const char message[] = + "Test doesn't work because the names of serial ports aren't found in env.\n" + "Please set environment variables:\n" + " QTEST_SERIALPORT_SENDER to name of output serial port\n" + " QTEST_SERIALPORT_RECEIVER to name of input serial port\n" + "Specify short names of port" +#if defined(Q_OS_UNIX) + ", like: ttyS0\n"; +#elif defined(Q_OS_WIN32) + ", like: COM1\n"; +#else + "\n"; +#endif + #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) - QSKIP("Test doesn't work because the names of serial ports aren't found in env."); + QSKIP(message); #else - QSKIP("Test doesn't work because the names of serial ports aren't set found env.", SkipAll); + QSKIP(message, SkipAll); #endif } else { m_availablePortNames << m_senderPortName << m_receiverPortName; @@ -226,9 +236,23 @@ void tst_QSerialPort::constructByName() void tst_QSerialPort::constructByInfo() { QSerialPortInfo senderPortInfo(m_senderPortName); + QSerialPortInfo receiverPortInfo(m_receiverPortName); + +#if defined(Q_OS_UNIX) + if (senderPortInfo.isNull() || receiverPortInfo.isNull()) { + static const char message[] = + "Test doesn't work because the specified serial ports aren't" + " found in system and can't be constructed by QSerialPortInfo.\n"; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + QSKIP(message); +#else + QSKIP(message, SkipAll); +#endif + } +#endif + QSerialPort serialPort(senderPortInfo); QCOMPARE(serialPort.portName(), m_senderPortName); - QSerialPortInfo receiverPortInfo(m_receiverPortName); serialPort.setPort(receiverPortInfo); QCOMPARE(serialPort.portName(), m_receiverPortName); } @@ -387,8 +411,8 @@ void tst_QSerialPort::waitForBytesWritten() void tst_QSerialPort::waitForReadyReadWithTimeout() { -#ifdef Q_OS_WIN clearReceiver(); +#ifdef Q_OS_WIN // the dummy device on other side also has to be open QSerialPort dummySerialPort(m_senderPortName); QVERIFY(dummySerialPort.open(QIODevice::WriteOnly)); |