diff options
Diffstat (limited to 'tests/auto/nfccommons')
-rw-r--r-- | tests/auto/nfccommons/qnearfieldtagtype1.cpp | 4 | ||||
-rw-r--r-- | tests/auto/nfccommons/qnearfieldtagtype2.cpp | 2 | ||||
-rw-r--r-- | tests/auto/nfccommons/qnearfieldtarget_emulator.cpp | 10 | ||||
-rw-r--r-- | tests/auto/nfccommons/qtlv.cpp | 22 | ||||
-rw-r--r-- | tests/auto/nfccommons/targetemulator.cpp | 24 |
5 files changed, 31 insertions, 31 deletions
diff --git a/tests/auto/nfccommons/qnearfieldtagtype1.cpp b/tests/auto/nfccommons/qnearfieldtagtype1.cpp index b12000ad..11e9ea71 100644 --- a/tests/auto/nfccommons/qnearfieldtagtype1.cpp +++ b/tests/auto/nfccommons/qnearfieldtagtype1.cpp @@ -335,7 +335,7 @@ static QVariant decodeResponse(const QByteArray &command, const QByteArray &resp if (writeBlockAddress != blockAddress) return false; - for (int i = 0; i < writeData.length(); ++i) { + for (int i = 0; i < writeData.size(); ++i) { if ((writeData.at(i) & data.at(i)) != data.at(i)) return false; } @@ -642,7 +642,7 @@ QNearFieldTarget::RequestId QNearFieldTagType1::writeBlock(quint8 blockAddress, const QByteArray &data, WriteMode mode) { - if (data.length() != 8) + if (data.size() != 8) return QNearFieldTarget::RequestId(); QByteArray command; diff --git a/tests/auto/nfccommons/qnearfieldtagtype2.cpp b/tests/auto/nfccommons/qnearfieldtagtype2.cpp index 049567cf..62ddf5b1 100644 --- a/tests/auto/nfccommons/qnearfieldtagtype2.cpp +++ b/tests/auto/nfccommons/qnearfieldtagtype2.cpp @@ -171,7 +171,7 @@ QNearFieldTarget::RequestId QNearFieldTagType2::readBlock(quint8 blockAddress) QNearFieldTarget::RequestId QNearFieldTagType2::writeBlock(quint8 blockAddress, const QByteArray &data) { - if (data.length() != 4) + if (data.size() != 4) return QNearFieldTarget::RequestId(); QByteArray command; diff --git a/tests/auto/nfccommons/qnearfieldtarget_emulator.cpp b/tests/auto/nfccommons/qnearfieldtarget_emulator.cpp index 9c151c43..5359d366 100644 --- a/tests/auto/nfccommons/qnearfieldtarget_emulator.cpp +++ b/tests/auto/nfccommons/qnearfieldtarget_emulator.cpp @@ -52,7 +52,7 @@ QNearFieldTarget::RequestId TagType1::sendCommand(const QByteArray &command) return id; } - quint16 crc = qChecksum(QByteArrayView(command.constData(), command.length()), Qt::ChecksumItuV41); + quint16 crc = qChecksum(QByteArrayView(command.constData(), command.size()), Qt::ChecksumItuV41); QByteArray response = tag->processCommand(command + char(crc & 0xff) + char(crc >> 8)); @@ -62,7 +62,7 @@ QNearFieldTarget::RequestId TagType1::sendCommand(const QByteArray &command) } // check crc - if (qChecksum(QByteArrayView(response.constData(), response.length()), Qt::ChecksumItuV41) != 0) { + if (qChecksum(QByteArrayView(response.constData(), response.size()), Qt::ChecksumItuV41) != 0) { reportError(QNearFieldTarget::ChecksumMismatchError, id); return id; } @@ -117,16 +117,16 @@ QNearFieldTarget::RequestId TagType2::sendCommand(const QByteArray &command) return id; } - quint16 crc = qChecksum(QByteArrayView(command.constData(), command.length()), Qt::ChecksumItuV41); + quint16 crc = qChecksum(QByteArrayView(command.constData(), command.size()), Qt::ChecksumItuV41); QByteArray response = tag->processCommand(command + char(crc & 0xff) + char(crc >> 8)); if (response.isEmpty()) return id; - if (response.length() > 1) { + if (response.size() > 1) { // check crc - if (qChecksum(QByteArrayView(response.constData(), response.length()), Qt::ChecksumItuV41) != 0) { + if (qChecksum(QByteArrayView(response.constData(), response.size()), Qt::ChecksumItuV41) != 0) { reportError(QNearFieldTarget::ChecksumMismatchError, id); return id; } diff --git a/tests/auto/nfccommons/qtlv.cpp b/tests/auto/nfccommons/qtlv.cpp index b74365e9..46c19553 100644 --- a/tests/auto/nfccommons/qtlv.cpp +++ b/tests/auto/nfccommons/qtlv.cpp @@ -104,7 +104,7 @@ bool QTlvReader::atEnd() const if (m_requestId.isValid()) return false; - return (m_index == m_tlvData.length()) || (tag() == 0xfe); + return (m_index == m_tlvData.size()) || (tag() == 0xfe); } /*! @@ -204,8 +204,8 @@ QByteArray QTlvReader::data() bool QTlvReader::readMoreData(int sparseOffset) { - while (sparseOffset >= m_tlvData.length()) { - int absOffset = absoluteOffset(m_tlvData.length()); + while (sparseOffset >= m_tlvData.size()) { + int absOffset = absoluteOffset(m_tlvData.size()); QByteArray data; @@ -236,7 +236,7 @@ bool QTlvReader::readMoreData(int sparseOffset) } } - if (data.isEmpty() && sparseOffset >= m_tlvData.length()) + if (data.isEmpty() && sparseOffset >= m_tlvData.size()) return false; m_tlvData.append(data); @@ -307,7 +307,7 @@ void QTlvWriter::writeTlv(quint8 tagType, const QByteArray &data) m_buffer.append(tagType); if (tagType != 0x00 && tagType != 0xfe) { - int length = data.length(); + int length = data.size(); if (length < 0xff) { m_buffer.append(quint8(length)); } else { @@ -353,7 +353,7 @@ bool QTlvWriter::process(bool all) if (m_tagMemorySize == -1) { if (m_rawData) - m_tagMemorySize = m_rawData->length(); + m_tagMemorySize = m_rawData->size(); else if (QNearFieldTagType1 *tag = qobject_cast<QNearFieldTagType1 *>(m_target)) { if (m_requestId.isValid()) { m_tagMemorySize = 8 * (tag->requestResponse(m_requestId).toUInt() + 1); @@ -370,7 +370,7 @@ bool QTlvWriter::process(bool all) if (spaceRemaining < 1) return false; - int length = qMin(spaceRemaining, m_buffer.length()); + int length = qMin(spaceRemaining, m_buffer.size()); if (m_rawData) { m_rawData->replace(m_index, length, m_buffer); @@ -422,8 +422,8 @@ bool QTlvWriter::process(bool all) int fillLength = qMin(nextBlockStart - m_index, spaceRemaining - bufferIndex); - if (fillLength && (all || m_buffer.length() - bufferIndex >= fillLength) && - (m_buffer.length() != bufferIndex)) { + if (fillLength && (all || m_buffer.size() - bufferIndex >= fillLength) && + (m_buffer.size() != bufferIndex)) { // sufficient data available if (m_requestId.isValid()) { const QVariant v = tag->requestResponse(m_requestId); @@ -431,7 +431,7 @@ bool QTlvWriter::process(bool all) // read in block QByteArray block = v.toByteArray(); - int fill = qMin(fillLength, m_buffer.length() - bufferIndex); + int fill = qMin(fillLength, m_buffer.size() - bufferIndex); for (int i = m_index - currentBlockStart; i < fill; ++i) block[i] = m_buffer.at(bufferIndex++); @@ -441,7 +441,7 @@ bool QTlvWriter::process(bool all) return false; } else if (v.typeId() == QMetaType::Bool) { m_requestId = QNearFieldTarget::RequestId(); - int fill = qMin(fillLength, m_buffer.length() - bufferIndex); + int fill = qMin(fillLength, m_buffer.size() - bufferIndex); bufferIndex = fill - (m_index - currentBlockStart); // write complete diff --git a/tests/auto/nfccommons/targetemulator.cpp b/tests/auto/nfccommons/targetemulator.cpp index 49ea8a72..8a77989b 100644 --- a/tests/auto/nfccommons/targetemulator.cpp +++ b/tests/auto/nfccommons/targetemulator.cpp @@ -53,7 +53,7 @@ void NfcTagType1::load(QSettings *settings) qWarning("Only NFC TagType1 v1.0 behavior is supported."); quint8 tms = memory.at(10); - if (memory.length() != 8 * (tms + 1)) + if (memory.size() != 8 * (tms + 1)) qWarning("Static memory size does not match TMS value."); quint8 rwa = memory.at(11); @@ -102,7 +102,7 @@ QByteArray NfcTagType1::processCommand(const QByteArray &command) bool tagType1 = (hr0 & 0xf0) == 0x10; bool dynamic = (hr0 & 0x0f) != 0x01; - if (command.length() == 9) { + if (command.size() == 9) { // static memory model command quint8 opcode = command.at(0); quint8 address = command.at(1); @@ -110,7 +110,7 @@ QByteArray NfcTagType1::processCommand(const QByteArray &command) QByteArray uid = command.mid(3, 4); // check checksum - if (qChecksum(QByteArrayView(command.constData(), command.length()), Qt::ChecksumItuV41) != 0) + if (qChecksum(QByteArrayView(command.constData(), command.size()), Qt::ChecksumItuV41) != 0) return QByteArray(); // check UID @@ -171,7 +171,7 @@ QByteArray NfcTagType1::processCommand(const QByteArray &command) response.append(memory.left(4)); break; } - } else if (tagType1 && dynamic && command.length() == 16) { + } else if (tagType1 && dynamic && command.size() == 16) { // dynamic memory model command quint8 opcode = command.at(0); quint8 address = command.at(1); @@ -179,7 +179,7 @@ QByteArray NfcTagType1::processCommand(const QByteArray &command) QByteArray uid = command.mid(10, 4); // check checksum - if (qChecksum(QByteArrayView(command.constData(), command.length()), Qt::ChecksumItuV41) != 0) + if (qChecksum(QByteArrayView(command.constData(), command.size()), Qt::ChecksumItuV41) != 0) return QByteArray(); // check UID @@ -233,7 +233,7 @@ QByteArray NfcTagType1::processCommand(const QByteArray &command) } if (!response.isEmpty()) { - quint16 crc = qChecksum(QByteArrayView(response.constData(), response.length()), Qt::ChecksumItuV41); + quint16 crc = qChecksum(QByteArrayView(response.constData(), response.size()), Qt::ChecksumItuV41); response.append(quint8(crc & 0xff)); response.append(quint8(crc >> 8)); } @@ -277,13 +277,13 @@ QByteArray NfcTagType2::processCommand(const QByteArray &command) QByteArray response; // check checksum - if (qChecksum(QByteArrayView(command.constData(), command.length()), Qt::ChecksumItuV41) != 0) + if (qChecksum(QByteArrayView(command.constData(), command.size()), Qt::ChecksumItuV41) != 0) return QByteArray(); if (expectPacket2) { expectPacket2 = false; quint8 sector = command.at(0); - if (sector * 1024 > memory.length()) + if (sector * 1024 > memory.size()) return NACK; else { currentSector = sector; @@ -299,8 +299,8 @@ QByteArray NfcTagType2::processCommand(const QByteArray &command) int absoluteBlock = currentSector * 256 + block; response.append(memory.mid(absoluteBlock * 4, 16)); - if (response.length() != 16) - response.append(QByteArray(16 - response.length(), '\0')); + if (response.size() != 16) + response.append(QByteArray(16 - response.size(), '\0')); break; } @@ -319,7 +319,7 @@ QByteArray NfcTagType2::processCommand(const QByteArray &command) return ACK; } case 0xc2: // SECTOR SELECT - Packet 1 - if (memory.length() > 1024) { + if (memory.size() > 1024) { expectPacket2 = true; return ACK; } @@ -334,7 +334,7 @@ QByteArray NfcTagType2::processCommand(const QByteArray &command) } if (!response.isEmpty()) { - quint16 crc = qChecksum(QByteArrayView(response.constData(), response.length()), Qt::ChecksumItuV41); + quint16 crc = qChecksum(QByteArrayView(response.constData(), response.size()), Qt::ChecksumItuV41); response.append(quint8(crc & 0xff)); response.append(quint8(crc >> 8)); } |