本文整理汇总了C++中QBluetoothLocalDevice::hostMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QBluetoothLocalDevice::hostMode方法的具体用法?C++ QBluetoothLocalDevice::hostMode怎么用?C++ QBluetoothLocalDevice::hostMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBluetoothLocalDevice
的用法示例。
在下文中一共展示了QBluetoothLocalDevice::hostMode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tst_hostModes
void tst_QBluetoothLocalDevice::tst_hostModes()
{
QFETCH(QBluetoothLocalDevice::HostMode, hostModeExpected);
QBluetoothLocalDevice localDevice;
QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
// there should be no changes yet
QVERIFY(hostModeSpy.isEmpty());
QTest::qWait(1000);
localDevice.setHostMode(hostModeExpected);
// wait for the device to switch bluetooth mode.
QTest::qWait(1000);
if (hostModeExpected != localDevice.hostMode()) {
WAIT_FOR_CONDITION(hostModeSpy.count(),1);
QVERIFY(hostModeSpy.count() > 0);
}
// test the actual signal values.
QList<QVariant> arguments = hostModeSpy.takeFirst();
QBluetoothLocalDevice::HostMode hostMode = qvariant_cast<QBluetoothLocalDevice::HostMode>(arguments.at(0));
QCOMPARE(hostModeExpected, hostMode);
// test actual
QCOMPARE(hostModeExpected, localDevice.hostMode());
}
示例2: tst_powerOff
void tst_QBluetoothLocalDevice::tst_powerOff()
{
if (!QBluetoothLocalDevice::allDevices().count())
QSKIP("Skipping test due to missing Bluetooth device");
{
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
device->powerOn();
delete device;
// wait for the device to switch bluetooth mode.
QTest::qWait(1000);
}
QBluetoothLocalDevice localDevice;
QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
// there should be no changes yet
QVERIFY(hostModeSpy.isValid());
QVERIFY(hostModeSpy.isEmpty());
localDevice.setHostMode(QBluetoothLocalDevice::HostPoweredOff);
// async, wait for it
QTRY_VERIFY(hostModeSpy.count() > 0);
// we should not be powered off
QVERIFY(localDevice.hostMode() == QBluetoothLocalDevice::HostPoweredOff);
}
示例3: initTestCase
void tst_QBluetoothDeviceDiscoveryAgent::initTestCase()
{
qRegisterMetaType<QBluetoothDeviceInfo>("QBluetoothDeviceInfo");
qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::InquiryType>("QBluetoothDeviceDiscoveryAgent::InquiryType");
// turn on BT in case it is not on
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
if (device->hostMode() == QBluetoothLocalDevice::HostPoweredOff) {
QSignalSpy hostModeSpy(device, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
QVERIFY(hostModeSpy.isEmpty());
device->powerOn();
int connectTime = 5000; // ms
while (hostModeSpy.count() < 1 && connectTime > 0) {
QTest::qWait(500);
connectTime -= 500;
}
QVERIFY(hostModeSpy.count() > 0);
}
QBluetoothLocalDevice::HostMode hostMode= device->hostMode();
QVERIFY(hostMode == QBluetoothLocalDevice::HostConnectable
|| hostMode == QBluetoothLocalDevice::HostDiscoverable
|| hostMode == QBluetoothLocalDevice::HostDiscoverableLimitedInquiry);
delete device;
}
示例4: tst_powerOn
void tst_QBluetoothLocalDevice::tst_powerOn()
{
{
QBluetoothLocalDevice localDevice;
QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
// there should be no changes yet
QVERIFY(hostModeSpy.isEmpty());
localDevice.powerOn();
// async, wait for it
WAIT_FOR_CONDITION(hostModeSpy.count(),1);
QVERIFY(hostModeSpy.count() > 0);
QBluetoothLocalDevice::HostMode hostMode= localDevice.hostMode();
// we should not be powered off
QVERIFY(hostMode == QBluetoothLocalDevice::HostConnectable
|| hostMode == QBluetoothLocalDevice::HostDiscoverable);
}
}
示例5: tst_powerOn
void tst_QBluetoothLocalDevice::tst_powerOn()
{
QBluetoothLocalDevice localDevice;
QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
// there should be no changes yet
QVERIFY(hostModeSpy.isValid());
QVERIFY(hostModeSpy.isEmpty());
if (!QBluetoothLocalDevice::allDevices().count())
QSKIP("Skipping test due to missing Bluetooth device");
localDevice.powerOn();
// async, wait for it
QTRY_VERIFY(hostModeSpy.count() > 0);
QBluetoothLocalDevice::HostMode hostMode= localDevice.hostMode();
// we should not be powered off
QVERIFY(hostMode == QBluetoothLocalDevice::HostConnectable
|| hostMode == QBluetoothLocalDevice::HostDiscoverable);
}
示例6: tst_powerOff
void tst_QBluetoothLocalDevice::tst_powerOff()
{
{
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
device->powerOn();
delete device;
// wait for the device to switch bluetooth mode.
QTest::qWait(1000);
}
QBluetoothLocalDevice localDevice;
QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
// there should be no changes yet
QVERIFY(hostModeSpy.isEmpty());
localDevice.setHostMode(QBluetoothLocalDevice::HostPoweredOff);
// async, wait for it
WAIT_FOR_CONDITION(hostModeSpy.count(),1);
QVERIFY(hostModeSpy.count() > 0);
// we should not be powered off
QVERIFY(localDevice.hostMode() == QBluetoothLocalDevice::HostPoweredOff);
}