summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-07-23 16:59:15 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-29 12:51:32 +0200
commita7f6e8cf3ed1fddce5fd8a8d0e3d9125e5d8431c (patch)
tree2741be5dcc07b00013dd34a74cb3a4b1aa8e467d /tests
parentb0cca9bdd0acf0865a1a5fcb0c51944d902638b1 (diff)
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 <michael.zanetti@canonical.com> Reviewed-by: Alex <alexander.blasche@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp21
1 files changed, 14 insertions, 7 deletions
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;