summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoralex <alex.blasche@nokia.com>2012-06-25 12:49:03 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-27 02:36:18 +0200
commit2cf4fc7c63622326780646375cf4c7c2fd014345 (patch)
tree2592a66068d5791f538358f0e68173afd4cb7373 /tests
parentf60cccfc4eef73ecc8e79c4b0826e7dcaf212c2b (diff)
Fix various Bluetooth tests such that they run via CI
The CI system doesn't have any Bluetooth devices attached to it. Task-number: QTBUG-22017 Change-Id: I136d8f1295f3e770eb8c66557343ede7fa438a06 Reviewed-by: Michael Zanetti <michael.zanetti@nokia.com> Reviewed-by: Andrew Stanley-Jones <andrew.stanley-jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp3
-rw-r--r--tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp36
-rw-r--r--tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp3
-rw-r--r--tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp3
-rw-r--r--tests/auto/qrfcommserver/tst_qrfcommserver.cpp3
5 files changed, 43 insertions, 5 deletions
diff --git a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
index 31ed1a03..30d8946b 100644
--- a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
+++ b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
@@ -94,6 +94,9 @@ void tst_QBluetoothDeviceDiscoveryAgent::initTestCase()
qRegisterMetaType<QBluetoothDeviceInfo>("QBluetoothDeviceInfo");
qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::InquiryType>("QBluetoothDeviceDiscoveryAgent::InquiryType");
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+
// turn on BT in case it is not on
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
if (device->hostMode() == QBluetoothLocalDevice::HostPoweredOff) {
diff --git a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp
index 1470567c..c6d2e921 100644
--- a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp
+++ b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp
@@ -119,7 +119,6 @@ void tst_QBluetoothLocalDevice::tst_pairingStatus_data()
void tst_QBluetoothLocalDevice::tst_powerOn()
{
- {
QBluetoothLocalDevice localDevice;
QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
@@ -127,6 +126,9 @@ void tst_QBluetoothLocalDevice::tst_powerOn()
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);
@@ -134,11 +136,13 @@ void tst_QBluetoothLocalDevice::tst_powerOn()
// we should not be powered off
QVERIFY(hostMode == QBluetoothLocalDevice::HostConnectable
|| hostMode == QBluetoothLocalDevice::HostDiscoverable);
- }
-
}
+
void tst_QBluetoothLocalDevice::tst_powerOff()
{
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+
{
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
device->powerOn();
@@ -164,6 +168,9 @@ void tst_QBluetoothLocalDevice::tst_hostModes()
{
QFETCH(QBluetoothLocalDevice::HostMode, hostModeExpected);
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+
QBluetoothLocalDevice localDevice;
QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
// there should be no changes yet
@@ -189,11 +196,17 @@ void tst_QBluetoothLocalDevice::tst_hostModes()
void tst_QBluetoothLocalDevice::tst_address()
{
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+
QBluetoothLocalDevice localDevice;
QVERIFY(!localDevice.address().toString().isEmpty());
}
void tst_QBluetoothLocalDevice::tst_name()
{
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+
QBluetoothLocalDevice localDevice;
QVERIFY(!localDevice.name().isEmpty());
}
@@ -201,14 +214,24 @@ void tst_QBluetoothLocalDevice::tst_isValid()
{
QBluetoothLocalDevice localDevice;
QVERIFY(localDevice.isValid());
+
+ /*
+ //TODO the above should really be the following once QBluetoothLocalDevice has been fixed
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QVERIFY(!localDevice.isValid());
+ else
+ QVERIFY(localDevice.isValid());
+ */
}
void tst_QBluetoothLocalDevice::tst_allDevices()
{
- // we should have one local bluetooth device
- QVERIFY(QBluetoothLocalDevice::allDevices().count() == 1);
+ //nothing we can really test here
}
void tst_QBluetoothLocalDevice::tst_construction()
{
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+
QBluetoothLocalDevice localDevice;
QVERIFY(localDevice.isValid());
@@ -223,6 +246,9 @@ void tst_QBluetoothLocalDevice::tst_pairDevice()
QFETCH(QBluetoothAddress, deviceAddress);
QFETCH(QBluetoothLocalDevice::Pairing, pairingExpected);
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+
qDebug() << "tst_pairDevice(): address=" << deviceAddress.toString() << "pairingModeExpected="
<< static_cast<int>(pairingExpected);
diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
index 57b92272..2afcb914 100644
--- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
@@ -125,6 +125,9 @@ tst_QBluetoothSocket::~tst_QBluetoothSocket()
void tst_QBluetoothSocket::initTestCase()
{
// start Bluetooth if not started
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
device->powerOn();
delete device;
diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
index 8e223d9e..210c5015 100644
--- a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
+++ b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
@@ -111,6 +111,9 @@ tst_QBluetoothTransferManager::~tst_QBluetoothTransferManager()
void tst_QBluetoothTransferManager::initTestCase()
{
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+
// start Bluetooth if not started
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
device->powerOn();
diff --git a/tests/auto/qrfcommserver/tst_qrfcommserver.cpp b/tests/auto/qrfcommserver/tst_qrfcommserver.cpp
index e6052f65..e8816270 100644
--- a/tests/auto/qrfcommserver/tst_qrfcommserver.cpp
+++ b/tests/auto/qrfcommserver/tst_qrfcommserver.cpp
@@ -94,6 +94,9 @@ void tst_QRfcommServer::initTestCase()
{
qRegisterMetaType<QBluetooth::SecurityFlags>("QBluetooth::SecurityFlags");
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+
// turn on BT in case it is not on
if (localDevice.hostMode() == QBluetoothLocalDevice::HostPoweredOff) {
QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));