summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qserialport/tst_qserialport.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qserialport/tst_qserialport.cpp b/tests/auto/qserialport/tst_qserialport.cpp
index 245c7f2..96d3788 100644
--- a/tests/auto/qserialport/tst_qserialport.cpp
+++ b/tests/auto/qserialport/tst_qserialport.cpp
@@ -86,6 +86,8 @@ private slots:
void flush();
void doubleFlush();
+ void waitForBytesWritten();
+
protected slots:
void handleBytesWrittenAndExitLoopSlot(qint64 bytesWritten);
void handleBytesWrittenAndExitLoopSlot2(qint64 bytesWritten);
@@ -319,5 +321,19 @@ void tst_QSerialPort::doubleFlush()
QCOMPARE(bytesWrittenSpy.count(), 2);
}
+void tst_QSerialPort::waitForBytesWritten()
+{
+ // the dummy device on other side also has to be open
+ QSerialPort dummySerialPort(m_receiverPortName);
+ QVERIFY(dummySerialPort.open(QIODevice::ReadOnly));
+
+ QSerialPort serialPort(m_senderPortName);
+ QVERIFY(serialPort.open(QIODevice::WriteOnly));
+ serialPort.write(alphabetArray);
+ const qint64 toWrite = serialPort.bytesToWrite();
+ QVERIFY(serialPort.waitForBytesWritten(1000));
+ QVERIFY(toWrite > serialPort.bytesToWrite());
+}
+
QTEST_MAIN(tst_QSerialPort)
#include "tst_qserialport.moc"