summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-10-28 17:45:37 +0100
committerAlex Blasche <alexander.blasche@digia.com>2014-11-03 13:17:21 +0100
commitcb3054e2373dec8e800c1b5208555936ef3ae63b (patch)
tree64e5a12725f1e2806be931343eb32ddd159f9e4d
parente3a6af2fdb25ca8087a92fa506c8a00b786c95cc (diff)
QBluetoothDeviceInfo - update auto test
Update auto test for LE on OS X and iOS - new ctor/assignment/copy-ctor - test that deviceUuid works properly. Change-Id: I0e19f2a9fd30f53642e793418d1c7a3dbc38417e Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp123
1 files changed, 98 insertions, 25 deletions
diff --git a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
index 74a27591..f43bdb23 100644
--- a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
+++ b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
@@ -33,6 +33,7 @@
#include <QtTest/QtTest>
+#include <QScopedPointer>
#include <QDebug>
#include <qbluetoothaddress.h>
@@ -95,6 +96,10 @@ void tst_QBluetoothDeviceInfo::tst_construction_data()
QTest::addColumn<QBluetoothDeviceInfo::MajorDeviceClass>("majorDeviceClass");
QTest::addColumn<quint8>("minorDeviceClass");
QTest::addColumn<QBluetoothDeviceInfo::CoreConfiguration>("coreConfiguration");
+ // On OS X and iOS there are no real addresses
+ // with Core Bluetooth, only 'uuids' (128-bit) generated by Apple instead.
+ QTest::addColumn<QBluetoothUuid>("deviceUuid");
+ const QBluetoothUuid leDeviceUuid(QString("6C903349-31E2-40EF-826B-1E62C0D884E2"));
// bits 12-8 Major
// bits 7-2 Minor
@@ -105,143 +110,167 @@ void tst_QBluetoothDeviceInfo::tst_construction_data()
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
- << QBluetoothDeviceInfo::BaseRateCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000100 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000100)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedComputer)
- << QBluetoothDeviceInfo::BaseRateCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000104 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000104)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
<< quint8(QBluetoothDeviceInfo::DesktopComputer)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000118 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000118)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
<< quint8(QBluetoothDeviceInfo::WearableComputer)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000200 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000200)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedPhone)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000204 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000204)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
<< quint8(QBluetoothDeviceInfo::CellularPhone)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000214 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000214)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
<< quint8(QBluetoothDeviceInfo::CommonIsdnAccessPhone)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000300 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000300)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
<< quint8(QBluetoothDeviceInfo::NetworkFullService)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000320 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000320)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
<< quint8(QBluetoothDeviceInfo::NetworkLoadFactorOne)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x0003E0 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x0003E0)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
<< quint8(QBluetoothDeviceInfo::NetworkNoService)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000400 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000400)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::AudioVideoDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedAudioVideoDevice)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000448 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000448)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::AudioVideoDevice
<< quint8(QBluetoothDeviceInfo::GamingDevice)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000500 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000500)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PeripheralDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedPeripheral)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x0005D8 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x0005D8)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PeripheralDevice
<< quint8(QBluetoothDeviceInfo::KeyboardWithPointingDevicePeripheral | QBluetoothDeviceInfo::CardReaderPeripheral)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000600 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000600)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ImagingDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedImagingDevice)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000680 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000680)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ImagingDevice
<< quint8(QBluetoothDeviceInfo::ImagePrinter)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000700 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000700)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::WearableDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedWearableDevice)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000714 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000714)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::WearableDevice
<< quint8(QBluetoothDeviceInfo::WearableGlasses)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000800 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000800)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ToyDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedToy)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000814 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000814)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ToyDevice
<< quint8(QBluetoothDeviceInfo::ToyGame)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x001f00 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x001f00)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::UncategorizedDevice
<< quint8(0)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x002000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x002000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::PositioningService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x100000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x100000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::InformationService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0xFFE000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0xFFE000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::AllServices)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
}
void tst_QBluetoothDeviceInfo::tst_construction()
@@ -262,9 +291,9 @@ void tst_QBluetoothDeviceInfo::tst_construction()
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
+ QFETCH(QBluetoothUuid, deviceUuid);
QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
-
QVERIFY(deviceInfo.isValid());
QCOMPARE(deviceInfo.address(), address);
@@ -277,6 +306,9 @@ void tst_QBluetoothDeviceInfo::tst_construction()
deviceInfo.setCoreConfigurations(coreConfiguration);
QCOMPARE(deviceInfo.coreConfigurations(), coreConfiguration);
+ deviceInfo.setDeviceUuid(deviceUuid);
+ QCOMPARE(deviceInfo.deviceUuid(), deviceUuid);
+
QBluetoothDeviceInfo copyInfo(deviceInfo);
QVERIFY(copyInfo.isValid());
@@ -286,6 +318,40 @@ void tst_QBluetoothDeviceInfo::tst_construction()
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
+ QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
+ }
+
+ {
+ // Test construction from the device unique UUID, without an address.
+ QFETCH(QString, name);
+ QFETCH(quint32, classOfDevice);
+ QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
+ QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
+ QFETCH(quint8, minorDeviceClass);
+ QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
+ QFETCH(QBluetoothUuid, deviceUuid);
+
+ QBluetoothDeviceInfo deviceInfo(deviceUuid, name, classOfDevice);
+ QVERIFY(deviceInfo.isValid());
+
+ QCOMPARE(deviceInfo.name(), name);
+ QCOMPARE(deviceInfo.serviceClasses(), serviceClasses);
+ QCOMPARE(deviceInfo.majorDeviceClass(), majorDeviceClass);
+ QCOMPARE(deviceInfo.minorDeviceClass(), minorDeviceClass);
+ QCOMPARE(deviceInfo.coreConfigurations(), QBluetoothDeviceInfo::UnknownCoreConfiguration);
+
+ deviceInfo.setCoreConfigurations(coreConfiguration);
+ QCOMPARE(deviceInfo.coreConfigurations(), coreConfiguration);
+
+ QBluetoothDeviceInfo copyInfo(deviceInfo);
+ QVERIFY(copyInfo.isValid());
+
+ QCOMPARE(copyInfo.name(), name);
+ QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
+ QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
+ QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
+ QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
+ QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
}
@@ -303,8 +369,11 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
+ QFETCH(QBluetoothUuid, deviceUuid);
QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
+
+ deviceInfo.setDeviceUuid(deviceUuid);
deviceInfo.setCoreConfigurations(coreConfiguration);
QVERIFY(deviceInfo.isValid());
@@ -320,6 +389,7 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
+ QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
{
@@ -337,6 +407,7 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
+ QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
{
@@ -364,6 +435,8 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QCOMPARE(copyInfo2.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo1.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo2.coreConfigurations(), coreConfiguration);
+ QCOMPARE(copyInfo1.deviceUuid(), deviceUuid);
+ QCOMPARE(copyInfo2.deviceUuid(), deviceUuid);
}
{