From a7f6e8cf3ed1fddce5fd8a8d0e3d9125e5d8431c Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 23 Jul 2013 16:59:15 +0200 Subject: Don't hardcode the test device's Bt address in the unit test. Ensure that all signals emitted during a pairing request are queued via the event loop. The exact reason for doing this is unknown however such a change was done on purpose in QtMobility. We keep the behavior to be on the safe side. Change-Id: I666c5b2c25a0c80df634f7b6643bd08126812b65 Reviewed-by: Michael Zanetti Reviewed-by: Alex --- .../tst_qbluetoothlocaldevice.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp index bd2272f1..bc4e269e 100644 --- a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp +++ b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp @@ -53,10 +53,8 @@ QT_USE_NAMESPACE_BLUETOOTH * Running the manual tests requires another Bluetooth device in the vincinity. * The remote device's address must be passed via the BT_TEST_DEVICE env variable. * Every pairing request must be accepted within a 10s interval of appearing. + * If BT_TEST_DEVICE is not set manual tests will be skipped. **/ -#define BT_TEST_DEVICE "98:D6:F7:D9:A5:3D" - - class tst_QBluetoothLocalDevice : public QObject { @@ -67,6 +65,7 @@ public: ~tst_QBluetoothLocalDevice(); private slots: + void initTestCase(); void tst_powerOn(); void tst_powerOff(); void tst_hostModes(); @@ -83,16 +82,16 @@ private slots: private: QBluetoothAddress remoteDevice; + bool expectRemoteDevice; }; tst_QBluetoothLocalDevice::tst_QBluetoothLocalDevice() + : expectRemoteDevice(false) { const QString remote = qgetenv("BT_TEST_DEVICE"); - if (remote == QStringLiteral("default")) { - remoteDevice = QBluetoothAddress(BT_TEST_DEVICE); - qWarning() << "Using default remote device for testing"; - } else if (!remote.isEmpty()) { + if (!remote.isEmpty()) { remoteDevice = QBluetoothAddress(remote); + expectRemoteDevice = true; qWarning() << "Using remote device " << remote << " for testing. Ensure that the device is discoverable for pairing requests"; } else { qWarning() << "Not using any remote device for testing. Set BT_TEST_DEVICE env to run manual tests involving a remote device"; @@ -110,6 +109,14 @@ tst_QBluetoothLocalDevice::~tst_QBluetoothLocalDevice() { } +void tst_QBluetoothLocalDevice::initTestCase() +{ + if (expectRemoteDevice) { + //test passed Bt address here since we cannot do that in the ctor + QVERIFY2(!remoteDevice.isNull(), "BT_TEST_DEVICE is not a valid Bluetooth address" ); + } +} + void tst_QBluetoothLocalDevice::tst_powerOn() { QBluetoothLocalDevice localDevice; -- cgit v1.2.3