summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorkuzulis <scapig2@yandex.ru>2011-11-19 16:33:11 +0400
committerkuzulis <kuzulis@kuzulis.localdomain>2011-11-19 16:33:11 +0400
commit4c644617ec463ebd2ddc445b553e504641b629a1 (patch)
treedc2aa4d3f6eb5ce0d9870d042674fcde12d87331 /tests
parent5f11f5232476ab700d232c3387b99797fc5eec98 (diff)
downloadqtserialport-4c644617ec463ebd2ddc445b553e504641b629a1.tar.gz
/tests/guidevtest: For test "IO test" implemented in a log record of the
transmitted/received data packet. In this case, the data in the log are sorted in a table of 32 characters.
Diffstat (limited to 'tests')
-rw-r--r--tests/guidevtest/unittestio.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/guidevtest/unittestio.cpp b/tests/guidevtest/unittestio.cpp
index 6e0b5dc..b426ae9 100644
--- a/tests/guidevtest/unittestio.cpp
+++ b/tests/guidevtest/unittestio.cpp
@@ -64,6 +64,20 @@ static const char *sflowsarray[] = {
"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;
+}
+
/* Public methods */
@@ -138,9 +152,14 @@ void UnitTestIO::start(bool first)
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();
- QString content(tr("= write: %1 read: %2 =\n"));
+ content = QString(tr("= write: %1 read: %2 =\n"));
content = content
.arg(m_bytesWrite)
.arg(m_bytesRead);
@@ -213,6 +232,10 @@ void UnitTestIO::transaction()
QByteArray data(TransferBytesCount, qrand());
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()));
}