QBluetoothServiceDiscovery auto test fix
Change-Id: I4e20a50549f69367652bd6881a3c541aa283c128 Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
This commit is contained in:
parent
de33fa0c04
commit
f6b6fb24f6
|
|
@ -29,5 +29,3 @@ qtHaveModule(nfc) {
|
||||||
qnearfieldtagtype2 \
|
qnearfieldtagtype2 \
|
||||||
qndefnfcsmartposterrecord
|
qndefnfcsmartposterrecord
|
||||||
}
|
}
|
||||||
|
|
||||||
qbluetoothservicediscoveryagent.CONFIG += no_check_target # QTBUG-22017
|
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,4 @@ CONFIG += testcase
|
||||||
|
|
||||||
QT = core concurrent bluetooth testlib
|
QT = core concurrent bluetooth testlib
|
||||||
|
|
||||||
CONFIG += insignificant_test # QTBUG-22017
|
|
||||||
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
|
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
|
||||||
|
|
|
||||||
|
|
@ -79,16 +79,21 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QBluetoothDeviceInfo> devices;
|
QList<QBluetoothDeviceInfo> devices;
|
||||||
|
bool localDeviceAvailable;
|
||||||
};
|
};
|
||||||
|
|
||||||
tst_QBluetoothServiceDiscoveryAgent::tst_QBluetoothServiceDiscoveryAgent()
|
tst_QBluetoothServiceDiscoveryAgent::tst_QBluetoothServiceDiscoveryAgent()
|
||||||
{
|
{
|
||||||
// start Bluetooth if not started
|
// start Bluetooth if not started
|
||||||
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
|
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
|
||||||
|
localDeviceAvailable = device->isValid();
|
||||||
|
if (localDeviceAvailable) {
|
||||||
device->powerOn();
|
device->powerOn();
|
||||||
delete device;
|
|
||||||
// wait for the device to switch bluetooth mode.
|
// wait for the device to switch bluetooth mode.
|
||||||
QTest::qWait(1000);
|
QTest::qWait(1000);
|
||||||
|
}
|
||||||
|
delete device;
|
||||||
|
|
||||||
qRegisterMetaType<QBluetoothDeviceInfo>("QBluetoothDeviceInfo");
|
qRegisterMetaType<QBluetoothDeviceInfo>("QBluetoothDeviceInfo");
|
||||||
qRegisterMetaType<QBluetoothServiceInfo>("QBluetoothServiceInfo");
|
qRegisterMetaType<QBluetoothServiceInfo>("QBluetoothServiceInfo");
|
||||||
qRegisterMetaType<QList<QBluetoothUuid> >("QList<QBluetoothUuid>");
|
qRegisterMetaType<QList<QBluetoothUuid> >("QList<QBluetoothUuid>");
|
||||||
|
|
@ -114,7 +119,7 @@ void tst_QBluetoothServiceDiscoveryAgent::serviceError(const QBluetoothServiceDi
|
||||||
|
|
||||||
void tst_QBluetoothServiceDiscoveryAgent::initTestCase()
|
void tst_QBluetoothServiceDiscoveryAgent::initTestCase()
|
||||||
{
|
{
|
||||||
#if 1
|
if (localDeviceAvailable) {
|
||||||
QBluetoothDeviceDiscoveryAgent discoveryAgent;
|
QBluetoothDeviceDiscoveryAgent discoveryAgent;
|
||||||
|
|
||||||
QSignalSpy finishedSpy(&discoveryAgent, SIGNAL(finished()));
|
QSignalSpy finishedSpy(&discoveryAgent, SIGNAL(finished()));
|
||||||
|
|
@ -138,9 +143,7 @@ void tst_QBluetoothServiceDiscoveryAgent::initTestCase()
|
||||||
QVERIFY(errorSpy.isEmpty());
|
QVERIFY(errorSpy.isEmpty());
|
||||||
|
|
||||||
devices = discoveryAgent.discoveredDevices();
|
devices = discoveryAgent.discoveredDevices();
|
||||||
#else
|
}
|
||||||
devices.append(QBluetoothDeviceInfo(QBluetoothAddress(Q_UINT64_C(0x001e3a81ba69)), "Yuna", 0));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QBluetoothServiceDiscoveryAgent::serviceDiscoveryDebug(const QBluetoothServiceInfo &info)
|
void tst_QBluetoothServiceDiscoveryAgent::serviceDiscoveryDebug(const QBluetoothServiceInfo &info)
|
||||||
|
|
@ -260,7 +263,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
|
||||||
QFETCH(QList<QBluetoothUuid>, uuidFilter);
|
QFETCH(QList<QBluetoothUuid>, uuidFilter);
|
||||||
QFETCH(QBluetoothServiceDiscoveryAgent::Error, serviceDiscoveryError);
|
QFETCH(QBluetoothServiceDiscoveryAgent::Error, serviceDiscoveryError);
|
||||||
|
|
||||||
qDebug() << "Doing address" << deviceInfo.address().toString();
|
qDebug() << "Scanning address" << deviceInfo.address().toString();
|
||||||
QBluetoothServiceDiscoveryAgent discoveryAgent(deviceInfo.address());
|
QBluetoothServiceDiscoveryAgent discoveryAgent(deviceInfo.address());
|
||||||
|
|
||||||
QVERIFY(!discoveryAgent.isActive());
|
QVERIFY(!discoveryAgent.isActive());
|
||||||
|
|
@ -313,15 +316,16 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
|
||||||
// All returned QBluetoothServiceInfo should be valid.
|
// All returned QBluetoothServiceInfo should be valid.
|
||||||
while (!discoveredSpy.isEmpty()) {
|
while (!discoveredSpy.isEmpty()) {
|
||||||
const QVariant v = discoveredSpy.takeFirst().at(0);
|
const QVariant v = discoveredSpy.takeFirst().at(0);
|
||||||
|
|
||||||
// Work around limitation in QMetaType and moc.
|
// Work around limitation in QMetaType and moc.
|
||||||
// QBluetoothServiceInfo is registered with metatype as QBluetoothServiceInfo
|
// QBluetoothServiceInfo is registered with metatype as QBluetoothServiceInfo
|
||||||
// moc sees it as the unqualified QBluetoothServiceInfo.
|
// moc sees it as the unqualified QBluetoothServiceInfo.
|
||||||
if (qstrcmp(v.typeName(), "QBluetoothServiceInfo") == 0) {
|
if (v.userType() == qMetaTypeId<QBluetoothServiceInfo>())
|
||||||
|
{
|
||||||
const QBluetoothServiceInfo info =
|
const QBluetoothServiceInfo info =
|
||||||
*reinterpret_cast<const QBluetoothServiceInfo*>(v.constData());
|
*reinterpret_cast<const QBluetoothServiceInfo*>(v.constData());
|
||||||
|
|
||||||
QVERIFY(info.isValid());
|
QVERIFY(info.isValid());
|
||||||
|
QVERIFY(!info.isRegistered());
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
qDebug() << info.device().name() << info.device().address().toString();
|
qDebug() << info.device().name() << info.device().address().toString();
|
||||||
|
|
@ -332,7 +336,10 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
|
||||||
qDebug() << "\tRFCOMM server channel:" << info.serverChannel();
|
qDebug() << "\tRFCOMM server channel:" << info.serverChannel();
|
||||||
//dumpServiceInfoAttributes(info);
|
//dumpServiceInfoAttributes(info);
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
QFAIL("Unknown type returned by service discovery");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVERIFY(discoveryAgent.discoveredServices().count() != 0);
|
QVERIFY(discoveryAgent.discoveredServices().count() != 0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue