diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-07-18 13:44:09 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-07-23 11:01:47 +0200 |
commit | d5731113e912e0df17f19fcdb12b4b6b68256220 (patch) | |
tree | 543c437f8ba375175631a05488e3e2cbd2fe2482 /tests | |
parent | 3956cae8adc2cb7f8f883e52a7f19e4f5b9fea29 (diff) |
Remove old GATT API
The subsequent patches will rename QLowEnergyControllerNew to
QLowEnergyController and fix up the documentation fragments which still
point to the old API.
Change-Id: I084e6b1a85a17f424702018f3ad7047bda35d46a
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'tests')
3 files changed, 5 insertions, 74 deletions
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp index 75c1c821..398fb1ad 100644 --- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp +++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp @@ -52,8 +52,6 @@ #include <qbluetoothserver.h> #include <qbluetoothserviceinfo.h> #include <qlowenergyserviceinfo.h> -#include <qlowenergycontroller.h> -#include <qlowenergycharacteristicinfo.h> QT_USE_NAMESPACE @@ -376,8 +374,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() QFETCH(QBluetoothDeviceInfo, deviceInfo); QFETCH(QList<QBluetoothUuid>, uuidFilter); QFETCH(QBluetoothServiceDiscoveryAgent::Error, serviceDiscoveryError); - QLowEnergyController leController; - bool leDevice = false; + QBluetoothLocalDevice localDevice; qDebug() << "Scanning address" << deviceInfo.address().toString(); QBluetoothServiceDiscoveryAgent discoveryAgent(localDevice.address()); @@ -406,8 +403,6 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() connect(&discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(serviceError(QBluetoothServiceDiscoveryAgent::Error))); - QSignalSpy leConnectedSpy(&leController, SIGNAL(connected(QLowEnergyServiceInfo))); - discoveryAgent.start(); /* @@ -469,7 +464,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() } } - int leCounter = 0; + while (!leDiscoveredSpy.isEmpty()) { const QVariant v = leDiscoveredSpy.takeFirst().at(0); if (v.userType() == qMetaTypeId<QLowEnergyServiceInfo>()) @@ -478,72 +473,13 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() *reinterpret_cast<const QLowEnergyServiceInfo*>(v.constData()); QVERIFY(info.isValid()); - if (info.device().coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) { - leDevice = true; - leController.connectToService(info); - leCounter ++; - } - + QVERIFY(info.device().coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration); } else { QFAIL("Unknown type returned by service discovery"); } } - // In case it is not LE device next steps will be skipped. - // In case of regular Bluetooth devices there is no need to go in to the loop below. - if (leDevice) { - scanTime = MaxScanTime; - while (leConnectedSpy.count() != leCounter && scanTime > 0) { - QTest::qWait(1000); - scanTime -= 1000; - } - int leTestCounter = 0; - QSignalSpy leDisonnectedSpy(&leController, SIGNAL(disconnected(QLowEnergyServiceInfo))); - while (!leConnectedSpy.isEmpty()) { - const QVariant v = leConnectedSpy.takeFirst().at(0); - if (v.userType() == qMetaTypeId<QLowEnergyServiceInfo>()) - { - const QLowEnergyServiceInfo info = - *reinterpret_cast<const QLowEnergyServiceInfo*>(v.constData()); - - QVERIFY(info.isValid()); - QCOMPARE(leController.errorString(), QString()); - QCOMPARE(leController.error(), QLowEnergyController::NoError); - QVERIFY((info.characteristics().size() > 0)); - qDebug() << "LE Service Connected: " << info.serviceName() << info.serviceUuid(); - leTestCounter++; - for (int i = 0; i < info.characteristics().size(); i++) - QVERIFY(info.characteristics().at(i).isValid()); - leController.disconnectFromService(info); - } else { - QFAIL("Unknown type returned by service discovery"); - } - - } - QCOMPARE(leCounter, leTestCounter); - scanTime = MaxScanTime; - while (leDisonnectedSpy.count() != leTestCounter && scanTime > 0) { - QTest::qWait(1000); - scanTime -= 1000; - } - - while (!leDisonnectedSpy.isEmpty()) { - const QVariant v = leDisonnectedSpy.takeFirst().at(0); - if (v.userType() == qMetaTypeId<QLowEnergyServiceInfo>()) - { - const QLowEnergyServiceInfo info = - *reinterpret_cast<const QLowEnergyServiceInfo*>(v.constData()); - - QVERIFY(info.isValid()); - qDebug() << "LE Service Disconnected: " << info.serviceName() << info.serviceUuid(); - } else { - QFAIL("Unknown type returned by service discovery"); - } - - } - } - QVERIFY(discoveryAgent.discoveredServices().count() != 0); discoveryAgent.clear(); QVERIFY(discoveryAgent.discoveredServices().count() == 0); diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp index 8a4c5af7..3d501351 100644 --- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp +++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp @@ -191,7 +191,6 @@ void tst_QLowEnergyController::tst_verifyAllServices() info.serviceUuid().toString().toLatin1()); } - QVERIFY(info.characteristics().isEmpty()); QCOMPARE(remoteDevice, info.device().address()); } } @@ -1351,7 +1350,7 @@ void tst_QLowEnergyController::verifyServiceProperties( // value different in other revisions and test may fail QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x82)); QCOMPARE(chars[0].properties(), - (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristicInfo::WriteNoResponse)); + (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristic::WriteNoResponse)); QCOMPARE(chars[0].value(), QByteArray("")); QVERIFY(chars[0].isValid()); QVERIFY(info->contains(chars[0])); @@ -1385,7 +1384,7 @@ void tst_QLowEnergyController::verifyServiceProperties( // value different in other revisions and test may fail QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x86)); QCOMPARE(chars[1].properties(), - (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristicInfo::WriteNoResponse)); + (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristic::WriteNoResponse)); QCOMPARE(chars[1].value(), QByteArray("")); QVERIFY(chars[1].isValid()); QVERIFY(info->contains(chars[1])); diff --git a/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp b/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp index 84631a9c..e908ae97 100644 --- a/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp +++ b/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp @@ -104,7 +104,6 @@ void tst_QLowEnergyServiceInfo::tst_construction() QCOMPARE(serviceInfo.serviceUuid().toString(), QBluetoothUuid().toString()); QCOMPARE(serviceInfo.serviceType(), QLowEnergyServiceInfo::PrimaryService); QCOMPARE(serviceInfo.isConnected(), false); - QCOMPARE(serviceInfo.characteristics().size(), 0); QCOMPARE(serviceInfo.device(), QBluetoothDeviceInfo()); } @@ -223,7 +222,6 @@ void tst_QLowEnergyServiceInfo::tst_assignment() QCOMPARE(copyInfo.device().coreConfigurations(), coreConfiguration); QCOMPARE(copyInfo.serviceType(), serviceType); QCOMPARE(copyInfo.isConnected(), false); - QCOMPARE(copyInfo.characteristics().size(), 0); QCOMPARE(copyInfo.device(), deviceInfo); } @@ -265,8 +263,6 @@ void tst_QLowEnergyServiceInfo::tst_assignment() QCOMPARE(copyInfo2.device().coreConfigurations(), coreConfiguration); QCOMPARE(copyInfo1.isConnected(), false); QCOMPARE(copyInfo2.isConnected(), false); - QCOMPARE(copyInfo1.characteristics().size(), 0); - QCOMPARE(copyInfo2.characteristics().size(), 0); QCOMPARE(copyInfo1.device(), deviceInfo); QCOMPARE(copyInfo2.device(), deviceInfo); } |