Debian Codegraph @

tests/auto/input/qabstractphysicaldeviceproxy/tst_qabstractphysicaldeviceproxy.cpp

raw symbols SCIP
1 // Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4
5 #include <QtTest/QTest>
6
7 #include "testdeviceproxy.h"
8
9 class tst_QAbstractPhysicalDeviceProxy : public QObject
10 {
11 Q_OBJECT
12
13 private Q_SLOTS:
14
15 void checkDefaultConstruction()
16 {
17 // GIVEN
18 TestProxy abstractPhysicalDeviceProxy;
19
20 // THEN
21 QCOMPARE(abstractPhysicalDeviceProxy.deviceName(), QLatin1String("TestProxy"));
22 QCOMPARE(abstractPhysicalDeviceProxy.status(), Qt3DInput::QAbstractPhysicalDeviceProxy::NotFound);
23 QCOMPARE(abstractPhysicalDeviceProxy.axisCount(), 0);
24 QCOMPARE(abstractPhysicalDeviceProxy.buttonCount(), 0);
25 QCOMPARE(abstractPhysicalDeviceProxy.axisNames(), QStringList());
26 QCOMPARE(abstractPhysicalDeviceProxy.buttonNames(), QStringList());
27 QVERIFY(abstractPhysicalDeviceProxy.device() == nullptr);
28 }
29
30 void checkDeviceBookkeeping()
31 {
32 // GIVEN
33 TestProxy *abstractPhysicalDeviceProxy = new TestProxy();
34
35 // WHEN
36 TestPhysicalDevice *device = new TestPhysicalDevice();
37 abstractPhysicalDeviceProxy->setDevice(device);
38
39 // THEN
40 QVERIFY(abstractPhysicalDeviceProxy->device() == device);
41
42 // WHEN
43 delete device;
44
45 // THEN -> should not crash
46 QVERIFY(abstractPhysicalDeviceProxy->device() == nullptr);
47 }
48 };
49
50 QTEST_MAIN(tst_QAbstractPhysicalDeviceProxy)
51
52 #include "tst_qabstractphysicaldeviceproxy.moc"