Debian Codegraph @

tests/auto/qfeedbackactuator/tst_qfeedbackactuator.cpp

raw symbols SCIP
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtFeedback module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28
29 //TESTED_COMPONENT=src/feedback
30
31 #include <QtTest/QtTest>
32
33 #include <qfeedbackactuator.h>
34
35 QT_USE_NAMESPACE
36
37 class tst_QFeedbackActuator : public QObject
38 {
39 Q_OBJECT
40 public:
41 tst_QFeedbackActuator();
42 ~tst_QFeedbackActuator();
43
44 public slots:
45 void initTestCase();
46 void cleanupTestCase();
47 void init();
48 void cleanup();
49
50 private slots:
51 void enumeration();
52 void setEnabled();
53 };
54
55 tst_QFeedbackActuator::tst_QFeedbackActuator()
56 {
57 }
58
59 tst_QFeedbackActuator::~tst_QFeedbackActuator()
60 {
61 }
62
63 void tst_QFeedbackActuator::initTestCase()
64 {
65 }
66
67 void tst_QFeedbackActuator::cleanupTestCase()
68 {
69 }
70
71 void tst_QFeedbackActuator::init()
72 {
73 //the list returned should always be the same with the same order
74 QCOMPARE(QFeedbackActuator::actuators(), QFeedbackActuator::actuators());
75 }
76
77 void tst_QFeedbackActuator::cleanup()
78 {
79 }
80
81
82 #if defined(HAVE_ACTUATORS)
83 //we're on meego/maemo
84 #define CAPABILITY true //the capabilities are supported through Immersion
85 #else
86 #define CAPABILITY false
87 #endif
88
89 void tst_QFeedbackActuator::enumeration()
90 {
91 QList<QFeedbackActuator*> actuators = QFeedbackActuator::actuators();
92 #ifdef HAVE_ACTUATORS
93 QVERIFY(!actuators.isEmpty());
94 #endif
95 foreach(QFeedbackActuator* actuator, actuators) {
96 if (actuator->name() == QString("test plugin") || actuator->name() == QString("5555"))
97 continue;
98
99 QVERIFY(actuator->isValid());
100 QVERIFY(actuator->id() >= 0);
101 QCOMPARE(actuator->isCapabilitySupported(QFeedbackActuator::Envelope), CAPABILITY);
102 QCOMPARE(actuator->isCapabilitySupported(QFeedbackActuator::Period), CAPABILITY);
103 QVERIFY(!actuator->name().isEmpty());
104 }
105
106 // Try comparisons
107 if (actuators.count() > 1) {
108 QFeedbackActuator* a1 = actuators.at(0);
109 QFeedbackActuator* a2 = actuators.at(1);
110 QFeedbackActuator* a1b = actuators.at(0);
111 QFeedbackActuator* a2b = actuators.at(1);
112 QVERIFY(a1->id() != a2->id());
113 // QVERIFY(*a1 != *a2); // doesn't work, no operator != !!
114 QVERIFY(!(*a1 == *a2));
115
116 QVERIFY(*a1 == *a1b);
117 QVERIFY(*a2 == *a2b);
118 }
119 }
120
121 void tst_QFeedbackActuator::setEnabled()
122 {
123 foreach(QFeedbackActuator* actuator, QFeedbackActuator::actuators()) {
124 if (actuator->name() == QString("test plugin") || actuator->name() == QString("5555"))
125 continue;
126 //this test might not always be true because you ight not be allowed to change the enabled property
127 actuator->setEnabled(false);
128 QVERIFY(!actuator->isEnabled());
129 actuator->setEnabled(true);
130 QVERIFY(actuator->isEnabled());
131 }
132 }
133
134
135
136
137 QTEST_MAIN(tst_QFeedbackActuator)
138
139 #include "tst_qfeedbackactuator.moc"