diff options
author | Mrudul Pendharkar <mrudul.v.pendharkar@nokia.com> | 2012-05-18 16:13:51 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-31 13:45:30 +0200 |
commit | a63a84db1696326f3a336af04da3f9b66ae70a54 (patch) | |
tree | 1845b339dfb81a4ec54b6caf8d3bdaa01cb45125 | |
parent | f839320dd7173bf5f1cda8de3d30394b09fb5ecf (diff) |
Cleaning code and removing dependency on QCoreApplication
Change-Id: Ie37bc765656ec420989460563cc0424813f2f7a9
Reviewed-by: Jaakko Korpela <jaakko.korpela@nokia.com>
-rw-r--r-- | src/feedback/feedback.pro | 22 | ||||
-rw-r--r-- | src/feedback/qfeedbackplugin.cpp | 8 | ||||
-rw-r--r-- | src/feedback/qfeedbackpluginsearch.h (renamed from src/feedback/qmobilitypluginsearch.h) | 64 | ||||
-rw-r--r-- | tests/auto/auto.pro | 1 | ||||
-rw-r--r-- | tests/auto/qfeedbacknoplugins/qfeedbacknoplugins.pro | 5 | ||||
-rw-r--r-- | tests/auto/qfeedbacknoplugins/tst_qfeedbacknoplugins.cpp | 169 |
6 files changed, 11 insertions, 258 deletions
diff --git a/src/feedback/feedback.pro b/src/feedback/feedback.pro index 0663ef1..b714b69 100644 --- a/src/feedback/feedback.pro +++ b/src/feedback/feedback.pro @@ -15,30 +15,14 @@ load(qt_module_config) PUBLIC_HEADERS += qfeedbackglobal.h \ qfeedbackactuator.h \ qfeedbackeffect.h \ - qfeedbackplugininterfaces.h + qfeedbackplugininterfaces.h \ + qfeedbackpluginsearch.h PRIVATE_HEADERS += qfeedbackeffect_p.h \ qfeedbackplugin_p.h -HEADERS = qtfeedbackversion.h $$PUBLIC_HEADERS $$PRIVATE_HEADERS +HEADERS = $$PUBLIC_HEADERS $$PRIVATE_HEADERS SOURCES += qfeedbackactuator.cpp \ qfeedbackeffect.cpp \ qfeedbackplugin.cpp - -symbian { - TARGET.EPOCALLOWDLLDATA = 1 - TARGET.CAPABILITY = ALL \ - -TCB - - # UID - TARGET.UID3 = 0x2002BFCE - - LIBS += -lefsrv - - # Main library - FEEDBACK_DEPLOYMENT.sources = QtFeedback.dll - FEEDBACK_DEPLOYMENT.path = /sys/bin - DEPLOYMENT += FEEDBACK_DEPLOYMENT - deploy.path = $$EPOCROOT -} diff --git a/src/feedback/qfeedbackplugin.cpp b/src/feedback/qfeedbackplugin.cpp index cf60b8e..4a164bf 100644 --- a/src/feedback/qfeedbackplugin.cpp +++ b/src/feedback/qfeedbackplugin.cpp @@ -43,7 +43,7 @@ #include "qfeedbackplugin_p.h" #include "qfeedbackeffect_p.h" -#include "qmobilitypluginsearch.h" +#include "qfeedbackpluginsearch.h" #include <QtCore/QCoreApplication> #include <QtCore/QStringList> @@ -257,10 +257,8 @@ class BackendManager public: BackendManager() { - QStringList pluginPaths = mobilityPlugins(QLatin1String("feedback")); - // Testing hook to force "no plugin mode" - if (qApp->property("QFEEDBACK_TEST_NO_PLUGINS").isValid()) - pluginPaths.clear(); + QStringList pluginPaths = getPluginPaths(QLatin1String("feedback")); + foreach (const QString& pluginPath, pluginPaths) { QPluginLoader loader(pluginPath); diff --git a/src/feedback/qmobilitypluginsearch.h b/src/feedback/qfeedbackpluginsearch.h index c34c279..fb18607 100644 --- a/src/feedback/qmobilitypluginsearch.h +++ b/src/feedback/qfeedbackpluginsearch.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtFeedback Components. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -38,65 +38,30 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef QMOBILITYPLUGINSEARCH_H -#define QMOBILITYPLUGINSEARCH_H +#ifndef QFEEDBACKPLUGINSEARCH_H +#define QFEEDBACKPLUGINSEARCH_H #include <QCoreApplication> #include <QStringList> #include <QDir> #include <QDebug> -#if defined(Q_OS_SYMBIAN) -# include <f32file.h> -#endif - QT_BEGIN_NAMESPACE -#if defined(Q_OS_SYMBIAN) -static inline bool qSymbian_CheckDir(const QDir& dir, RFs& rfs) -{ - bool pathFound = false; - // In Symbian, going cdUp() in a c:/private/<uid3>/ will result in *platsec* error at fileserver (requires AllFiles capability) - // Also, trying to cd() to a nonexistent directory causes *platsec* error. This does not cause functional harm, but should - // nevertheless be changed to use native Symbian methods to avoid unnecessary platsec warnings (as per qpluginloader.cpp). - // Use native Symbian code to check for directory existence, because checking - // for files from under non-existent protected dir like E:/private/<uid> using - // QDir::exists causes platform security violations on most apps. - QString nativePath = QDir::toNativeSeparators(dir.absolutePath()); - TPtrC ptr = TPtrC16(static_cast<const TUint16*>(nativePath.utf16()), nativePath.length()); - TUint attributes; - TInt err = rfs.Att(ptr, attributes); - if (err == KErrNone) { - // yes, the directory exists. - pathFound = true; - } - return pathFound; -} -#define CHECKDIR(dir) qSymbian_CheckDir(dir, rfs) -#else #define CHECKDIR(dir) (dir).exists() -#endif -inline QStringList mobilityPlugins(const QString& plugintype) +inline QStringList getPluginPaths(const QString& plugintype) { #if !defined QT_NO_DEBUG const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; #endif QStringList paths = QCoreApplication::libraryPaths(); -/*#ifdef QTM_PLUGIN_PATH - paths << QLatin1String(QTM_PLUGIN_PATH); -#endif*/ #if !defined QT_NO_DEBUG if (showDebug) qDebug() << "Plugin paths:" << paths; #endif -#if defined(Q_OS_SYMBIAN) - RFs rfs; - qt_symbian_throwIfError(rfs.Connect()); -#endif - // Temp variable to avoid multiple identical paths // (we don't convert the list to set first, because that loses the order) QSet<QString> processed; @@ -145,26 +110,7 @@ inline QStringList mobilityPlugins(const QString& plugintype) } } - /* Add application path + plugintype */ - QDir appldir(QCoreApplication::applicationDirPath()); - if(appldir.cd(plugintype)){ - if (!processed.contains(appldir.absolutePath())){ - processed.insert(appldir.absolutePath()); - QStringList files = appldir.entryList(QDir::Files); -#if !defined QT_NO_DEBUG - if (showDebug) - qDebug() << "Looking for " << plugintype << " plugins in" << appldir.path() << files; -#endif - for (int j=0; j < files.count(); j++) { - plugins << appldir.absoluteFilePath(files.at(j)); - } - } - } - -#if defined(Q_OS_SYMBIAN) - rfs.Close(); -#endif - return plugins; + return plugins; } QT_END_NAMESPACE diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 2d25bd1..4382f19 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -3,7 +3,6 @@ SUBDIRS += \ qfeedbackactuator \ qfeedbackhapticseffect \ qfeedbackplugin \ - qfeedbacknoplugins \ qfeedbackmmk \ qdeclarativefeedback \ diff --git a/tests/auto/qfeedbacknoplugins/qfeedbacknoplugins.pro b/tests/auto/qfeedbacknoplugins/qfeedbacknoplugins.pro deleted file mode 100644 index 2847925..0000000 --- a/tests/auto/qfeedbacknoplugins/qfeedbacknoplugins.pro +++ /dev/null @@ -1,5 +0,0 @@ -include(../auto.pri) - -QT += feedback - -SOURCES += tst_qfeedbacknoplugins.cpp diff --git a/tests/auto/qfeedbacknoplugins/tst_qfeedbacknoplugins.cpp b/tests/auto/qfeedbacknoplugins/tst_qfeedbacknoplugins.cpp deleted file mode 100644 index 7a63f8f..0000000 --- a/tests/auto/qfeedbacknoplugins/tst_qfeedbacknoplugins.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//TESTED_COMPONENT=src/feedback - -#include <QtTest/QtTest> - -#include <qfeedbackeffect.h> -#include <qfeedbackactuator.h> - -QT_USE_NAMESPACE - -class tst_QFeedbackNoPlugins : public QObject -{ - Q_OBJECT -public: - tst_QFeedbackNoPlugins(); - ~tst_QFeedbackNoPlugins(); - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void testHapticEffect(); - void testFileEffect(); - void testThemeEffect(); - void testActuators(); -}; - -tst_QFeedbackNoPlugins::tst_QFeedbackNoPlugins() -{ - // This turns off plugin loading in unit test builds - qApp->setProperty("QFEEDBACK_TEST_NO_PLUGINS", 1); -} - -tst_QFeedbackNoPlugins::~tst_QFeedbackNoPlugins() -{ -} - -void tst_QFeedbackNoPlugins::initTestCase() -{ -} - -void tst_QFeedbackNoPlugins::cleanupTestCase() -{ -} - -void tst_QFeedbackNoPlugins::init() -{ -} - -void tst_QFeedbackNoPlugins::cleanup() -{ -} - -void tst_QFeedbackNoPlugins::testThemeEffect() -{ - // No plugins - QVERIFY(!QFeedbackEffect::supportsThemeEffect()); - QVERIFY(!QFeedbackEffect::playThemeEffect(QFeedbackEffect::Press)); - QVERIFY(!QFeedbackEffect::playThemeEffect(QFeedbackEffect::Release)); -} - -void tst_QFeedbackNoPlugins::testFileEffect() -{ - QFeedbackFileEffect fileEffect; - QVERIFY(QFeedbackFileEffect::supportedMimeTypes().isEmpty()); - - QVERIFY(fileEffect.state() == QFeedbackEffect::Stopped); - - fileEffect.setSource(QUrl("load")); // this should call load - QVERIFY(fileEffect.state() == QFeedbackEffect::Stopped); // fail :D - QVERIFY(!fileEffect.isLoaded()); - fileEffect.setLoaded(true); - QVERIFY(!fileEffect.isLoaded()); - fileEffect.setLoaded(false); - QVERIFY(!fileEffect.isLoaded()); - fileEffect.start(); - QVERIFY(fileEffect.state() == QFeedbackEffect::Stopped); // fail :D -} - -void tst_QFeedbackNoPlugins::testHapticEffect() -{ - QFeedbackHapticsEffect testEffect; - - // it will do nothing, so stick some values in and play it. - testEffect.setAttackIntensity(0.0); - testEffect.setAttackTime(250); - testEffect.setIntensity(1.0); - testEffect.setDuration(100); - testEffect.setFadeTime(250); - testEffect.setFadeIntensity(0.0); - testEffect.start(); - QVERIFY(testEffect.state() == QFeedbackHapticsEffect::Stopped); - testEffect.pause(); - QVERIFY(testEffect.state() == QFeedbackHapticsEffect::Stopped); - testEffect.start(); - QVERIFY(testEffect.state() == QFeedbackHapticsEffect::Stopped); - testEffect.stop(); - QVERIFY(testEffect.state() == QFeedbackHapticsEffect::Stopped); -} - - -void tst_QFeedbackNoPlugins::testActuators() -{ - QList<QFeedbackActuator*> actuators = QFeedbackActuator::actuators(); - - // No plugins == no actuators - QVERIFY(actuators.isEmpty()); - - // Create a default one, anyway - QFeedbackActuator a; - - QVERIFY(a.isValid() == false); - QVERIFY(a.name().isEmpty()); - - QCOMPARE(a.isCapabilitySupported(QFeedbackActuator::Envelope), false); - QCOMPARE(a.isCapabilitySupported(QFeedbackActuator::Period), false); - - a.setEnabled(false); - QVERIFY(!a.isEnabled()); - a.setEnabled(true); - QVERIFY(!a.isEnabled()); -} - -QTEST_MAIN(tst_QFeedbackNoPlugins) - -#include "tst_qfeedbacknoplugins.moc" |