diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-06-04 17:19:09 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-11 12:03:27 +0200 |
commit | bc7ccdb362b79c441010175bbae1421089d291e2 (patch) | |
tree | cd97a43bedf46639173327a7e84b57a33c220095 /tests | |
parent | 1a9a359b9bdee646cd964fd5af13b239da79f9c9 (diff) |
Convert characteristic and descriptor handles to int
ATT protocol defines them as int and just because Bluez5 happens to parse
them from command line doesn't mean all other platforms have to
deal with strings too. This avoids a lot of string to int conversions
and vice versa.
Handles should probably fit into short as well but this needs further
verification. For we play safe.
Change-Id: If75ca539b4b2956b9a65ee2a9ef738b0fe3aa2ee
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qlowenergycharacteristicinfo/tst_qlowenergycharacteristicinfo.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qlowenergydescriptorinfo/tst_qlowenergydescriptorinfo.cpp | 35 |
2 files changed, 26 insertions, 17 deletions
diff --git a/tests/auto/qlowenergycharacteristicinfo/tst_qlowenergycharacteristicinfo.cpp b/tests/auto/qlowenergycharacteristicinfo/tst_qlowenergycharacteristicinfo.cpp index 2736dade..580ad0c1 100644 --- a/tests/auto/qlowenergycharacteristicinfo/tst_qlowenergycharacteristicinfo.cpp +++ b/tests/auto/qlowenergycharacteristicinfo/tst_qlowenergycharacteristicinfo.cpp @@ -99,7 +99,7 @@ void tst_QLowEnergyCharacteristicInfo::tst_construction() QCOMPARE(characteristicInfo.uuid().toString(), QBluetoothUuid().toString()); QCOMPARE(characteristicInfo.value(), QByteArray()); QCOMPARE(characteristicInfo.properties(), QLowEnergyCharacteristicInfo::Unknown); - QCOMPARE(characteristicInfo.handle(), QString("0x0000")); + QCOMPARE(characteristicInfo.handle(), 0u); QCOMPARE(characteristicInfo.name(), QString("")); QCOMPARE(characteristicInfo.isNotificationCharacteristic(), false); QCOMPARE(characteristicInfo.descriptors().count(), 0); @@ -113,7 +113,7 @@ void tst_QLowEnergyCharacteristicInfo::tst_construction() QCOMPARE(characteristicInfo.uuid().toString(), characteristicUuid.toString()); QCOMPARE(characteristicInfo.value(), QByteArray()); QCOMPARE(characteristicInfo.properties(), QLowEnergyCharacteristicInfo::Unknown); - QCOMPARE(characteristicInfo.handle(), QString("0x0000")); + QCOMPARE(characteristicInfo.handle(), 0u); QCOMPARE(characteristicInfo.name(), QBluetoothUuid::characteristicToString(QBluetoothUuid::HIDControlPoint)); QCOMPARE(characteristicInfo.isNotificationCharacteristic(), false); @@ -135,10 +135,10 @@ void tst_QLowEnergyCharacteristicInfo::tst_construction() copyInfo = QLowEnergyCharacteristicInfo(alternateCharacteristicUuid); QCOMPARE(copyInfo.uuid().toString(), alternateCharacteristicUuid.toString()); - QCOMPARE(copyInfo.handle(), QString("0x0000")); + QCOMPARE(copyInfo.handle(), 0u); QCOMPARE(copyInfo.value(), QByteArray()); QCOMPARE(copyInfo.properties(), QLowEnergyCharacteristicInfo::Unknown); - QCOMPARE(copyInfo.handle(), QString("0x0000")); + QCOMPARE(copyInfo.handle(), 0u); QCOMPARE(copyInfo.name(), QBluetoothUuid::characteristicToString(QBluetoothUuid::TemperatureMeasurement)); QCOMPARE(copyInfo.isNotificationCharacteristic(), false); diff --git a/tests/auto/qlowenergydescriptorinfo/tst_qlowenergydescriptorinfo.cpp b/tests/auto/qlowenergydescriptorinfo/tst_qlowenergydescriptorinfo.cpp index e10d248e..6934417a 100644 --- a/tests/auto/qlowenergydescriptorinfo/tst_qlowenergydescriptorinfo.cpp +++ b/tests/auto/qlowenergydescriptorinfo/tst_qlowenergydescriptorinfo.cpp @@ -87,15 +87,15 @@ void tst_QLowEnergyDescriptorInfo::initTestCase() void tst_QLowEnergyDescriptorInfo::tst_construction() { - const QBluetoothUuid descriptorUuid(QString("0x2902").toUShort(0,0)); - const QBluetoothUuid alternateDescriptorUuid(QString("0x2906").toUShort(0,0)); + const QBluetoothUuid descriptorUuid(0x2902u); + const QBluetoothUuid alternateDescriptorUuid(0x2906u); { QLowEnergyDescriptorInfo descriptorInfo = QLowEnergyDescriptorInfo(QBluetoothUuid()); QCOMPARE(descriptorInfo.uuid(), QBluetoothUuid()); QCOMPARE(descriptorInfo.value(), QByteArray()); - QCOMPARE(descriptorInfo.handle(), QString("0x0000")); + QCOMPARE(descriptorInfo.handle(), 0u); QCOMPARE(descriptorInfo.name(), QBluetoothUuid::descriptorToString(descriptorInfo.type())); QCOMPARE(descriptorInfo.type(), @@ -124,7 +124,7 @@ void tst_QLowEnergyDescriptorInfo::tst_construction() QCOMPARE(copyInfo.uuid(), alternateDescriptorUuid); QCOMPARE(copyInfo.value(), QByteArray()); - QCOMPARE(copyInfo.handle(), QString("0x0000")); + QCOMPARE(copyInfo.handle(), 0u); QCOMPARE(copyInfo.name(), QBluetoothUuid::descriptorToString(copyInfo.type())); } @@ -134,15 +134,24 @@ 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)); + QTest::newRow("0x000000 COD") + << QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription); + QTest::newRow("0x001000 COD") + << QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration); + QTest::newRow("0x002000 COD") + << QBluetoothUuid(QBluetoothUuid::ServerCharacteristicConfiguration); + QTest::newRow("0x003000 COD") + << QBluetoothUuid(QBluetoothUuid::CharacteristicPresentationFormat); + QTest::newRow("0x004000 COD") + << QBluetoothUuid(QBluetoothUuid::CharacteristicAggregateFormat); + QTest::newRow("0x005000 COD") + << QBluetoothUuid(QBluetoothUuid::ValidRange); + QTest::newRow("0x006000 COD") + << QBluetoothUuid(QBluetoothUuid::ExternalReportReference); + QTest::newRow("0x007000 COD") + << QBluetoothUuid(QBluetoothUuid::ReportReference); + QTest::newRow("0x008000 COD") + << QBluetoothUuid(QBluetoothUuid::CharacteristicExtendedProperties); } void tst_QLowEnergyDescriptorInfo::tst_assignment() |