summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-10-10 12:09:55 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-11 13:11:52 +0200
commit8155679b01ec523d877bcb1d6d019b3b555befaa (patch)
treecdacff719274d632bc02011a6deb9cd142226f74
parent42bd6c83b19f789821c4fde414f1ef457dce120d (diff)
Improve handling of invalid Bt address by QBluetoothTransferManager
Some minor unit test improvements Task-number: QTBUG-33801 Change-Id: Idc98bf8928ced0f9e01b24668edf7c32172d2fd1 Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--src/bluetooth/qbluetoothtransferreply_bluez.cpp10
-rw-r--r--src/bluetooth/qbluetoothtransferreply_qnx.cpp11
-rw-r--r--tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp9
3 files changed, 23 insertions, 7 deletions
diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
index 3c63adeb..0634f080 100644
--- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
@@ -110,13 +110,21 @@ bool QBluetoothTransferReplyBluez::start()
}
else {
if (!file->exists()) {
- m_errorStr = tr("File does not exist");
+ m_errorStr = QBluetoothTransferReply::tr("File does not exist");
m_error = QBluetoothTransferReply::FileNotFoundError;
m_finished = true;
m_running = false;
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
return false;
}
+ if (request().address().isNull()) {
+ m_errorStr = QBluetoothTransferReply::tr("Invalid target address");
+ m_error = QBluetoothTransferReply::HostNotFoundError;
+ m_finished = true;
+ m_running = false;
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
+ return false;
+ }
m_size = file->size();
startOPP(file->fileName());
}
diff --git a/src/bluetooth/qbluetoothtransferreply_qnx.cpp b/src/bluetooth/qbluetoothtransferreply_qnx.cpp
index e37852cd..b3425300 100644
--- a/src/bluetooth/qbluetoothtransferreply_qnx.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_qnx.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 Research In Motion
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
@@ -113,13 +114,21 @@ bool QBluetoothTransferReplyQnx::start()
} else {
if (!file->exists()) {
- m_errorStr = tr("File does not exist");
+ m_errorStr = QBluetoothTransferReply::tr("File does not exist");
m_error = QBluetoothTransferReply::FileNotFoundError;
m_finished = true;
m_running = false;
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
return false;
}
+ if (request().address().isNull()) {
+ m_errorStr = QBluetoothTransferReply::tr("Invalid target address");
+ m_error = QBluetoothTransferReply::HostNotFoundError;
+ m_finished = true;
+ m_running = false;
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
+ return false;
+ }
startOPP(file->fileName());
}
return true;
diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
index 5c9ea9f0..885b7f1e 100644
--- a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
+++ b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
@@ -276,7 +276,7 @@ void tst_QBluetoothTransferManager::tst_sendFile()
QBluetoothLocalDevice dev;
if (expectSuccess) {
dev.requestPairing(deviceAddress, QBluetoothLocalDevice::Paired);
- QTest::qWait(2000);
+ QTest::qWait(5000);
QCOMPARE(dev.pairingStatus(deviceAddress), QBluetoothLocalDevice::Paired);
}
@@ -289,8 +289,7 @@ void tst_QBluetoothTransferManager::tst_sendFile()
fileHandle = QFINDTESTDATA("testfile.txt");
QVERIFY(!fileHandle.isEmpty());
} else {
- fileHandle = QFINDTESTDATA("arbitraryFileName.txt"); //file doesn't exist
- QVERIFY(fileHandle.isEmpty());
+ fileHandle = ("arbitraryFileName.txt"); //file doesn't exist
}
QFile f(fileHandle);
QCOMPARE(f.exists(), !isInvalidFile);
@@ -311,8 +310,8 @@ void tst_QBluetoothTransferManager::tst_sendFile()
const int maxWaitTime = 20 * 1000; //20s
for (int time = 0;
time<maxWaitTime && (finishedSpy.count()==0);
- time+=10000) {
- QTest::qWait(10000); //if interval
+ time+=1000) {
+ QTest::qWait(1000); //if interval
}
QVERIFY(finishedSpy.count()>0);