diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2016-05-03 15:45:40 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2016-05-04 16:14:19 +0000 |
commit | b8d5c1f1dff57da6927470543e5d004c237846ac (patch) | |
tree | 5fdd8fafd036df90e8dd45b4767b26984ca5c828 /tests | |
parent | aa4222f350a59ad2d90f14a1dfb88f83bf2d2c78 (diff) |
CAN: Do not use QPointer class as it is overhead
... and use the QScopedPointer instead, where possible.
Change-Id: Ie503d5ff31af77cf6a495f324c1e93c34ff7d58b
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/plugins/genericcanbus/dummybackend.h | 3 | ||||
-rw-r--r-- | tests/auto/qcanbus/tst_qcanbus.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qcanbusdevice/tst_qcanbusdevice.cpp | 15 |
3 files changed, 11 insertions, 12 deletions
diff --git a/tests/auto/plugins/genericcanbus/dummybackend.h b/tests/auto/plugins/genericcanbus/dummybackend.h index 2ba5dfe..1c708b3 100644 --- a/tests/auto/plugins/genericcanbus/dummybackend.h +++ b/tests/auto/plugins/genericcanbus/dummybackend.h @@ -40,7 +40,6 @@ #include <QtSerialBus/qcanbusdevice.h> #include <QtCore/qbytearray.h> -#include <QtCore/qpointer.h> QT_BEGIN_NAMESPACE @@ -63,7 +62,7 @@ public Q_SLOTS: void sendMessage(); private: - QPointer<QTimer> sendTimer; + QTimer *sendTimer; QByteArray byteArray; }; diff --git a/tests/auto/qcanbus/tst_qcanbus.cpp b/tests/auto/qcanbus/tst_qcanbus.cpp index 664f4e8..b549f09 100644 --- a/tests/auto/qcanbus/tst_qcanbus.cpp +++ b/tests/auto/qcanbus/tst_qcanbus.cpp @@ -51,7 +51,7 @@ private slots: void createDevice(); private: - QPointer<QCanBus> bus; + QCanBus *bus; }; tst_QCanBus::tst_QCanBus() @@ -71,8 +71,7 @@ void tst_QCanBus::initTestCase() #endif bus = QCanBus::instance(); QVERIFY(bus); - QPointer<QCanBus> sameInstance; - sameInstance = QCanBus::instance(); + QCanBus *sameInstance = QCanBus::instance(); QCOMPARE(bus, sameInstance); } diff --git a/tests/auto/qcanbusdevice/tst_qcanbusdevice.cpp b/tests/auto/qcanbusdevice/tst_qcanbusdevice.cpp index b99ac64..c8ffb40 100644 --- a/tests/auto/qcanbusdevice/tst_qcanbusdevice.cpp +++ b/tests/auto/qcanbusdevice/tst_qcanbusdevice.cpp @@ -39,6 +39,7 @@ #include <QtTest/QtTest> #include <QSignalSpy> +#include <QScopedPointer> class tst_Backend : public QCanBusDevice { @@ -119,7 +120,7 @@ private slots: void tst_filtering(); private: - QPointer<QCanBusDevice> device; + QScopedPointer<QCanBusDevice> device; }; tst_QCanBusDevice::tst_QCanBusDevice() @@ -130,7 +131,7 @@ tst_QCanBusDevice::tst_QCanBusDevice() void tst_QCanBusDevice::initTestCase() { - device = new tst_Backend(); + device.reset(new tst_Backend()); QVERIFY(device); QSignalSpy stateSpy(device.data(), @@ -180,8 +181,8 @@ void tst_QCanBusDevice::conf() void tst_QCanBusDevice::write() { - QSignalSpy spy(device, SIGNAL(written())); - QSignalSpy stateSpy(device, + QSignalSpy spy(device.data(), SIGNAL(written())); + QSignalSpy stateSpy(device.data(), SIGNAL(stateChanged(QCanBusDevice::CanBusDeviceState))); QCanBusFrame frame; @@ -217,7 +218,7 @@ void tst_QCanBusDevice::write() void tst_QCanBusDevice::read() { - QSignalSpy stateSpy(device, + QSignalSpy stateSpy(device.data(), SIGNAL(stateChanged(QCanBusDevice::CanBusDeviceState))); device->disconnectDevice(); @@ -244,10 +245,10 @@ void tst_QCanBusDevice::read() void tst_QCanBusDevice::error() { - QSignalSpy spy(device, SIGNAL(errorOccurred(QCanBusDevice::CanBusError))); + QSignalSpy spy(device.data(), SIGNAL(errorOccurred(QCanBusDevice::CanBusError))); QString testString(QStringLiteral("testString")); - auto backend = qobject_cast<tst_Backend *>(device); + auto backend = qobject_cast<tst_Backend *>(device.data()); QVERIFY(backend); //NoError |