summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
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/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
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/qlowenergydescriptor/tst_qlowenergydescriptor.cpp')
-rw-r--r--tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp11
1 files changed, 6 insertions, 5 deletions
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;