diff options
author | Juha Vuolle <juha.vuolle@insta.fi> | 2022-04-07 12:50:24 +0300 |
---|---|---|
committer | Juha Vuolle <juha.vuolle@insta.fi> | 2022-04-20 08:42:40 +0300 |
commit | 3b16da807f55cb4d8515326776b32b8cfa71b0b6 (patch) | |
tree | 6d29e9d57e7db208161dce13c5bc243acf59a9b0 /tests | |
parent | a0adebf5a6e694a41dec45aa15014a4ea8de4038 (diff) |
Enable tst_qbluetoothlocaldevice power on/off testing on Windows
Improved support for QBluetoothLocalDevice on Windows was added in 6.3.
The commit also slightly rearranges the tst_powerOff and tst_powerOn
logic as there seemed to be a dependency on whether or not the Bluetooth
is initially ON/OFF (or alternatively in which order the
tst_powerOn()/tst_powerOff() were executed).
Amends 43c01fbe3f2a74d83a10c3fec4d25fc9342f7544
Pick-to: 6.3
Change-Id: I47507824945145ed95eb911a3d046369e492a407
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp index 8d872c70..d59ec259 100644 --- a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp +++ b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp @@ -115,20 +115,21 @@ void tst_QBluetoothLocalDevice::tst_powerOn() #ifdef Q_OS_OSX QSKIP("Not possible on OS X"); #endif -#ifdef Q_OS_WIN - QSKIP("Not possible on Windows"); -#endif + if (numDevices == 0) + QSKIP("Skipping test due to missing Bluetooth device"); QBluetoothLocalDevice localDevice; + if (localDevice.hostMode() != QBluetoothLocalDevice::HostPoweredOff) { + // Ensure device is OFF so we can test switching it ON + localDevice.setHostMode(QBluetoothLocalDevice::HostPoweredOff); + QTRY_VERIFY(localDevice.hostMode() == QBluetoothLocalDevice::HostPoweredOff); + } QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode))); // there should be no changes yet QVERIFY(hostModeSpy.isValid()); QVERIFY(hostModeSpy.isEmpty()); - if (numDevices == 0) - QSKIP("Skipping test due to missing Bluetooth device"); - localDevice.powerOn(); // async, wait for it QTRY_VERIFY(!hostModeSpy.isEmpty()); @@ -143,21 +144,16 @@ void tst_QBluetoothLocalDevice::tst_powerOff() #ifdef Q_OS_OSX QSKIP("Not possible on OS X"); #endif -#ifdef Q_OS_WIN - QSKIP("Not possible on Windows"); -#endif - if (numDevices == 0) 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; + if (localDevice.hostMode() == QBluetoothLocalDevice::HostPoweredOff) { + // Ensure device is ON so we can test switching it OFF + localDevice.powerOn(); + QTRY_VERIFY(localDevice.hostMode() != QBluetoothLocalDevice::HostPoweredOff); + } + QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode))); // there should be no changes yet QVERIFY(hostModeSpy.isValid()); |