diff options
Diffstat (limited to 'tests/auto')
4 files changed, 66 insertions, 4 deletions
diff --git a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp index fd923f0e..d20458fd 100644 --- a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp +++ b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp @@ -86,6 +86,8 @@ private slots: void tst_properties(); + void tst_invalidBtAddress(); + void tst_startStopDeviceDiscoveries(); void tst_deviceDiscovery_data(); @@ -143,6 +145,24 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_properties() QCOMPARE(discoveryAgent.inquiryType(), QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry); } +void tst_QBluetoothDeviceDiscoveryAgent::tst_invalidBtAddress() +{ + QBluetoothDeviceDiscoveryAgent *discoveryAgent = new QBluetoothDeviceDiscoveryAgent(QBluetoothAddress("11:11:11:11:11:11")); + + QCOMPARE(discoveryAgent->error(), QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError); + discoveryAgent->start(); + QCOMPARE(discoveryAgent->isActive(), false); + delete discoveryAgent; + + discoveryAgent = new QBluetoothDeviceDiscoveryAgent(QBluetoothAddress()); + QCOMPARE(discoveryAgent->error(), QBluetoothDeviceDiscoveryAgent::NoError); + if (QBluetoothLocalDevice::allDevices().count() > 0) { + discoveryAgent->start(); + QCOMPARE(discoveryAgent->isActive(), true); + } + delete discoveryAgent; +} + void tst_QBluetoothDeviceDiscoveryAgent::deviceDiscoveryDebug(const QBluetoothDeviceInfo &info) { qDebug() << "Discovered device:" << info.address().toString() << info.name(); diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp index dc065096..cd5b1166 100644 --- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp +++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp @@ -81,6 +81,7 @@ public slots: private slots: void initTestCase(); + void tst_invalidBtAddress(); void tst_serviceDiscovery_data(); void tst_serviceDiscovery(); void tst_serviceDiscoveryAdapters(); @@ -155,6 +156,24 @@ void tst_QBluetoothServiceDiscoveryAgent::initTestCase() } } +void tst_QBluetoothServiceDiscoveryAgent::tst_invalidBtAddress() +{ + QBluetoothServiceDiscoveryAgent *discoveryAgent = new QBluetoothServiceDiscoveryAgent(QBluetoothAddress("11:11:11:11:11:11")); + + QCOMPARE(discoveryAgent->error(), QBluetoothServiceDiscoveryAgent::InvalidBluetoothAdapterError); + discoveryAgent->start(); + QCOMPARE(discoveryAgent->isActive(), false); + delete discoveryAgent; + + discoveryAgent = new QBluetoothServiceDiscoveryAgent(QBluetoothAddress()); + QCOMPARE(discoveryAgent->error(), QBluetoothServiceDiscoveryAgent::NoError); + if (QBluetoothLocalDevice::allDevices().count() > 0) { + discoveryAgent->start(); + QCOMPARE(discoveryAgent->isActive(), true); + } + delete discoveryAgent; +} + void tst_QBluetoothServiceDiscoveryAgent::serviceDiscoveryDebug(const QBluetoothServiceInfo &info) { qDebug() << "Discovered service on" diff --git a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp index 62550622..2195bc0e 100644 --- a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp +++ b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp @@ -71,6 +71,8 @@ private slots: void tst_assignment_data(); void tst_assignment(); + + void tst_serviceClassUuids(); }; tst_QBluetoothServiceInfo::tst_QBluetoothServiceInfo() @@ -329,6 +331,27 @@ void tst_QBluetoothServiceInfo::tst_assignment() } } +void tst_QBluetoothServiceInfo::tst_serviceClassUuids() +{ + QBluetoothServiceInfo info; + QCOMPARE(info.serviceClassUuids().count(), 0); + + QBluetoothServiceInfo::Sequence classIds; + classIds << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); + QCOMPARE(classIds.count(), 1); + + QBluetoothUuid uuid(QString("e8e10f95-1a70-4b27-9ccf-02010264e9c8")); + classIds.prepend(QVariant::fromValue(uuid)); + QCOMPARE(classIds.count(), 2); + QCOMPARE(classIds.at(0).value<QBluetoothUuid>(), uuid); + + info.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classIds); + QList<QBluetoothUuid> svclids = info.serviceClassUuids(); + QCOMPARE(svclids.count(), 2); + QCOMPARE(svclids.at(0), uuid); + QCOMPARE(svclids.at(1), QBluetoothUuid(QBluetoothUuid::SerialPort)); +} + QTEST_MAIN(tst_QBluetoothServiceInfo) #include "tst_qbluetoothserviceinfo.moc" diff --git a/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp b/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp index 87e6a41d..6fac6571 100644 --- a/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp +++ b/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp @@ -163,14 +163,14 @@ void tst_QNearFieldTagType2::staticMemoryModel() QCOMPARE(readBlock, QByteArray(4, 0x55) + initialBlock.mid(4)); // Write 0xaa - id = target->writeBlock(i, QByteArray(4, 0xaa)); + id = target->writeBlock(i, QByteArray(4, char(0xaa))); QVERIFY(target->waitForRequestCompleted(id)); QVERIFY(target->requestResponse(id).toBool()); id = target->readBlock(i); QVERIFY(target->waitForRequestCompleted(id)); readBlock = target->requestResponse(id).toByteArray(); - QCOMPARE(readBlock, QByteArray(4, 0xaa) + initialBlock.mid(4)); + QCOMPARE(readBlock, QByteArray(4, char(0xaa)) + initialBlock.mid(4)); } } } @@ -240,14 +240,14 @@ void tst_QNearFieldTagType2::dynamicMemoryModel() QCOMPARE(readBlock, QByteArray(4, 0x55) + initialBlock.mid(4)); // Write 0xaa - id = target->writeBlock(i, QByteArray(4, 0xaa)); + id = target->writeBlock(i, QByteArray(4, char(0xaa))); QVERIFY(target->waitForRequestCompleted(id)); QVERIFY(target->requestResponse(id).toBool()); id = target->readBlock(i); QVERIFY(target->waitForRequestCompleted(id)); readBlock = target->requestResponse(id).toByteArray(); - QCOMPARE(readBlock, QByteArray(4, 0xaa) + initialBlock.mid(4)); + QCOMPARE(readBlock, QByteArray(4, char(0xaa)) + initialBlock.mid(4)); } // change to sector 0 |