-
Alex Blasche authored
This global operator was added to QBluetoothDeviceInfo and QLowEnergyService flags. Change-Id: Ic841cf8c08a2289a9c112dc6283c8891dcc8750e Reviewed-by:
Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by:
Alex Blasche <alexander.blasche@theqtcompany.com>
e86249d3
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtTest/QtTest>
#include <QScopedPointer>
#include <QDebug>
#include <qbluetoothaddress.h>
#include <qbluetoothdeviceinfo.h>
#include <qbluetoothlocaldevice.h>
#include <qbluetoothuuid.h>
QT_USE_NAMESPACE
Q_DECLARE_METATYPE(QBluetoothDeviceInfo::ServiceClasses)
Q_DECLARE_METATYPE(QBluetoothDeviceInfo::MajorDeviceClass)
Q_DECLARE_METATYPE(QBluetoothDeviceInfo::CoreConfiguration)
class tst_QBluetoothDeviceInfo : public QObject
{
Q_OBJECT
public:
tst_QBluetoothDeviceInfo();
~tst_QBluetoothDeviceInfo();
private slots:
void initTestCase();
void tst_construction_data();
void tst_construction();
void tst_assignment_data();
void tst_assignment();
void tst_serviceUuids();
void tst_cached();
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
void tst_flags();
};
tst_QBluetoothDeviceInfo::tst_QBluetoothDeviceInfo()
{
}
tst_QBluetoothDeviceInfo::~tst_QBluetoothDeviceInfo()
{
}
void tst_QBluetoothDeviceInfo::initTestCase()
{
qRegisterMetaType<QBluetoothDeviceInfo::ServiceClasses>();
qRegisterMetaType<QBluetoothDeviceInfo::MajorDeviceClass>();
// start Bluetooth if not started
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
device->powerOn();
delete device;
}
void tst_QBluetoothDeviceInfo::tst_construction_data()
{
QTest::addColumn<QBluetoothAddress>("address");
QTest::addColumn<QString>("name");
QTest::addColumn<quint32>("classOfDevice");
QTest::addColumn<QBluetoothDeviceInfo::ServiceClasses>("serviceClasses");
QTest::addColumn<QBluetoothDeviceInfo::MajorDeviceClass>("majorDeviceClass");
QTest::addColumn<quint8>("minorDeviceClass");
QTest::addColumn<QBluetoothDeviceInfo::CoreConfiguration>("coreConfiguration");
// On OS X and iOS there are no real addresses
// with Core Bluetooth, only 'uuids' (128-bit) generated by Apple instead.
QTest::addColumn<QBluetoothUuid>("deviceUuid");
const QBluetoothUuid leDeviceUuid(QString("6C903349-31E2-40EF-826B-1E62C0D884E2"));
// bits 12-8 Major
// bits 7-2 Minor
// bits 1-0 0
QTest::newRow("0x000000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
<< QBluetoothDeviceInfo::BaseRateCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000100 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000100)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedComputer)
<< QBluetoothDeviceInfo::BaseRateCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000104 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000104)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
<< quint8(QBluetoothDeviceInfo::DesktopComputer)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000118 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000118)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
<< quint8(QBluetoothDeviceInfo::WearableComputer)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000200 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000200)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
<< quint8(QBluetoothDeviceInfo::UncategorizedPhone)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000204 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000204)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
<< quint8(QBluetoothDeviceInfo::CellularPhone)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000214 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000214)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
<< quint8(QBluetoothDeviceInfo::CommonIsdnAccessPhone)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000300 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000300)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
<< quint8(QBluetoothDeviceInfo::NetworkFullService)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000320 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000320)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
<< quint8(QBluetoothDeviceInfo::NetworkLoadFactorOne)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x0003E0 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x0003E0)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
<< quint8(QBluetoothDeviceInfo::NetworkNoService)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000400 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000400)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::AudioVideoDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedAudioVideoDevice)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000448 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000448)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::AudioVideoDevice
<< quint8(QBluetoothDeviceInfo::GamingDevice)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000500 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000500)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PeripheralDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedPeripheral)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x0005D8 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x0005D8)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PeripheralDevice
<< quint8(QBluetoothDeviceInfo::KeyboardWithPointingDevicePeripheral | QBluetoothDeviceInfo::CardReaderPeripheral)
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000600 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000600)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ImagingDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedImagingDevice)
211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
<< QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000680 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000680)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ImagingDevice
<< quint8(QBluetoothDeviceInfo::ImagePrinter)
<< QBluetoothDeviceInfo::LowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000700 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000700)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::WearableDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedWearableDevice)
<< QBluetoothDeviceInfo::LowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000714 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000714)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::WearableDevice
<< quint8(QBluetoothDeviceInfo::WearableGlasses)
<< QBluetoothDeviceInfo::LowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000800 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000800)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ToyDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedToy)
<< QBluetoothDeviceInfo::LowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x000814 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000814)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ToyDevice
<< quint8(QBluetoothDeviceInfo::ToyGame)
<< QBluetoothDeviceInfo::LowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x001f00 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x001f00)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::UncategorizedDevice
<< quint8(0)
<< QBluetoothDeviceInfo::LowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x002000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x002000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::PositioningService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
<< QBluetoothDeviceInfo::LowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0x100000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x100000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::InformationService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
<< QBluetoothDeviceInfo::LowEnergyCoreConfiguration
<< leDeviceUuid;
QTest::newRow("0xFFE000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0xFFE000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::AllServices)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
<< QBluetoothDeviceInfo::LowEnergyCoreConfiguration
<< leDeviceUuid;
}
void tst_QBluetoothDeviceInfo::tst_construction()
{
{
281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
QBluetoothDeviceInfo deviceInfo;
QVERIFY(!deviceInfo.isValid());
QVERIFY(deviceInfo.coreConfigurations()
== QBluetoothDeviceInfo::UnknownCoreConfiguration);
}
{
QFETCH(QBluetoothAddress, address);
QFETCH(QString, name);
QFETCH(quint32, classOfDevice);
QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
QFETCH(QBluetoothUuid, deviceUuid);
QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
QVERIFY(deviceInfo.isValid());
QCOMPARE(deviceInfo.address(), address);
QCOMPARE(deviceInfo.name(), name);
QCOMPARE(deviceInfo.serviceClasses(), serviceClasses);
QCOMPARE(deviceInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(deviceInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(deviceInfo.coreConfigurations(), QBluetoothDeviceInfo::UnknownCoreConfiguration);
deviceInfo.setCoreConfigurations(coreConfiguration);
QCOMPARE(deviceInfo.coreConfigurations(), coreConfiguration);
deviceInfo.setDeviceUuid(deviceUuid);
QCOMPARE(deviceInfo.deviceUuid(), deviceUuid);
QBluetoothDeviceInfo copyInfo(deviceInfo);
QVERIFY(copyInfo.isValid());
QCOMPARE(copyInfo.address(), address);
QCOMPARE(copyInfo.name(), name);
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
{
// Test construction from the device unique UUID, without an address.
QFETCH(QString, name);
QFETCH(quint32, classOfDevice);
QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
QFETCH(QBluetoothUuid, deviceUuid);
QBluetoothDeviceInfo deviceInfo(deviceUuid, name, classOfDevice);
QVERIFY(deviceInfo.isValid());
QCOMPARE(deviceInfo.name(), name);
QCOMPARE(deviceInfo.serviceClasses(), serviceClasses);
QCOMPARE(deviceInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(deviceInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(deviceInfo.coreConfigurations(), QBluetoothDeviceInfo::UnknownCoreConfiguration);
deviceInfo.setCoreConfigurations(coreConfiguration);
QCOMPARE(deviceInfo.coreConfigurations(), coreConfiguration);
QBluetoothDeviceInfo copyInfo(deviceInfo);
QVERIFY(copyInfo.isValid());
351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
QCOMPARE(copyInfo.name(), name);
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
}
void tst_QBluetoothDeviceInfo::tst_assignment_data()
{
tst_construction_data();
}
void tst_QBluetoothDeviceInfo::tst_assignment()
{
QFETCH(QBluetoothAddress, address);
QFETCH(QString, name);
QFETCH(quint32, classOfDevice);
QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
QFETCH(QBluetoothUuid, deviceUuid);
QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
deviceInfo.setDeviceUuid(deviceUuid);
deviceInfo.setCoreConfigurations(coreConfiguration);
QVERIFY(deviceInfo.isValid());
{
QBluetoothDeviceInfo copyInfo = deviceInfo;
QVERIFY(copyInfo.isValid());
QCOMPARE(copyInfo.address(), address);
QCOMPARE(copyInfo.name(), name);
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
{
QBluetoothDeviceInfo copyInfo;
QVERIFY(!copyInfo.isValid());
copyInfo = deviceInfo;
QVERIFY(copyInfo.isValid());
QCOMPARE(copyInfo.address(), address);
QCOMPARE(copyInfo.name(), name);
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
{
QBluetoothDeviceInfo copyInfo1;
QBluetoothDeviceInfo copyInfo2;
QVERIFY(!copyInfo1.isValid());
QVERIFY(!copyInfo2.isValid());
421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
copyInfo1 = copyInfo2 = deviceInfo;
QVERIFY(copyInfo1.isValid());
QVERIFY(copyInfo2.isValid());
QVERIFY(QBluetoothDeviceInfo() != copyInfo1);
QCOMPARE(copyInfo1.address(), address);
QCOMPARE(copyInfo2.address(), address);
QCOMPARE(copyInfo1.name(), name);
QCOMPARE(copyInfo2.name(), name);
QCOMPARE(copyInfo1.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo2.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo1.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo2.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo1.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo2.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo1.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo2.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo1.deviceUuid(), deviceUuid);
QCOMPARE(copyInfo2.deviceUuid(), deviceUuid);
}
{
QBluetoothDeviceInfo testDeviceInfo;
QVERIFY(testDeviceInfo == QBluetoothDeviceInfo());
}
}
void tst_QBluetoothDeviceInfo::tst_serviceUuids()
{
QBluetoothDeviceInfo deviceInfo;
QBluetoothDeviceInfo copyInfo = deviceInfo;
QList<QBluetoothUuid> servicesList;
servicesList.append(QBluetoothUuid::L2cap);
servicesList.append(QBluetoothUuid::Rfcomm);
QVERIFY(servicesList.count() > 0);
deviceInfo.setServiceUuids(servicesList, QBluetoothDeviceInfo::DataComplete);
QVERIFY(deviceInfo.serviceUuids().count() > 0);
QVERIFY(deviceInfo != copyInfo);
QVERIFY(deviceInfo.serviceUuidsCompleteness() == QBluetoothDeviceInfo::DataComplete);
}
void tst_QBluetoothDeviceInfo::tst_cached()
{
QBluetoothDeviceInfo deviceInfo(QBluetoothAddress("AABBCCDDEEFF"),
QString("My Bluetooth Device"), quint32(0x002000));
QBluetoothDeviceInfo copyInfo = deviceInfo;
QVERIFY(!deviceInfo.isCached());
deviceInfo.setCached(true);
QVERIFY(deviceInfo.isCached());
QVERIFY(deviceInfo != copyInfo);
deviceInfo.setCached(false);
QVERIFY(!(deviceInfo.isCached()));
}
void tst_QBluetoothDeviceInfo::tst_flags()
{
QBluetoothDeviceInfo::CoreConfigurations flags1(QBluetoothDeviceInfo::LowEnergyCoreConfiguration);
QBluetoothDeviceInfo::CoreConfigurations flags2(QBluetoothDeviceInfo::BaseRateCoreConfiguration);
QBluetoothDeviceInfo::CoreConfigurations result;
// test QFlags &operator|=(QFlags f)
result = flags1 | flags2;
QVERIFY(result.testFlag(QBluetoothDeviceInfo::LowEnergyCoreConfiguration));
491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
QVERIFY(result.testFlag(QBluetoothDeviceInfo::BaseRateCoreConfiguration));
// test QFlags &operator|=(Enum f)
result = flags1 | QBluetoothDeviceInfo::BaseRateCoreConfiguration;
QVERIFY(result.testFlag(QBluetoothDeviceInfo::LowEnergyCoreConfiguration));
QVERIFY(result.testFlag(QBluetoothDeviceInfo::BaseRateCoreConfiguration));
// test Q_DECLARE_OPERATORS_FOR_FLAGS(QBluetoothDeviceInfo::CoreConfigurations)
result = QBluetoothDeviceInfo::BaseRateCoreConfiguration | flags1;
QVERIFY(result.testFlag(QBluetoothDeviceInfo::LowEnergyCoreConfiguration));
QVERIFY(result.testFlag(QBluetoothDeviceInfo::BaseRateCoreConfiguration));
QBluetoothDeviceInfo::ServiceClasses serviceFlag1(QBluetoothDeviceInfo::AudioService);
QBluetoothDeviceInfo::ServiceClasses serviceFlag2(QBluetoothDeviceInfo::CapturingService);
QBluetoothDeviceInfo::ServiceClasses serviceResult;
// test QFlags &operator|=(QFlags f)
serviceResult = serviceFlag1 | serviceFlag2;
QVERIFY(serviceResult.testFlag(QBluetoothDeviceInfo::AudioService));
QVERIFY(serviceResult.testFlag(QBluetoothDeviceInfo::CapturingService));
// test QFlags &operator|=(Enum f)
serviceResult = serviceFlag1 | QBluetoothDeviceInfo::CapturingService;
QVERIFY(serviceResult.testFlag(QBluetoothDeviceInfo::AudioService));
QVERIFY(serviceResult.testFlag(QBluetoothDeviceInfo::CapturingService));
// test Q_DECLARE_OPERATORS_FOR_FLAGS(QBluetoothDeviceInfo::ServiceClasses)
serviceResult = QBluetoothDeviceInfo::CapturingService | serviceFlag1;
QVERIFY(serviceResult.testFlag(QBluetoothDeviceInfo::AudioService));
QVERIFY(serviceResult.testFlag(QBluetoothDeviceInfo::CapturingService));
}
QTEST_MAIN(tst_QBluetoothDeviceInfo)
#include "tst_qbluetoothdeviceinfo.moc"