summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-02-26 17:10:09 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-27 09:53:54 +0100
commited49b5cda6d84793ffdfd433b2d2cea0583de219 (patch)
tree32faca81d528d9c3201ccf0084b178e82d8c20a2
parentf58cddd97aa873d7d2b310d59e5fa1febbaba224 (diff)
Add copy operator to QBluetoothHostInfo.
The QBluetoothSocket unit test was sometimes failing because of it. Change-Id: I6071902e1aaa9e1138f071b7f2ce2a8ccb436789 Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--src/bluetooth/qbluetoothhostinfo.cpp13
-rw-r--r--src/bluetooth/qbluetoothhostinfo.h2
-rw-r--r--tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp18
3 files changed, 33 insertions, 0 deletions
diff --git a/src/bluetooth/qbluetoothhostinfo.cpp b/src/bluetooth/qbluetoothhostinfo.cpp
index 1e8dbc2e..00ce0680 100644
--- a/src/bluetooth/qbluetoothhostinfo.cpp
+++ b/src/bluetooth/qbluetoothhostinfo.cpp
@@ -82,6 +82,19 @@ QBluetoothHostInfo::~QBluetoothHostInfo()
}
/*!
+ Assigns \a other to this QBluetoothHostInfo instance.
+*/
+QBluetoothHostInfo &QBluetoothHostInfo::operator=(const QBluetoothHostInfo &other)
+{
+ Q_D(QBluetoothHostInfo);
+
+ d->m_address = other.d_func()->m_address;
+ d->m_name = other.d_func()->m_name;
+
+ return *this;
+}
+
+/*!
Returns the Bluetooth address as a QBluetoothAddress.
*/
QBluetoothAddress QBluetoothHostInfo::address() const
diff --git a/src/bluetooth/qbluetoothhostinfo.h b/src/bluetooth/qbluetoothhostinfo.h
index 24590ebb..b4428a82 100644
--- a/src/bluetooth/qbluetoothhostinfo.h
+++ b/src/bluetooth/qbluetoothhostinfo.h
@@ -55,6 +55,8 @@ public:
QBluetoothHostInfo(const QBluetoothHostInfo &other);
~QBluetoothHostInfo();
+ QBluetoothHostInfo &operator=(const QBluetoothHostInfo &other);
+
QBluetoothAddress address() const;
void setAddress(const QBluetoothAddress &address);
diff --git a/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp b/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp
index aa2448a8..be2cadbf 100644
--- a/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp
+++ b/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp
@@ -65,6 +65,8 @@ private slots:
void tst_construction_data();
void tst_construction();
+
+ void tst_copy();
};
tst_QBluetoothHostInfo::tst_QBluetoothHostInfo()
@@ -171,6 +173,22 @@ void tst_QBluetoothHostInfo::tst_construction()
QCOMPARE(setter.address().isNull(), !validBtAddress);
}
+void tst_QBluetoothHostInfo::tst_copy()
+{
+ QBluetoothHostInfo original;
+ original.setAddress(QBluetoothAddress("11:22:33:44:55:66"));
+ original.setName(QStringLiteral("FunkyName"));
+
+ QBluetoothHostInfo assignConstructor(original);
+ QCOMPARE(assignConstructor.name(), original.name());
+ QCOMPARE(assignConstructor.address(), original.address());
+
+ QBluetoothHostInfo assignOperator;
+ assignOperator = original;
+ QCOMPARE(assignOperator.name(), original.name());
+ QCOMPARE(assignOperator.address(), original.address());
+}
+
QTEST_MAIN(tst_QBluetoothHostInfo)
#include "tst_qbluetoothhostinfo.moc"