diff options
Diffstat (limited to 'tests/auto')
10 files changed, 43 insertions, 35 deletions
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp index 7ef78800..a0ff581c 100644 --- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp +++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp @@ -186,12 +186,12 @@ static void dumpAttributeVariant(const QVariant &var, const QString indent) if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) { qDebug("%sSequence", indent.toLocal8Bit().constData()); const QBluetoothServiceInfo::Sequence *sequence = static_cast<const QBluetoothServiceInfo::Sequence *>(var.data()); - foreach (const QVariant &v, *sequence) + for (const QVariant &v : *sequence) dumpAttributeVariant(v, indent + '\t'); } else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) { qDebug("%sAlternative", indent.toLocal8Bit().constData()); const QBluetoothServiceInfo::Alternative *alternative = static_cast<const QBluetoothServiceInfo::Alternative *>(var.data()); - foreach (const QVariant &v, *alternative) + for (const QVariant &v : *alternative) dumpAttributeVariant(v, indent + '\t'); } else if (var.userType() == qMetaTypeId<QBluetoothUuid>()) { QBluetoothUuid uuid = var.value<QBluetoothUuid>(); @@ -237,7 +237,8 @@ static void dumpAttributeVariant(const QVariant &var, const QString indent) static inline void dumpServiceInfoAttributes(const QBluetoothServiceInfo &info) { - foreach (quint16 id, info.attributes()) { + const QList<quint16> attributes = info.attributes(); + for (quint16 id : attributes) { dumpAttributeVariant(info.attribute(id), QString("\t")); } } @@ -254,7 +255,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery_data() // Only need to test the first 5 live devices int max = 5; - foreach (const QBluetoothDeviceInfo &info, devices) { + for (const QBluetoothDeviceInfo &info : qAsConst(devices)) { if (info.isCached()) continue; QTest::newRow("default filter") << info << QList<QBluetoothUuid>() diff --git a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp index eb7ce85a..ae8cf5d0 100644 --- a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp +++ b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp @@ -132,7 +132,7 @@ void tst_QBluetoothServiceInfo::tst_construction() QCOMPARE(serviceInfo.serverChannel(), -1); QCOMPARE(serviceInfo.protocolServiceMultiplexer(), -1); - foreach (QBluetoothUuid::ProtocolUuid u, protUuids) + for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids)) QCOMPARE(serviceInfo.protocolDescriptor(u).count(), 0); } @@ -166,9 +166,9 @@ void tst_QBluetoothServiceInfo::tst_construction() QCOMPARE(copyInfo.device().address(), alternatedeviceInfo.address()); QCOMPARE(serviceInfo.device().address(), alternatedeviceInfo.address()); - foreach (QBluetoothUuid::ProtocolUuid u, protUuids) + for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids)) QCOMPARE(serviceInfo.protocolDescriptor(u).count(), 0); - foreach (QBluetoothUuid::ProtocolUuid u, protUuids) + for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids)) QCOMPARE(copyInfo.protocolDescriptor(u).count(), 0); } } diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp index fa4629ac..05bc1a0f 100644 --- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp +++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp @@ -377,7 +377,7 @@ void tst_QBluetoothSocket::tst_clientCommunication() { /* Send line by line with event loop */ - foreach (const QString &line, data) { + for (const QString &line : qAsConst(data)) { QSignalSpy readyReadSpy(&socket, SIGNAL(readyRead())); QSignalSpy bytesWrittenSpy(&socket, SIGNAL(bytesWritten(qint64))); diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp index f69644c6..6b0481a5 100644 --- a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp +++ b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp @@ -143,14 +143,15 @@ void tst_QBluetoothTransferManager::tst_request() QFETCH(tst_QBluetoothTransferManager_QParameterMap, parameters); QBluetoothTransferRequest transferRequest(address); - foreach (QBluetoothTransferRequest::Attribute key, parameters.keys()) + const QList<QBluetoothTransferRequest::Attribute> attributes = parameters.keys(); + for (QBluetoothTransferRequest::Attribute key : attributes) QCOMPARE(transferRequest.attribute(key), QVariant()); - foreach (QBluetoothTransferRequest::Attribute key, parameters.keys()) + for (QBluetoothTransferRequest::Attribute key : attributes) transferRequest.setAttribute((QBluetoothTransferRequest::Attribute)key, parameters[key]); QCOMPARE(transferRequest.address(), address); - foreach (QBluetoothTransferRequest::Attribute key, parameters.keys()) + for (QBluetoothTransferRequest::Attribute key : attributes) QCOMPARE(transferRequest.attribute(key), parameters[key]); //test copy constructor @@ -158,17 +159,17 @@ void tst_QBluetoothTransferManager::tst_request() QVERIFY(constructorCopy == transferRequest); QVERIFY(!(constructorCopy != transferRequest)); QCOMPARE(constructorCopy.address(), address); - foreach (QBluetoothTransferRequest::Attribute key, parameters.keys()) + for (QBluetoothTransferRequest::Attribute key : attributes) QCOMPARE(constructorCopy.attribute(key), parameters[key]); //test assignment operator QBluetoothTransferRequest request; QVERIFY(request.address().isNull()); - foreach (QBluetoothTransferRequest::Attribute key, parameters.keys()) + for (QBluetoothTransferRequest::Attribute key : attributes) QCOMPARE(request.attribute(key), QVariant()); request = transferRequest; QCOMPARE(request.address(), address); - foreach (QBluetoothTransferRequest::Attribute key, parameters.keys()) + for (QBluetoothTransferRequest::Attribute key : attributes) QCOMPARE(request.attribute(key), parameters[key]); //test that it's a true and independent copy diff --git a/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp b/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp index 1a8a8e52..dcf2c95b 100644 --- a/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp +++ b/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp @@ -98,7 +98,8 @@ void tst_QBluetoothTransferRequest::tst_construction() QBluetoothTransferRequest transferRequest(address); - foreach (int key, parameters.keys()) { + const QList<int> keys = parameters.keys(); + for (const int key : keys) { transferRequest.setAttribute((QBluetoothTransferRequest::Attribute)key, parameters[key]); QCOMPARE(parameters[key], transferRequest.attribute((QBluetoothTransferRequest::Attribute)key)); } @@ -123,7 +124,8 @@ void tst_QBluetoothTransferRequest::tst_assignment() QBluetoothTransferRequest transferRequest(address); - foreach (int key, parameters.keys()) { + const QList<int> keys = parameters.keys(); + for (const int key : keys) { transferRequest.setAttribute((QBluetoothTransferRequest::Attribute)key, parameters[key]); } diff --git a/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp b/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp index e0513cea..1862af7f 100644 --- a/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp +++ b/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp @@ -114,7 +114,7 @@ void tst_QLowEnergyCharacteristic::initTestCase() // find first service with descriptor QLowEnergyController *controller = 0; - foreach (const QBluetoothDeviceInfo &remoteDevice, remoteLeDevices) { + for (const QBluetoothDeviceInfo &remoteDevice : qAsConst(remoteLeDevices)) { controller = new QLowEnergyController(remoteDevice, this); qDebug() << "Connecting to" << remoteDevice.name() << remoteDevice.address() << remoteDevice.deviceUuid(); @@ -138,7 +138,8 @@ void tst_QLowEnergyCharacteristic::initTestCase() QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(), QLowEnergyController::DiscoveredState); - foreach (const QBluetoothUuid &leServiceUuid, controller->services()) { + const QList<QBluetoothUuid> leServiceUuids = controller->services(); + for (const QBluetoothUuid &leServiceUuid : leServiceUuids) { QLowEnergyService *leService = controller->createServiceObject(leServiceUuid, this); if (!leService) continue; @@ -147,8 +148,8 @@ void tst_QLowEnergyCharacteristic::initTestCase() QTRY_VERIFY_WITH_TIMEOUT( leService->state() == QLowEnergyService::ServiceDiscovered, 10000); - QList<QLowEnergyCharacteristic> chars = leService->characteristics(); - foreach (const QLowEnergyCharacteristic &ch, chars) { + const QList<QLowEnergyCharacteristic> chars = leService->characteristics(); + for (const QLowEnergyCharacteristic &ch : chars) { if (!ch.descriptors().isEmpty()) { globalService = leService; globalControl = controller; diff --git a/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp b/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp index 30b2fb75..f3a0e9a4 100644 --- a/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp +++ b/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp @@ -674,7 +674,7 @@ void TestQLowEnergyControllerGattServer::serviceData() const auto inUuids = QSet<QBluetoothUuid>() << descData.uuid() << descData2.uuid() << descData3.uuid(); QSet<QBluetoothUuid> outUuids; - foreach (const QLowEnergyDescriptor &desc, descriptors) + for (const QLowEnergyDescriptor &desc : descriptors) outUuids << desc.uuid(); QCOMPARE(inUuids, outUuids); diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp index 53c2f754..b175ddd0 100644 --- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp +++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp @@ -159,7 +159,8 @@ void tst_QLowEnergyController::initTestCase() bool deviceFound = false; devAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); QTRY_VERIFY_WITH_TIMEOUT(finishedSpy.count() > 0, 30000); - foreach (const QBluetoothDeviceInfo &info, devAgent->discoveredDevices()) { + const QList<QBluetoothDeviceInfo> infos = devAgent->discoveredDevices(); + for (const QBluetoothDeviceInfo &info : infos) { #ifndef Q_OS_MAC if (info.address() == remoteDevice) { #else @@ -343,7 +344,7 @@ void tst_QLowEnergyController::tst_connect() listing.append(v.value<QBluetoothUuid>()); } - foreach (const QBluetoothUuid &uuid, foundServices) { + for (const QBluetoothUuid &uuid : qAsConst(foundServices)) { QVERIFY2(listing.contains(uuid), uuid.toString().toLatin1()); @@ -361,7 +362,7 @@ void tst_QLowEnergyController::tst_connect() QVERIFY(!control.createServiceObject(QBluetoothUuid(QBluetoothUuid::DeviceName))); // initiate characteristic discovery - foreach (QLowEnergyService *service, savedReferences) { + for (QLowEnergyService *service : qAsConst(savedReferences)) { qDebug() << "Discovering" << service->serviceUuid(); QSignalSpy stateSpy(service, SIGNAL(stateChanged(QLowEnergyService::ServiceState))); @@ -378,7 +379,7 @@ void tst_QLowEnergyController::tst_connect() } // ensure that related service objects share same state - foreach (QLowEnergyService* originalService, savedReferences) { + for (QLowEnergyService* originalService : qAsConst(savedReferences)) { QLowEnergyService *newService = control.createServiceObject( originalService->serviceUuid()); QVERIFY(newService); @@ -398,7 +399,7 @@ void tst_QLowEnergyController::tst_connect() } else { QCOMPARE(disconnectedSpy.count(), 1); // after disconnect all service references must be invalid - foreach (const QLowEnergyService *entry, savedReferences) { + for (const QLowEnergyService *entry : qAsConst(savedReferences)) { const QBluetoothUuid &uuid = entry->serviceUuid(); QVERIFY2(entry->state() == QLowEnergyService::InvalidService, uuid.toString().toLatin1()); @@ -1208,7 +1209,7 @@ void tst_QLowEnergyController::verifyServiceProperties( } else if (info->serviceUuid() == QBluetoothUuid(QString("f000aa40-0451-4000-b000-000000000000"))) { qDebug() << "Verifying Pressure"; - QList<QLowEnergyCharacteristic> chars = info->characteristics(); + const QList<QLowEnergyCharacteristic> chars = info->characteristics(); QVERIFY(chars.count() >= 3); // Pressure Data @@ -1271,7 +1272,7 @@ void tst_QLowEnergyController::verifyServiceProperties( //calibration and period characteristic are swapped, ensure we don't depend on their order QLowEnergyCharacteristic calibration, period; - foreach (const QLowEnergyCharacteristic &ch, chars) { + for (const QLowEnergyCharacteristic &ch : chars) { //find calibration characteristic if (ch.uuid() == QBluetoothUuid(QString("f000aa43-0451-4000-b000-000000000000"))) calibration = ch; @@ -1660,7 +1661,8 @@ bool tst_QLowEnergyController::verifyClientCharacteristicValue(const QByteArray void tst_QLowEnergyController::tst_defaultBehavior() { QList<QBluetoothAddress> foundAddresses; - foreach (const QBluetoothHostInfo &info, QBluetoothLocalDevice::allDevices()) + const QList<QBluetoothHostInfo> infos = QBluetoothLocalDevice::allDevices(); + for (const QBluetoothHostInfo &info : infos) foundAddresses.append(info.address()); const QBluetoothAddress randomAddress("11:22:33:44:55:66"); diff --git a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp index e6728eab..b6ab0e53 100644 --- a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp +++ b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp @@ -105,7 +105,7 @@ void tst_QLowEnergyDescriptor::initTestCase() // find first service with descriptor QLowEnergyController *controller = 0; - foreach (const QBluetoothDeviceInfo& remoteDeviceInfo, remoteLeDeviceInfos) { + for (const QBluetoothDeviceInfo& remoteDeviceInfo : qAsConst(remoteLeDeviceInfos)) { controller = new QLowEnergyController(remoteDeviceInfo, this); qDebug() << "Connecting to" << remoteDeviceInfo.address(); controller->connectToDevice(); @@ -128,7 +128,8 @@ void tst_QLowEnergyDescriptor::initTestCase() QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(), QLowEnergyController::DiscoveredState); - foreach (const QBluetoothUuid &leServiceUuid, controller->services()) { + const QList<QBluetoothUuid> leServiceUuids = controller->services(); + for (const QBluetoothUuid &leServiceUuid : leServiceUuids) { QLowEnergyService *leService = controller->createServiceObject(leServiceUuid, this); if (!leService) continue; @@ -137,8 +138,8 @@ void tst_QLowEnergyDescriptor::initTestCase() QTRY_VERIFY_WITH_TIMEOUT( leService->state() == QLowEnergyService::ServiceDiscovered, 10000); - QList<QLowEnergyCharacteristic> chars = leService->characteristics(); - foreach (const QLowEnergyCharacteristic &ch, chars) { + const QList<QLowEnergyCharacteristic> chars = leService->characteristics(); + for (const QLowEnergyCharacteristic &ch : chars) { if (!ch.descriptors().isEmpty()) { globalService = leService; globalControl = controller; @@ -239,7 +240,7 @@ void tst_QLowEnergyDescriptor::tst_assignCompare() QList<QLowEnergyDescriptor> targets; const QList<QLowEnergyCharacteristic> chars = globalService->characteristics(); - foreach (const QLowEnergyCharacteristic &ch, chars) { + for (const QLowEnergyCharacteristic &ch : chars) { if (!ch.descriptors().isEmpty()) { targets = ch.descriptors(); break; diff --git a/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp b/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp index d5b8720f..c3c457e9 100644 --- a/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp +++ b/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp @@ -205,7 +205,7 @@ void tst_QNearFieldManager::registerNdefMessageHandler_type() const QNdefMessage message = messageSpy.first().at(0).value<QNdefMessage>(); bool hasRecord = false; - foreach (const QNdefRecord &record, message) { + for (const QNdefRecord &record : message) { if (record.typeNameFormat() == typeNameFormat && record.type() == type) { hasRecord = true; break; |