summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbluetoothdeviceinfo/qbluetoothdeviceinfo.pro3
-rw-r--r--tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp83
-rw-r--r--tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro3
-rw-r--r--tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp99
-rw-r--r--tests/auto/qlowenergycharacteristicinfo/qlowenergycharacteristicinfo.pro9
-rw-r--r--tests/auto/qlowenergycharacteristicinfo/tst_qlowenergycharacteristicinfo.cpp219
-rw-r--r--tests/auto/qlowenergydescriptorinfo/qlowenergydescriptorinfo.pro9
-rw-r--r--tests/auto/qlowenergydescriptorinfo/tst_qlowenergydescriptorinfo.cpp176
-rw-r--r--tests/auto/qlowenergyserviceinfo/qlowenergyserviceinfo.pro9
-rw-r--r--tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp281
10 files changed, 864 insertions, 27 deletions
diff --git a/tests/auto/qbluetoothdeviceinfo/qbluetoothdeviceinfo.pro b/tests/auto/qbluetoothdeviceinfo/qbluetoothdeviceinfo.pro
index 43ca52ed..408628ea 100644
--- a/tests/auto/qbluetoothdeviceinfo/qbluetoothdeviceinfo.pro
+++ b/tests/auto/qbluetoothdeviceinfo/qbluetoothdeviceinfo.pro
@@ -4,3 +4,6 @@ CONFIG += testcase
QT = core concurrent bluetooth testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+qnx {
+ LIBS += -lbtapi
+}
diff --git a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
index adc61199..371a7bf7 100644
--- a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
+++ b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
@@ -52,6 +52,7 @@ QT_USE_NAMESPACE
Q_DECLARE_METATYPE(QBluetoothDeviceInfo::ServiceClasses)
Q_DECLARE_METATYPE(QBluetoothDeviceInfo::MajorDeviceClass)
+Q_DECLARE_METATYPE(QBluetoothDeviceInfo::CoreConfiguration)
class tst_QBluetoothDeviceInfo : public QObject
{
@@ -101,6 +102,7 @@ void tst_QBluetoothDeviceInfo::tst_construction_data()
QTest::addColumn<QBluetoothDeviceInfo::ServiceClasses>("serviceClasses");
QTest::addColumn<QBluetoothDeviceInfo::MajorDeviceClass>("majorDeviceClass");
QTest::addColumn<quint8>("minorDeviceClass");
+ QTest::addColumn<QBluetoothDeviceInfo::CoreConfiguration>("coreConfiguration");
// bits 12-8 Major
// bits 7-2 Minor
@@ -110,120 +112,144 @@ void tst_QBluetoothDeviceInfo::tst_construction_data()
<< quint32(0x000000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous);
+ << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
+ << QBluetoothDeviceInfo::BaseRateCoreConfiguration;
QTest::newRow("0x000100 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000100)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedComputer);
+ << quint8(QBluetoothDeviceInfo::UncategorizedComputer)
+ << QBluetoothDeviceInfo::BaseRateCoreConfiguration;
QTest::newRow("0x000104 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000104)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
- << quint8(QBluetoothDeviceInfo::DesktopComputer);
+ << quint8(QBluetoothDeviceInfo::DesktopComputer)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000118 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000118)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
- << quint8(QBluetoothDeviceInfo::WearableComputer);
+ << quint8(QBluetoothDeviceInfo::WearableComputer)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000200 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000200)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedPhone);
+ << quint8(QBluetoothDeviceInfo::UncategorizedPhone)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000204 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000204)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
- << quint8(QBluetoothDeviceInfo::CellularPhone);
+ << quint8(QBluetoothDeviceInfo::CellularPhone)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000214 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000214)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
- << quint8(QBluetoothDeviceInfo::CommonIsdnAccessPhone);
+ << quint8(QBluetoothDeviceInfo::CommonIsdnAccessPhone)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000300 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000300)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
- << quint8(QBluetoothDeviceInfo::NetworkFullService);
+ << quint8(QBluetoothDeviceInfo::NetworkFullService)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000320 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000320)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
- << quint8(QBluetoothDeviceInfo::NetworkLoadFactorOne);
+ << quint8(QBluetoothDeviceInfo::NetworkLoadFactorOne)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x0003E0 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x0003E0)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
- << quint8(QBluetoothDeviceInfo::NetworkNoService);
+ << quint8(QBluetoothDeviceInfo::NetworkNoService)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000400 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000400)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::AudioVideoDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedAudioVideoDevice);
+ << quint8(QBluetoothDeviceInfo::UncategorizedAudioVideoDevice)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000448 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000448)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::AudioVideoDevice
- << quint8(QBluetoothDeviceInfo::GamingDevice);
+ << quint8(QBluetoothDeviceInfo::GamingDevice)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000500 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000500)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PeripheralDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedPeripheral);
+ << quint8(QBluetoothDeviceInfo::UncategorizedPeripheral)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x0005D8 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x0005D8)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PeripheralDevice
- << quint8(QBluetoothDeviceInfo::KeyboardWithPointingDevicePeripheral | QBluetoothDeviceInfo::CardReaderPeripheral);
+ << quint8(QBluetoothDeviceInfo::KeyboardWithPointingDevicePeripheral | QBluetoothDeviceInfo::CardReaderPeripheral)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000600 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000600)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ImagingDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedImagingDevice);
+ << quint8(QBluetoothDeviceInfo::UncategorizedImagingDevice)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
QTest::newRow("0x000680 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000680)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ImagingDevice
- << quint8(QBluetoothDeviceInfo::ImagePrinter);
+ << quint8(QBluetoothDeviceInfo::ImagePrinter)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
QTest::newRow("0x000700 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000700)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::WearableDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedWearableDevice);
+ << quint8(QBluetoothDeviceInfo::UncategorizedWearableDevice)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
QTest::newRow("0x000714 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000714)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::WearableDevice
- << quint8(QBluetoothDeviceInfo::WearableGlasses);
+ << quint8(QBluetoothDeviceInfo::WearableGlasses)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
QTest::newRow("0x000800 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000800)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ToyDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedToy);
+ << quint8(QBluetoothDeviceInfo::UncategorizedToy)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
QTest::newRow("0x000814 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000814)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ToyDevice
- << quint8(QBluetoothDeviceInfo::ToyGame);
+ << quint8(QBluetoothDeviceInfo::ToyGame)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
QTest::newRow("0x001f00 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x001f00)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::UncategorizedDevice
- << quint8(0);
+ << quint8(0)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
QTest::newRow("0x002000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x002000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::PositioningService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous);
+ << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
QTest::newRow("0x100000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x100000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::InformationService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous);
+ << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
QTest::newRow("0xFFE000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0xFFE000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::AllServices)
<< QBluetoothDeviceInfo::MiscellaneousDevice
- << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous);
+ << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
}
void tst_QBluetoothDeviceInfo::tst_construction()
@@ -241,6 +267,7 @@ void tst_QBluetoothDeviceInfo::tst_construction()
QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
+ QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
@@ -251,6 +278,7 @@ void tst_QBluetoothDeviceInfo::tst_construction()
QCOMPARE(deviceInfo.serviceClasses(), serviceClasses);
QCOMPARE(deviceInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(deviceInfo.minorDeviceClass(), minorDeviceClass);
+ QCOMPARE(deviceInfo.coreConfiguration(), coreConfiguration);
QBluetoothDeviceInfo copyInfo(deviceInfo);
@@ -261,6 +289,7 @@ void tst_QBluetoothDeviceInfo::tst_construction()
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
+ QCOMPARE(copyInfo.coreConfiguration(), coreConfiguration);
}
}
@@ -277,8 +306,10 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
+ QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
+ deviceInfo.setCoreConfiguration(coreConfiguration);
QVERIFY(deviceInfo.isValid());
@@ -292,6 +323,7 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
+ QCOMPARE(copyInfo.coreConfiguration(), coreConfiguration);
}
{
@@ -308,6 +340,7 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
+ QCOMPARE(copyInfo.coreConfiguration(), coreConfiguration);
}
{
@@ -333,6 +366,8 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QCOMPARE(copyInfo2.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo1.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo2.minorDeviceClass(), minorDeviceClass);
+ QCOMPARE(copyInfo1.coreConfiguration(), coreConfiguration);
+ QCOMPARE(copyInfo2.coreConfiguration(), coreConfiguration);
}
{
diff --git a/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro b/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro
index 7b8ee74a..e678aa12 100644
--- a/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro
+++ b/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro
@@ -3,5 +3,8 @@ TARGET = tst_qbluetoothservicediscoveryagent
CONFIG += testcase
QT = core concurrent bluetooth testlib
+qnx {
+ LIBS += -lbtapi
+}
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
index a55ba0c3..cd5b1166 100644
--- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
+++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
@@ -51,11 +51,15 @@
#include <qbluetoothlocaldevice.h>
#include <qbluetoothserver.h>
#include <qbluetoothserviceinfo.h>
+#include <qlowenergyserviceinfo.h>
+#include <qlowenergycontroller.h>
+#include <qlowenergycharacteristicinfo.h>
QT_USE_NAMESPACE
Q_DECLARE_METATYPE(QBluetoothDeviceInfo)
Q_DECLARE_METATYPE(QBluetoothServiceDiscoveryAgent::Error)
+Q_DECLARE_METATYPE(QLowEnergyServiceInfo)
// Maximum time to for bluetooth device scan
const int MaxScanTime = 5 * 60 * 1000; // 5 minutes in ms
@@ -71,6 +75,7 @@ public:
public slots:
void deviceDiscoveryDebug(const QBluetoothDeviceInfo &info);
void serviceDiscoveryDebug(const QBluetoothServiceInfo &info);
+ void leServiceDiscoveryDebug(const QLowEnergyServiceInfo &info);
void serviceError(const QBluetoothServiceDiscoveryAgent::Error err);
private slots:
@@ -100,6 +105,7 @@ tst_QBluetoothServiceDiscoveryAgent::tst_QBluetoothServiceDiscoveryAgent()
qRegisterMetaType<QBluetoothDeviceInfo>("QBluetoothDeviceInfo");
qRegisterMetaType<QBluetoothServiceInfo>("QBluetoothServiceInfo");
+ qRegisterMetaType<QLowEnergyServiceInfo>("QLowEnergyServiceInfo");
qRegisterMetaType<QList<QBluetoothUuid> >("QList<QBluetoothUuid>");
qRegisterMetaType<QBluetoothServiceDiscoveryAgent::Error>("QBluetoothServiceDiscoveryAgent::Error");
qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::Error>("QBluetoothDeviceDiscoveryAgent::Error");
@@ -180,6 +186,14 @@ void tst_QBluetoothServiceDiscoveryAgent::serviceDiscoveryDebug(const QBluetooth
qDebug() << "\tRFCOMM server channel:" << info.serverChannel();
}
+void tst_QBluetoothServiceDiscoveryAgent::leServiceDiscoveryDebug(const QLowEnergyServiceInfo &info)
+{
+ qDebug() << "Discovered LE service on"
+ << info.device().name() << info.device().address().toString();
+ qDebug() << "\tService name:" << info.name();
+ qDebug() << "\tUUID:" << info.uuid();
+}
+
static void dumpAttributeVariant(const QVariant &var, const QString indent)
{
if (!var.isValid()) {
@@ -316,7 +330,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscoveryAdapters()
QVERIFY(serviceInfo.registerService());
QVERIFY(server.isListening());
- qDebug() << "Scanning address" << addresses[0].toString();
+ qDebug() << "Scanning address " << addresses[0].toString();
QBluetoothServiceDiscoveryAgent discoveryAgent(addresses[1]);
bool setAddress = discoveryAgent.setRemoteAddress(addresses[0]);
@@ -362,9 +376,9 @@ 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());
bool setAddress = discoveryAgent.setRemoteAddress(deviceInfo.address());
@@ -384,11 +398,16 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
QSignalSpy finishedSpy(&discoveryAgent, SIGNAL(finished()));
QSignalSpy errorSpy(&discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)));
QSignalSpy discoveredSpy(&discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)));
+ QSignalSpy leDiscoveredSpy(&discoveryAgent, SIGNAL(serviceDiscovered(QLowEnergyServiceInfo)));
// connect(&discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
// this, SLOT(serviceDiscoveryDebug(QBluetoothServiceInfo)));
+// connect(&discoveryAgent, SIGNAL(serviceDiscovered(QLowEnergyServiceInfo)),
+// this, SLOT(leServiceDiscoveryDebug(QLowEnergyServiceInfo)));
connect(&discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)),
this, SLOT(serviceError(QBluetoothServiceDiscoveryAgent::Error)));
+ QSignalSpy leConnectedSpy(&leController, SIGNAL(connected(QLowEnergyServiceInfo)));
+
discoveryAgent.start();
QVERIFY(discoveryAgent.isActive());
@@ -446,6 +465,80 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
}
}
+ int leCounter = 0;
+ while (!leDiscoveredSpy.isEmpty()) {
+ const QVariant v = leDiscoveredSpy.takeFirst().at(0);
+ if (v.userType() == qMetaTypeId<QLowEnergyServiceInfo>())
+ {
+ const QLowEnergyServiceInfo info =
+ *reinterpret_cast<const QLowEnergyServiceInfo*>(v.constData());
+
+ QVERIFY(info.isValid());
+ if (info.device().coreConfiguration() == QBluetoothDeviceInfo::LowEnergyCoreConfiguration || info.device().coreConfiguration() == QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration) {
+ leDevice = true;
+ leController.connectToService(info);
+ leCounter ++;
+ }
+
+ } 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(info.errorString(), QString());
+ QVERIFY((info.characteristics().size() > 0));
+ qDebug() << "LE Service Connected: " << info.name() << info.uuid();
+ 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());
+ QCOMPARE(info.errorString(), QString());
+ qDebug() << "LE Service Disconnected: " << info.name() << info.uuid();
+ } else {
+ QFAIL("Unknown type returned by service discovery");
+ }
+
+ }
+ }
QVERIFY(discoveryAgent.discoveredServices().count() != 0);
discoveryAgent.clear();
diff --git a/tests/auto/qlowenergycharacteristicinfo/qlowenergycharacteristicinfo.pro b/tests/auto/qlowenergycharacteristicinfo/qlowenergycharacteristicinfo.pro
new file mode 100644
index 00000000..aa4d5842
--- /dev/null
+++ b/tests/auto/qlowenergycharacteristicinfo/qlowenergycharacteristicinfo.pro
@@ -0,0 +1,9 @@
+SOURCES += tst_qlowenergycharacteristicinfo.cpp
+TARGET = tst_qlowenergycharacteristicinfo
+CONFIG += testcase
+
+QT = core bluetooth testlib
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+qnx {
+ LIBS += -lbtapi
+}
diff --git a/tests/auto/qlowenergycharacteristicinfo/tst_qlowenergycharacteristicinfo.cpp b/tests/auto/qlowenergycharacteristicinfo/tst_qlowenergycharacteristicinfo.cpp
new file mode 100644
index 00000000..fa585ffd
--- /dev/null
+++ b/tests/auto/qlowenergycharacteristicinfo/tst_qlowenergycharacteristicinfo.cpp
@@ -0,0 +1,219 @@
+/***************************************************************************
+**
+** Copyright (C) 2013 BlackBerry Limited all rights reserved
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QUuid>
+
+#include <QDebug>
+
+#include <qbluetoothdeviceinfo.h>
+#include <qlowenergycharacteristicinfo.h>
+#include <qbluetoothaddress.h>
+#include <qbluetoothlocaldevice.h>
+#include <qbluetoothuuid.h>
+
+QT_USE_NAMESPACE
+
+Q_DECLARE_METATYPE(QUuid)
+Q_DECLARE_METATYPE(QLowEnergyCharacteristicInfo)
+Q_DECLARE_METATYPE(QBluetoothUuid::CharacteristicId)
+
+class tst_QLowEnergyCharacteristicInfo : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QLowEnergyCharacteristicInfo();
+ ~tst_QLowEnergyCharacteristicInfo();
+
+private slots:
+ void initTestCase();
+ void tst_construction();
+ void tst_assignment_data();
+ void tst_assignment();
+};
+
+tst_QLowEnergyCharacteristicInfo::tst_QLowEnergyCharacteristicInfo()
+{
+}
+
+tst_QLowEnergyCharacteristicInfo::~tst_QLowEnergyCharacteristicInfo()
+{
+}
+
+void tst_QLowEnergyCharacteristicInfo::initTestCase()
+{
+ // start Bluetooth if not started
+ QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
+ device->powerOn();
+ delete device;
+}
+
+void tst_QLowEnergyCharacteristicInfo::tst_construction()
+{
+ const QBluetoothUuid characteristicUuid(QBluetoothUuid::HIDControlPoint);
+ const QBluetoothUuid alternateCharacteristicUuid(QBluetoothUuid::TemperatureMeasurement);
+
+ {
+ QLowEnergyCharacteristicInfo characteristicInfo;
+
+ QVERIFY(!characteristicInfo.isValid());
+ QCOMPARE(characteristicInfo.uuid().toString(), QBluetoothUuid().toString());
+ QCOMPARE(characteristicInfo.value(), QByteArray());
+ QCOMPARE(characteristicInfo.permissions(), 0);
+ QCOMPARE(characteristicInfo.handle(), QString("0x0000"));
+ QCOMPARE(characteristicInfo.name(), QString(""));
+ QCOMPARE(characteristicInfo.isNotificationCharacteristic(), false);
+ QCOMPARE(characteristicInfo.descriptors().count(), 0);
+ QCOMPARE(characteristicInfo.errorString(), QString(""));
+ }
+
+ {
+ QLowEnergyCharacteristicInfo characteristicInfo(characteristicUuid);
+
+ QVERIFY(!characteristicInfo.isValid());
+
+ QCOMPARE(characteristicInfo.uuid().toString(), characteristicUuid.toString());
+ QCOMPARE(characteristicInfo.value(), QByteArray());
+ QCOMPARE(characteristicInfo.permissions(), 0);
+ QCOMPARE(characteristicInfo.handle(), QString("0x0000"));
+ QCOMPARE(characteristicInfo.name(), QString(""));
+ QCOMPARE(characteristicInfo.isNotificationCharacteristic(), false);
+ QCOMPARE(characteristicInfo.descriptors().count(), 0);
+ QCOMPARE(characteristicInfo.errorString(), QString(""));
+
+ QLowEnergyCharacteristicInfo copyInfo(characteristicInfo);
+
+ QVERIFY(!copyInfo.isValid());
+
+ QCOMPARE(copyInfo.uuid().toString(), characteristicUuid.toString());
+
+ copyInfo = QLowEnergyCharacteristicInfo(alternateCharacteristicUuid);
+ QCOMPARE(copyInfo.uuid().toString(), alternateCharacteristicUuid.toString());
+
+ QCOMPARE(copyInfo.handle(), QString("0x0000"));
+ QCOMPARE(copyInfo.value(), QByteArray());
+ QCOMPARE(copyInfo.permissions(), 0);
+ QCOMPARE(copyInfo.handle(), QString("0x0000"));
+ QCOMPARE(copyInfo.name(), QString(""));
+ QCOMPARE(copyInfo.isNotificationCharacteristic(), false);
+ QCOMPARE(copyInfo.descriptors().count(), 0);
+ QCOMPARE(copyInfo.errorString(), QString(""));
+ copyInfo.writeValue("test");
+ QVERIFY(copyInfo.errorString().size() > 0);
+ }
+}
+
+void tst_QLowEnergyCharacteristicInfo::tst_assignment_data()
+{
+ QTest::addColumn<QBluetoothUuid>("characteristicClassUuid");
+
+ QTest::newRow("0x000000 COD") << QBluetoothUuid(QBluetoothUuid::AlertCategoryID);
+ QTest::newRow("0x001000 COD") << QBluetoothUuid(QBluetoothUuid::AlertCategoryIDBitMask);
+ QTest::newRow("0x002000 COD") << QBluetoothUuid(QBluetoothUuid::AlertLevel);
+ QTest::newRow("0x003000 COD") << QBluetoothUuid(QBluetoothUuid::AlertNotificationControlPoint);
+ QTest::newRow("0x004000 COD") << QBluetoothUuid(QBluetoothUuid::AlertStatus);
+ QTest::newRow("0x005000 COD") << QBluetoothUuid(QBluetoothUuid::Appearance);
+ QTest::newRow("0x006000 COD") << QBluetoothUuid(QBluetoothUuid::CSCFeature);
+ QTest::newRow("0x007000 COD") << QBluetoothUuid(QBluetoothUuid::CSCMeasurement);
+ QTest::newRow("0x008000 COD") << QBluetoothUuid(QBluetoothUuid::CurrentTime);
+ QTest::newRow("0x009000 COD") << QBluetoothUuid(QBluetoothUuid::DateTime);
+ QTest::newRow("0x010000 COD") << QBluetoothUuid(QBluetoothUuid::DayOfWeek);
+ QTest::newRow("0x011000 COD") << QBluetoothUuid(QBluetoothUuid::DeviceName);
+ QTest::newRow("0x012000 COD") << QBluetoothUuid(QBluetoothUuid::DSTOffset);
+ QTest::newRow("0x013000 COD") << QBluetoothUuid(QBluetoothUuid::ExactTime256);
+ QTest::newRow("0x014000 COD") << QBluetoothUuid(QBluetoothUuid::HeartRateControlPoint);
+ QTest::newRow("0x015000 COD") << QBluetoothUuid(QBluetoothUuid::IntermediateCuffPressure);
+ QTest::newRow("0x016000 COD") << QBluetoothUuid(QBluetoothUuid::Navigation);
+ QTest::newRow("0x017000 COD") << QBluetoothUuid(QBluetoothUuid::NewAlert);
+ QTest::newRow("0x018000 COD") << QBluetoothUuid(QBluetoothUuid::PeripheralPreferredConnectionParameters);
+}
+
+void tst_QLowEnergyCharacteristicInfo::tst_assignment()
+{
+ QFETCH(QBluetoothUuid, characteristicClassUuid);
+
+ QLowEnergyCharacteristicInfo characteristicInfo(characteristicClassUuid);
+
+ QVERIFY(!characteristicInfo.isValid());
+
+ {
+ QLowEnergyCharacteristicInfo copyInfo = characteristicInfo;
+
+ QVERIFY(!copyInfo.isValid());
+
+ QCOMPARE(copyInfo.uuid(), characteristicClassUuid);
+ QCOMPARE(copyInfo.value(), QByteArray());
+ }
+
+ {
+ QLowEnergyCharacteristicInfo copyInfo;
+
+ QVERIFY(!copyInfo.isValid());
+
+ copyInfo = characteristicInfo;
+
+ QVERIFY(!copyInfo.isValid());
+
+ QCOMPARE(copyInfo.uuid(), characteristicClassUuid);
+ }
+
+ {
+ QLowEnergyCharacteristicInfo copyInfo1;
+ QLowEnergyCharacteristicInfo copyInfo2;
+
+ QVERIFY(!copyInfo1.isValid());
+ QVERIFY(!copyInfo2.isValid());
+
+ copyInfo1 = copyInfo2 = characteristicInfo;
+
+ QVERIFY(!copyInfo1.isValid());
+ QVERIFY(!copyInfo2.isValid());
+ //QVERIFY(QLowEnergyCharacteristicInfo() != copyInfo1);
+
+ QCOMPARE(copyInfo1.uuid(), characteristicClassUuid);
+ QCOMPARE(copyInfo2.uuid(), characteristicClassUuid);
+ }
+}
+
+QTEST_MAIN(tst_QLowEnergyCharacteristicInfo)
+
+#include "tst_qlowenergycharacteristicinfo.moc"
diff --git a/tests/auto/qlowenergydescriptorinfo/qlowenergydescriptorinfo.pro b/tests/auto/qlowenergydescriptorinfo/qlowenergydescriptorinfo.pro
new file mode 100644
index 00000000..f25272a7
--- /dev/null
+++ b/tests/auto/qlowenergydescriptorinfo/qlowenergydescriptorinfo.pro
@@ -0,0 +1,9 @@
+SOURCES += tst_qlowenergydescriptorinfo.cpp
+TARGET = tst_qlowenergydescriptorinfo
+CONFIG += testcase
+
+QT = core bluetooth testlib
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+qnx {
+ LIBS += -lbtapi
+}
diff --git a/tests/auto/qlowenergydescriptorinfo/tst_qlowenergydescriptorinfo.cpp b/tests/auto/qlowenergydescriptorinfo/tst_qlowenergydescriptorinfo.cpp
new file mode 100644
index 00000000..d3abcedf
--- /dev/null
+++ b/tests/auto/qlowenergydescriptorinfo/tst_qlowenergydescriptorinfo.cpp
@@ -0,0 +1,176 @@
+/***************************************************************************
+**
+** Copyright (C) 2013 BlackBerry Limited all rights reserved
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QUuid>
+
+#include <QDebug>
+
+#include <qbluetoothdeviceinfo.h>
+#include <qlowenergydescriptorinfo.h>
+#include <qbluetoothlocaldevice.h>
+#include "qbluetoothuuid.h"
+
+QT_USE_NAMESPACE
+
+Q_DECLARE_METATYPE(QUuid)
+Q_DECLARE_METATYPE(QBluetoothUuid::DescriptorID)
+
+class tst_QLowEnergyDescriptorInfo : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QLowEnergyDescriptorInfo();
+ ~tst_QLowEnergyDescriptorInfo();
+
+private slots:
+ void initTestCase();
+ void tst_construction();
+ void tst_assignment_data();
+ void tst_assignment();
+};
+
+tst_QLowEnergyDescriptorInfo::tst_QLowEnergyDescriptorInfo()
+{
+}
+
+tst_QLowEnergyDescriptorInfo::~tst_QLowEnergyDescriptorInfo()
+{
+}
+
+void tst_QLowEnergyDescriptorInfo::initTestCase()
+{
+ // start Bluetooth if not started
+ QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
+ device->powerOn();
+ delete device;
+}
+
+void tst_QLowEnergyDescriptorInfo::tst_construction()
+{
+ const QBluetoothUuid descriptorUuid(QString("0x2902").toUShort(0,0));
+ const QBluetoothUuid alternateDescriptorUuid(QString("0x2906").toUShort(0,0));
+
+ {
+ QLowEnergyDescriptorInfo descriptorInfo = QLowEnergyDescriptorInfo(QBluetoothUuid());
+
+ QCOMPARE(descriptorInfo.uuid(), QBluetoothUuid());
+ QCOMPARE(descriptorInfo.value(), QByteArray());
+ QCOMPARE(descriptorInfo.properties(), QVariantMap());
+ QCOMPARE(descriptorInfo.handle(), QString("0x0000"));
+ QCOMPARE(descriptorInfo.name(), QString(""));
+ }
+
+ {
+ QLowEnergyDescriptorInfo descriptorInfo(descriptorUuid);
+
+ QCOMPARE(descriptorInfo.uuid().toString(), descriptorUuid.toString());
+
+ QLowEnergyDescriptorInfo copyInfo = descriptorInfo;
+
+ QCOMPARE(copyInfo.uuid().toString(), descriptorUuid.toString());
+
+ copyInfo = QLowEnergyDescriptorInfo(alternateDescriptorUuid);
+ QCOMPARE(copyInfo.uuid().toString(), alternateDescriptorUuid.toString());
+
+ QCOMPARE(copyInfo.uuid(), QBluetoothUuid());
+ QCOMPARE(copyInfo.value(), QByteArray());
+ QCOMPARE(copyInfo.properties(), QVariantMap());
+ QCOMPARE(copyInfo.handle(), QString("0x0000"));
+ QCOMPARE(copyInfo.name(), QString(""));
+
+ }
+}
+
+void tst_QLowEnergyDescriptorInfo::tst_assignment_data()
+{
+ QTest::addColumn<QBluetoothUuid>("descriptorClassUuid");
+
+ QTest::newRow("0x000000 COD") << QBluetoothUuid(QString("0x2901").toUShort(0,0));
+ QTest::newRow("0x001000 COD") << QBluetoothUuid(QString("0x2902").toUShort(0,0));
+ QTest::newRow("0x002000 COD") << QBluetoothUuid(QString("0x2903").toUShort(0,0));
+ QTest::newRow("0x003000 COD") << QBluetoothUuid(QString("0x2904").toUShort(0,0));
+ QTest::newRow("0x004000 COD") << QBluetoothUuid(QString("0x2905").toUShort(0,0));
+ QTest::newRow("0x005000 COD") << QBluetoothUuid(QString("0x2906").toUShort(0,0));
+ QTest::newRow("0x006000 COD") << QBluetoothUuid(QString("0x2907").toUShort(0,0));
+ QTest::newRow("0x007000 COD") << QBluetoothUuid(QString("0x2908").toUShort(0,0));
+ QTest::newRow("0x008000 COD") << QBluetoothUuid(QString("0x2900").toUShort(0,0));
+}
+
+void tst_QLowEnergyDescriptorInfo::tst_assignment()
+{
+ QFETCH(QBluetoothUuid, descriptorClassUuid);
+
+ QLowEnergyDescriptorInfo descriptorInfo(descriptorClassUuid);
+
+
+ {
+ QLowEnergyDescriptorInfo copyInfo = descriptorInfo;
+
+ QCOMPARE(copyInfo.uuid(), descriptorClassUuid);
+ QCOMPARE(copyInfo.value(), QByteArray());
+ }
+
+ {
+ QLowEnergyDescriptorInfo copyInfo = QLowEnergyDescriptorInfo(QBluetoothUuid());
+
+ copyInfo = descriptorInfo;
+
+ QCOMPARE(copyInfo.uuid(), descriptorClassUuid);
+ }
+
+ {
+ QLowEnergyDescriptorInfo copyInfo1 = QLowEnergyDescriptorInfo(QBluetoothUuid());
+ QLowEnergyDescriptorInfo copyInfo2 = QLowEnergyDescriptorInfo(QBluetoothUuid());
+
+ copyInfo1 = copyInfo2 = descriptorInfo;
+
+ QCOMPARE(copyInfo1.uuid(), descriptorClassUuid);
+ QCOMPARE(copyInfo2.uuid(), descriptorClassUuid);
+ }
+
+}
+
+QTEST_MAIN(tst_QLowEnergyDescriptorInfo)
+
+#include "tst_qlowenergydescriptorinfo.moc"
+
diff --git a/tests/auto/qlowenergyserviceinfo/qlowenergyserviceinfo.pro b/tests/auto/qlowenergyserviceinfo/qlowenergyserviceinfo.pro
new file mode 100644
index 00000000..3fa99d76
--- /dev/null
+++ b/tests/auto/qlowenergyserviceinfo/qlowenergyserviceinfo.pro
@@ -0,0 +1,9 @@
+SOURCES += tst_qlowenergyserviceinfo.cpp
+TARGET = tst_qlowenergyserviceinfo
+CONFIG += testcase
+
+QT = core bluetooth testlib
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+qnx {
+ LIBS += -lbtapi
+}
diff --git a/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp b/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp
new file mode 100644
index 00000000..96db5a63
--- /dev/null
+++ b/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp
@@ -0,0 +1,281 @@
+/***************************************************************************
+**
+** Copyright (C) 2013 BlackBerry Limited all rights reserved
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QUuid>
+
+#include <QDebug>
+
+#include <qbluetoothdeviceinfo.h>
+#include <qlowenergyserviceinfo.h>
+#include <qbluetoothaddress.h>
+#include <qbluetoothlocaldevice.h>
+#include <qbluetoothuuid.h>
+
+QT_USE_NAMESPACE
+
+Q_DECLARE_METATYPE(QUuid)
+Q_DECLARE_METATYPE(QLowEnergyServiceInfo::ServiceType)
+Q_DECLARE_METATYPE(QBluetoothDeviceInfo::CoreConfiguration)
+Q_DECLARE_METATYPE(QLowEnergyServiceInfo)
+Q_DECLARE_METATYPE(QBluetoothUuid::ServiceClassUuid)
+
+class tst_QLowEnergyServiceInfo : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QLowEnergyServiceInfo();
+ ~tst_QLowEnergyServiceInfo();
+
+private slots:
+ void initTestCase();
+ void tst_construction();
+ void tst_assignment_data();
+ void tst_assignment();
+};
+
+tst_QLowEnergyServiceInfo::tst_QLowEnergyServiceInfo()
+{
+}
+
+tst_QLowEnergyServiceInfo::~tst_QLowEnergyServiceInfo()
+{
+}
+
+void tst_QLowEnergyServiceInfo::initTestCase()
+{
+ // start Bluetooth if not started
+ QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
+ device->powerOn();
+ delete device;
+}
+
+void tst_QLowEnergyServiceInfo::tst_construction()
+{
+ const QBluetoothUuid serviceUuid(QBluetoothUuid::HeartRate);
+ const QBluetoothUuid alternateServiceUuid(QBluetoothUuid::BatteryService);
+ const QBluetoothDeviceInfo deviceInfo(QBluetoothAddress("001122334455"), "Test Device", 0);
+ const QBluetoothDeviceInfo alternatedeviceInfo(QBluetoothAddress("554433221100"), "Test Device2", 0);
+
+ {
+ QLowEnergyServiceInfo serviceInfo;
+
+ QVERIFY(!serviceInfo.isValid());
+ QCOMPARE(serviceInfo.name(), QString());
+ QCOMPARE(serviceInfo.uuid().toString(), QBluetoothUuid().toString());
+ QCOMPARE(serviceInfo.serviceType(), QLowEnergyServiceInfo::PrimaryService);
+ QCOMPARE(serviceInfo.isConnected(), false);
+ QCOMPARE(serviceInfo.characteristics().size(), 0);
+ QCOMPARE(serviceInfo.errorString(), QString(""));
+ QCOMPARE(serviceInfo.device(), QBluetoothDeviceInfo());
+ }
+
+ {
+ QLowEnergyServiceInfo serviceInfo(serviceUuid);
+ serviceInfo.setDevice(deviceInfo);
+
+ QVERIFY(serviceInfo.isValid());
+
+ QCOMPARE(serviceInfo.uuid().toString(), serviceUuid.toString());
+ QCOMPARE(serviceInfo.device().address(), deviceInfo.address());
+
+ QLowEnergyServiceInfo copyInfo(serviceInfo);
+
+ QVERIFY(copyInfo.isValid());
+
+ QCOMPARE(copyInfo.uuid().toString(), serviceUuid.toString());
+ QCOMPARE(copyInfo.device().address(), deviceInfo.address());
+
+
+ copyInfo = QLowEnergyServiceInfo(alternateServiceUuid);
+ copyInfo.setDevice(alternatedeviceInfo);
+ QCOMPARE(copyInfo.uuid(), alternateServiceUuid);
+
+ QCOMPARE(copyInfo.device().address(), alternatedeviceInfo.address());
+
+ }
+}
+
+void tst_QLowEnergyServiceInfo::tst_assignment_data()
+{
+ QTest::addColumn<QBluetoothAddress>("address");
+ QTest::addColumn<QString>("name");
+ QTest::addColumn<quint32>("classOfDevice");
+ QTest::addColumn<QBluetoothUuid>("serviceClassUuid");
+ QTest::addColumn<QLowEnergyServiceInfo::ServiceType>("serviceType");
+ QTest::addColumn<QBluetoothDeviceInfo::CoreConfiguration>("coreConfiguration");
+
+ // bits 12-8 Major
+ // bits 7-2 Minor
+ // bits 1-0 0
+
+ QTest::newRow("0x000000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
+ << quint32(0x000000)
+ << QBluetoothUuid(QBluetoothUuid::GenericAccess)
+ << QLowEnergyServiceInfo::ServiceType(QLowEnergyServiceInfo::PrimaryService)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ QTest::newRow("0x000100 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
+ << quint32(0x000100)
+ << QBluetoothUuid(QBluetoothUuid::GenericAttribute)
+ << QLowEnergyServiceInfo::ServiceType(QLowEnergyServiceInfo::PrimaryService)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ QTest::newRow("0x000104 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
+ << quint32(0x000104)
+ << QBluetoothUuid(QBluetoothUuid::HeartRate)
+ << QLowEnergyServiceInfo::ServiceType(QLowEnergyServiceInfo::PrimaryService)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ QTest::newRow("0x000118 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
+ << quint32(0x000118)
+ << QBluetoothUuid(QBluetoothUuid::CyclingSpeedAndCadence)
+ << QLowEnergyServiceInfo::ServiceType(QLowEnergyServiceInfo::PrimaryService)
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ QTest::newRow("0x000200 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
+ << quint32(0x000200)
+ << QBluetoothUuid(QBluetoothUuid::CyclingPower)
+ << QLowEnergyServiceInfo::ServiceType(QLowEnergyServiceInfo::PrimaryService)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ QTest::newRow("0x000204 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
+ << quint32(0x000204)
+ << QBluetoothUuid(QBluetoothUuid::ScanParameters)
+ << QLowEnergyServiceInfo::ServiceType(QLowEnergyServiceInfo::PrimaryService)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ QTest::newRow("0x000214 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
+ << quint32(0x000214)
+ << QBluetoothUuid(QBluetoothUuid::DeviceInformation)
+ << QLowEnergyServiceInfo::ServiceType(QLowEnergyServiceInfo::PrimaryService)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ QTest::newRow("0x000300 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
+ << quint32(0x000300)
+ << QBluetoothUuid(QBluetoothUuid::CurrentTimeService)
+ << QLowEnergyServiceInfo::ServiceType(QLowEnergyServiceInfo::PrimaryService)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ QTest::newRow("0x000320 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
+ << quint32(0x000320)
+ << QBluetoothUuid(QBluetoothUuid::LocationAndNavigation)
+ << QLowEnergyServiceInfo::ServiceType(QLowEnergyServiceInfo::PrimaryService)
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+}
+
+void tst_QLowEnergyServiceInfo::tst_assignment()
+{
+ QFETCH(QBluetoothAddress, address);
+ QFETCH(QString, name);
+ QFETCH(quint32, classOfDevice);
+ QFETCH(QBluetoothUuid, serviceClassUuid);
+ QFETCH(QLowEnergyServiceInfo::ServiceType, serviceType);
+ QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
+
+ QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
+ deviceInfo.setCoreConfiguration(coreConfiguration);
+ QCOMPARE(deviceInfo.coreConfiguration(), coreConfiguration);
+
+ QLowEnergyServiceInfo serviceInfo(serviceClassUuid);
+ serviceInfo.setDevice(deviceInfo);
+ QCOMPARE(serviceInfo.device(), deviceInfo);
+
+ QVERIFY(serviceInfo.isValid());
+
+ {
+ QLowEnergyServiceInfo copyInfo = serviceInfo;
+
+ QVERIFY(copyInfo.isValid());
+
+ QCOMPARE(copyInfo.device().address(), address);
+ QCOMPARE(copyInfo.uuid(), serviceClassUuid);
+ QCOMPARE(copyInfo.device().coreConfiguration(), coreConfiguration);
+ QCOMPARE(copyInfo.serviceType(), serviceType);
+ QCOMPARE(copyInfo.isConnected(), false);
+ QCOMPARE(copyInfo.characteristics().size(), 0);
+ QCOMPARE(copyInfo.errorString(), QString(""));
+ QCOMPARE(copyInfo.device(), deviceInfo);
+ }
+
+ {
+ QLowEnergyServiceInfo copyInfo;
+
+ QVERIFY(!copyInfo.isValid());
+
+ copyInfo = serviceInfo;
+
+ QVERIFY(copyInfo.isValid());
+
+ QCOMPARE(copyInfo.device().address(), address);
+ QCOMPARE(copyInfo.uuid(), serviceClassUuid);
+ QCOMPARE(copyInfo.device().coreConfiguration(), coreConfiguration);
+ QCOMPARE(copyInfo.serviceType(), serviceType);
+ }
+
+ {
+ QLowEnergyServiceInfo copyInfo1;
+ QLowEnergyServiceInfo copyInfo2;
+
+ QVERIFY(!copyInfo1.isValid());
+ QVERIFY(!copyInfo2.isValid());
+
+ copyInfo1 = copyInfo2 = serviceInfo;
+
+ QVERIFY(copyInfo1.isValid());
+ QVERIFY(copyInfo2.isValid());
+ //QVERIFY(QLowEnergyServiceInfo() != copyInfo1);
+
+ QCOMPARE(copyInfo1.device().address(), address);
+ QCOMPARE(copyInfo2.device().address(), address);
+ QCOMPARE(copyInfo1.uuid(), serviceClassUuid);
+ QCOMPARE(copyInfo2.uuid(), serviceClassUuid);
+ QCOMPARE(copyInfo1.serviceType(), serviceType);
+ QCOMPARE(copyInfo2.serviceType(), serviceType);
+ QCOMPARE(copyInfo1.device().coreConfiguration(), coreConfiguration);
+ QCOMPARE(copyInfo2.device().coreConfiguration(), coreConfiguration);
+ QCOMPARE(copyInfo1.isConnected(), false);
+ QCOMPARE(copyInfo2.isConnected(), false);
+ QCOMPARE(copyInfo1.characteristics().size(), 0);
+ QCOMPARE(copyInfo2.characteristics().size(), 0);
+ QCOMPARE(copyInfo1.errorString(), QString(""));
+ QCOMPARE(copyInfo2.errorString(), QString(""));
+ QCOMPARE(copyInfo1.device(), deviceInfo);
+ QCOMPARE(copyInfo2.device(), deviceInfo);
+ }
+}
+
+QTEST_MAIN(tst_QLowEnergyServiceInfo)
+
+#include "tst_qlowenergyserviceinfo.moc"