summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2010-10-19 11:23:22 +1000
committerMichael Goddard <michael.goddard@nokia.com>2010-10-19 11:23:22 +1000
commit64e3b9b47b7588b563eeb2a34e12e7e6d4b7047f (patch)
tree587ec14e686cae76cd08d82efedfad0e9fb778be /tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp
parent79454262cd5e3af9cacea36ab0aef242edfe3bfc (diff)
Extend the test plugin to test more parts of the API.
Unfortunately you can't currently report that an effect has finished playing from the backend (reliably).
Diffstat (limited to 'tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp')
-rw-r--r--tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp b/tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp
index 74410da4b4..a04080239f 100644
--- a/tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp
+++ b/tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp
@@ -54,6 +54,8 @@ Q_EXPORT_PLUGIN2(feedback_testplugin, QFeedbackTestPlugin)
QFeedbackTestPlugin::QFeedbackTestPlugin() : QObject(qApp), mHapticState(QFeedbackEffect::Stopped), mFileState(QFeedbackEffect::Stopped)
{
actuators_ << createFeedbackActuator(this, 7357);
+ mHapticTimer.setSingleShot(true);
+ connect(&mHapticTimer, SIGNAL(timeout()), this, SLOT(timerExpired()));
}
QFeedbackTestPlugin::~QFeedbackTestPlugin()
@@ -113,14 +115,24 @@ bool QFeedbackTestPlugin::isActuatorCapabilitySupported(const QFeedbackActuator
void QFeedbackTestPlugin::updateEffectProperty(const QFeedbackHapticsEffect *effect, EffectProperty ep)
{
- Q_UNUSED(effect)
- Q_UNUSED(ep)
+ if (ep == QFeedbackHapticsInterface::Duration)
+ mHapticTimer.setInterval(effect->duration());
}
void QFeedbackTestPlugin::setEffectState(const QFeedbackHapticsEffect *effect, QFeedbackEffect::State state)
{
Q_UNUSED(effect)
- mHapticState = state;
+ if (mHapticState != state) {
+ mHapticState = state;
+ if (mHapticState == QFeedbackEffect::Running) {
+ mHapticTimer.start();
+ } else if (mHapticState == QFeedbackEffect::Stopped) {
+ mHapticTimer.stop();
+ } else if (mHapticState == QFeedbackEffect::Paused) {
+ // In theory should set the duration to the remainder...
+ mHapticTimer.stop();
+ }
+ }
}
QFeedbackEffect::State QFeedbackTestPlugin::effectState(const QFeedbackHapticsEffect *effect)
@@ -129,6 +141,14 @@ QFeedbackEffect::State QFeedbackTestPlugin::effectState(const QFeedbackHapticsEf
return mHapticState;
}
+void QFeedbackTestPlugin::timerExpired()
+{
+ qDebug() << "Timer expired";
+ mHapticState = QFeedbackEffect::Stopped;
+}
+
+
+
void QFeedbackTestPlugin::setLoaded(QFeedbackFileEffect *effect, bool load)
{
Q_UNUSED(effect)
@@ -161,7 +181,7 @@ QFeedbackEffect::State QFeedbackTestPlugin::effectState(const QFeedbackFileEffec
int QFeedbackTestPlugin::effectDuration(const QFeedbackFileEffect *effect)
{
Q_UNUSED(effect)
- return -1;
+ return 5678;
}
QStringList QFeedbackTestPlugin::supportedMimeTypes()