summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlowenergycontroller
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2018-08-14 11:08:18 +0200
committerOliver Wolff <oliver.wolff@qt.io>2018-08-15 07:56:46 +0000
commita0ade068004ad869d6235ae8d6cd5e2050bf765d (patch)
tree42c949ba2fa7fcd4ab5356293d1ef3cad1c436f6 /tests/auto/qlowenergycontroller
parent84f0e76c647e7f09529b79525b2d4fbc698576d8 (diff)
Replace foreach with for loop and set QT_NO_FOREACH
To avoid unnecessary copies, const is used wherever possible. Change-Id: Ic743716512751cfd24fad5bd37c244b115dd26fe Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests/auto/qlowenergycontroller')
-rw-r--r--tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp18
1 files changed, 10 insertions, 8 deletions
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");