From 23a3863de809a4051ae6db4942145cb0cb624d6c Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Fri, 13 Dec 2013 18:04:45 +0100 Subject: Check the local adapter's BluetoothAdress before doing the discovery Task-number: QTBUG-35571 Change-Id: I8f2eea7a8437787d61a238c760e948f45738618a Reviewed-by: Aaron McCarthy Reviewed-by: Alex Blasche Reviewed-by: Fabian Bumberger --- .../tst_qbluetoothdevicediscoveryagent.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp') 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(); -- cgit v1.2.3