void tst_QBluetoothLocalDevice::tst_pairDevice() { QFETCH(QBluetoothAddress, deviceAddress); QFETCH(QBluetoothLocalDevice::Pairing, pairingExpected); QBluetoothLocalDevice localDevice; //powerOn if not already localDevice.powerOn(); QSignalSpy pairingSpy(&localDevice, SIGNAL(pairingFinished(const QBluetoothAddress &,QBluetoothLocalDevice::Pairing)) ); // there should be no signals yet QVERIFY(pairingSpy.isEmpty()); localDevice.requestPairing(deviceAddress, pairingExpected); // async, wait for it WAIT_FOR_CONDITION(pairingSpy.count(),1); QVERIFY(pairingSpy.count() > 0); // test the actual signal values. QList<QVariant> arguments = pairingSpy.takeFirst(); QBluetoothAddress address = qvariant_cast<QBluetoothAddress>(arguments.at(0)); QBluetoothLocalDevice::Pairing pairingResult = qvariant_cast<QBluetoothLocalDevice::Pairing>(arguments.at(1)); QCOMPARE(deviceAddress, address); QCOMPARE(pairingExpected, pairingResult); QCOMPARE(pairingExpected, localDevice.pairingStatus(deviceAddress)); }
void tst_QBluetoothLocalDevice::tst_pairDevice() { QFETCH(QBluetoothAddress, deviceAddress); QFETCH(QBluetoothLocalDevice::Pairing, pairingExpected); if (!QBluetoothLocalDevice::allDevices().count()) QSKIP("Skipping test due to missing Bluetooth device"); qDebug() << "tst_pairDevice(): address=" << deviceAddress.toString() << "pairingModeExpected=" << static_cast<int>(pairingExpected); QBluetoothLocalDevice localDevice; //powerOn if not already localDevice.powerOn(); QSignalSpy pairingSpy(&localDevice, SIGNAL(pairingFinished(const QBluetoothAddress &,QBluetoothLocalDevice::Pairing)) ); // there should be no signals yet QVERIFY(pairingSpy.isValid()); QVERIFY(pairingSpy.isEmpty()); QVERIFY(localDevice.isValid()); localDevice.requestPairing(deviceAddress, pairingExpected); // async, wait for it QTRY_VERIFY(pairingSpy.count() > 0); // test the actual signal values. QList<QVariant> arguments = pairingSpy.takeFirst(); QBluetoothAddress address = qvariant_cast<QBluetoothAddress>(arguments.at(0)); QBluetoothLocalDevice::Pairing pairingResult = qvariant_cast<QBluetoothLocalDevice::Pairing>(arguments.at(1)); QCOMPARE(deviceAddress, address); QCOMPARE(pairingExpected, pairingResult); QCOMPARE(pairingExpected, localDevice.pairingStatus(deviceAddress)); }