summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2016-06-02 08:19:11 +0200
committerSean Harmer <sean.harmer@kdab.com>2016-06-29 09:21:28 +0000
commit847ee3bbaabc2ed58d307b72b38fa085cf04d062 (patch)
tree4eee7c8684ea9cd0ba9223569ce545a9223625ed /tests/auto
parent494893005843993bae5344f72e248a9de7e0c63b (diff)
tst_QLogicalDevice: add tests for axis and actions bookkeeping
Change-Id: I43b8bfd2a3e9cb7822aa763fbb1a078d7c9f0839 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/input/qlogicaldevice/tst_qlogicaldevice.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/input/qlogicaldevice/tst_qlogicaldevice.cpp b/tests/auto/input/qlogicaldevice/tst_qlogicaldevice.cpp
index fcbd8894c..f81fcee41 100644
--- a/tests/auto/input/qlogicaldevice/tst_qlogicaldevice.cpp
+++ b/tests/auto/input/qlogicaldevice/tst_qlogicaldevice.cpp
@@ -173,6 +173,74 @@ private Q_SLOTS:
arbiter.events.clear();
}
+
+ void checkAxisBookkeeping()
+ {
+ // GIVEN
+ QScopedPointer<Qt3DInput::QLogicalDevice> device(new Qt3DInput::QLogicalDevice);
+ {
+ // WHEN
+ Qt3DInput::QAxis axis;
+ device->addAxis(&axis);
+
+ // THEN
+ QCOMPARE(axis.parent(), device.data());
+ QCOMPARE(device->axes().size(), 1);
+ }
+ // THEN (Should not crash and parameter be unset)
+ QVERIFY(device->axes().empty());
+
+ {
+ // WHEN
+ Qt3DInput::QLogicalDevice someOtherDevice;
+ QScopedPointer<Qt3DInput::QAxis> axis(new Qt3DInput::QAxis(&someOtherDevice));
+ device->addAxis(axis.data());
+
+ // THEN
+ QCOMPARE(axis->parent(), &someOtherDevice);
+ QCOMPARE(device->axes().size(), 1);
+
+ // WHEN
+ device.reset();
+ axis.reset();
+
+ // THEN Should not crash when the axis is destroyed (tests for failed removal of destruction helper)
+ }
+ }
+
+ void checkActionBookkeeping()
+ {
+ // GIVEN
+ QScopedPointer<Qt3DInput::QLogicalDevice> device(new Qt3DInput::QLogicalDevice);
+ {
+ // WHEN
+ Qt3DInput::QAction action;
+ device->addAction(&action);
+
+ // THEN
+ QCOMPARE(action.parent(), device.data());
+ QCOMPARE(device->actions().size(), 1);
+ }
+ // THEN (Should not crash and parameter be unset)
+ QVERIFY(device->actions().empty());
+
+ {
+ // WHEN
+ Qt3DInput::QLogicalDevice someOtherDevice;
+ QScopedPointer<Qt3DInput::QAction> action(new Qt3DInput::QAction(&someOtherDevice));
+ device->addAction(action.data());
+
+ // THEN
+ QCOMPARE(action->parent(), &someOtherDevice);
+ QCOMPARE(device->actions().size(), 1);
+
+ // WHEN
+ device.reset();
+ action.reset();
+
+ // THEN Should not crash when the action is destroyed (tests for failed removal of destruction helper)
+ }
+ }
};
QTEST_MAIN(tst_QLogicalDevice)