void tst_QBluetoothHostInfo::tst_construction() { QFETCH(QString, btAddress); QFETCH(QString, name); QFETCH(bool, validBtAddress); QBluetoothAddress empty; QVERIFY(empty.isNull()); QBluetoothHostInfo setter; QBluetoothAddress addr(btAddress); setter.setName(name); setter.setAddress(addr); QCOMPARE(setter.name(), name); QCOMPARE(setter.address().toString(), btAddress); QCOMPARE(setter.address().isNull(), !validBtAddress); setter.setAddress(empty); QCOMPARE(setter.name(), name); QCOMPARE(setter.address().toString(), QString("00:00:00:00:00:00")); QCOMPARE(setter.address().isNull(), true); setter.setName(QString()); QCOMPARE(setter.name(), QString()); QCOMPARE(setter.address().toString(), QString("00:00:00:00:00:00")); QCOMPARE(setter.address().isNull(), true); setter.setAddress(addr); QCOMPARE(setter.name(), QString()); QCOMPARE(setter.address().toString(), btAddress); QCOMPARE(setter.address().isNull(), !validBtAddress); }
QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices() { QList<QBluetoothHostInfo> localDevices; OrgBluezManagerInterface manager(QLatin1String("org.bluez"), QLatin1String("/"), QDBusConnection::systemBus()); QDBusPendingReply<QList<QDBusObjectPath> > reply = manager.ListAdapters(); reply.waitForFinished(); if (reply.isError()) return localDevices; foreach (const QDBusObjectPath &path, reply.value()) { QBluetoothHostInfo hostinfo; OrgBluezAdapterInterface adapter(QLatin1String("org.bluez"), path.path(), QDBusConnection::systemBus()); QDBusPendingReply<QVariantMap> reply = adapter.GetProperties(); reply.waitForFinished(); if (reply.isError()) continue; hostinfo.setAddress(QBluetoothAddress(reply.value().value(QLatin1String("Address")).toString())); hostinfo.setName(reply.value().value(QLatin1String("Name")).toString()); localDevices.append(hostinfo); } return localDevices; }
QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices() { QList<QBluetoothHostInfo> localDevices; QBluetoothHostInfo hostInfo; hostInfo.setName(QBluetoothLocalDevicePrivate::name()); hostInfo.setAddress(QBluetoothLocalDevicePrivate::address()); localDevices.append(hostInfo); return localDevices; }
void tst_QBluetoothHostInfo::tst_name() { QFETCH(QString, name); QBluetoothHostInfo info; QString result = info.name(); QVERIFY(result.isNull()); QVERIFY(result.isEmpty()); info.setName(name); QCOMPARE(info.name(), name); }
void tst_QBluetoothHostInfo::tst_copy() { QBluetoothHostInfo original; original.setAddress(QBluetoothAddress("11:22:33:44:55:66")); original.setName(QStringLiteral("FunkyName")); QBluetoothHostInfo assignConstructor(original); QCOMPARE(assignConstructor.name(), original.name()); QCOMPARE(assignConstructor.address(), original.address()); QBluetoothHostInfo assignOperator; assignOperator = original; QCOMPARE(assignOperator.name(), original.name()); QCOMPARE(assignOperator.address(), original.address()); }