diff options
author | Wolf-Michael Bolle <wolf-michael.bolle@nokia.com> | 2011-10-17 10:59:51 +0200 |
---|---|---|
committer | Wolf-Michael Bolle <wolf-michael.bolle@nokia.com> | 2011-10-17 10:59:51 +0200 |
commit | 84e11bd16c2f9cdbc2ae14963a201cea9ad3127d (patch) | |
tree | 31928c30d7017a50f551b7cd7ebf726d4742d6bd | |
parent | 258d7412fc97c89d4d24eca96dac4bf899950ccf (diff) |
Added QML bindings and unit tests.
-rw-r--r-- | src/imports/imports.pro | 3 | ||||
-rw-r--r-- | src/imports/mimetypes/mimetypes.cpp | 69 | ||||
-rw-r--r-- | src/imports/mimetypes/mimetypes.pro | 36 | ||||
-rw-r--r-- | src/imports/mimetypes/qdeclarativemimedatabase.cpp | 119 | ||||
-rw-r--r-- | src/imports/mimetypes/qdeclarativemimedatabase_p.h | 101 | ||||
-rw-r--r-- | src/imports/mimetypes/qdeclarativemimetype.cpp | 208 | ||||
-rw-r--r-- | src/imports/mimetypes/qdeclarativemimetype_p.h | 118 | ||||
-rw-r--r-- | src/imports/mimetypes/qmldir | 1 | ||||
-rw-r--r-- | src/src.pro | 2 | ||||
-rw-r--r-- | tests/auto/auto.pro | 4 | ||||
-rw-r--r-- | tests/auto/qdeclarativemimedatabase/qdeclarativemimedatabase.pro | 17 | ||||
-rw-r--r-- | tests/auto/qdeclarativemimedatabase/testdata_list.js | 209 | ||||
-rw-r--r-- | tests/auto/qdeclarativemimedatabase/tst_qdeclarativemimedatabase.cpp | 44 | ||||
-rw-r--r-- | tests/auto/qdeclarativemimedatabase/tst_qdeclarativemimedatabase.qml | 213 | ||||
-rw-r--r-- | tests/auto/qdeclarativemimetype/qdeclarativemimetype.pro | 17 | ||||
-rw-r--r-- | tests/auto/qdeclarativemimetype/tst_qdeclarativemimetype.cpp | 44 | ||||
-rw-r--r-- | tests/auto/qdeclarativemimetype/tst_qdeclarativemimetype.qml | 134 |
17 files changed, 1337 insertions, 2 deletions
diff --git a/src/imports/imports.pro b/src/imports/imports.pro new file mode 100644 index 0000000..8d627c0 --- /dev/null +++ b/src/imports/imports.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS += mimetypes diff --git a/src/imports/mimetypes/mimetypes.cpp b/src/imports/mimetypes/mimetypes.cpp new file mode 100644 index 0000000..9856ce0 --- /dev/null +++ b/src/imports/mimetypes/mimetypes.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMimeTypes addon 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$ +** +****************************************************************************/ + +#include "qdeclarativemimetype_p.h" +#include "qdeclarativemimedatabase_p.h" + +#include <QtDeclarative/qdeclarativeextensionplugin.h> + +// ------------------------------------------------------------------------------------------------ + +class QMimeTypesDeclarativeModule : public QDeclarativeExtensionPlugin +{ + Q_OBJECT + +public: + virtual void registerTypes(const char* uri); +}; + +// ------------------------------------------------------------------------------------------------ + +void QMimeTypesDeclarativeModule::registerTypes(const char* uri) +{ + qmlRegisterType<QDeclarativeMimeType>(uri, 1, 0, "MimeType"); + qmlRegisterType<QDeclarativeMimeDatabase>(uri, 1, 0, "MimeDatabase"); +} + +// ------------------------------------------------------------------------------------------------ + +#include "mimetypes.moc" + +Q_EXPORT_PLUGIN2(qmimetypesdeclarativemodule, QT_PREPEND_NAMESPACE(QMimeTypesDeclarativeModule)) diff --git a/src/imports/mimetypes/mimetypes.pro b/src/imports/mimetypes/mimetypes.pro new file mode 100644 index 0000000..520c9b8 --- /dev/null +++ b/src/imports/mimetypes/mimetypes.pro @@ -0,0 +1,36 @@ +CONFIG += qt plugin +TEMPLATE = lib +TARGET = declarative_mimetypes + +# QtCore/qlist.h uses /usr/include/limits.h which uses does not compile with -pedantic. +# QtDeclarative/qdeclarativeprivate.h will not compile with -pedantic. +#MAKE_CXXFLAGS += -W -Wall -Wextra -Werror -ansi -pedantic -Wshadow -Wno-long-long -Wnon-virtual-dtor +QMAKE_CXXFLAGS += -W -Wall -Wextra -Werror -ansi -Wshadow -Wno-long-long -Wnon-virtual-dtor +mac|darwin: { +} else { + QMAKE_CXXFLAGS += -Wc++0x-compat +} + + +LIBS += -L../../mimetypes -lQtMimeTypes + + +INCLUDEPATH += ../../../include/QtMimeTypes ../../../src/mimetypes + + +SOURCES += mimetypes.cpp + +# No headers + + +SOURCES += qdeclarativemimetype.cpp \ + qdeclarativemimedatabase.cpp + +HEADERS += qdeclarativemimetype_p.h \ + qdeclarativemimedatabase_p.h + + +qmldir.files += $$PWD/qmldir + + +INSTALLS += qmldir target diff --git a/src/imports/mimetypes/qdeclarativemimedatabase.cpp b/src/imports/mimetypes/qdeclarativemimedatabase.cpp new file mode 100644 index 0000000..d3bab15 --- /dev/null +++ b/src/imports/mimetypes/qdeclarativemimedatabase.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMimeTypes addon 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$ +** +****************************************************************************/ + +#include "qdeclarativemimedatabase_p.h" + +#include "qdeclarativemimetype_p.h" + +#include <QtCore/QDebug> + +// ------------------------------------------------------------------------------------------------ + +QDeclarativeMimeDatabase::QDeclarativeMimeDatabase(QObject *theParent) : + QObject(theParent), + m_MimeDatabase() +{} + +// ------------------------------------------------------------------------------------------------ + +QDeclarativeMimeDatabase::~QDeclarativeMimeDatabase() +{ + //qDebug() << Q_FUNC_INFO; +} + +// ------------------------------------------------------------------------------------------------ + +QMimeDatabase &QDeclarativeMimeDatabase::mimeDatabase() +{ + return m_MimeDatabase; +} + +// ------------------------------------------------------------------------------------------------ + +QVariantList QDeclarativeMimeDatabase::mimeTypeNames() const +{ + QVariantList result; + + foreach (const QMimeType &mimeType, m_MimeDatabase.mimeTypes()) { + result << mimeType.name(); + } + + return result; +} + +// ------------------------------------------------------------------------------------------------ + +QDeclarativeMimeType *QDeclarativeMimeDatabase::mimeTypeForName ( + const QString &mimeTypeName + ) +{ + return new QDeclarativeMimeType ( + m_MimeDatabase.mimeTypeForName(mimeTypeName), + this // <- The new object will be released later + // when this registry is released. + ); +} + +// ------------------------------------------------------------------------------------------------ + +QDeclarativeMimeType *QDeclarativeMimeDatabase::findByName ( + const QString &fileName + ) +{ + return new QDeclarativeMimeType ( + m_MimeDatabase.findByName(fileName), + this // <- The new object will be released later + // when this registry is released. + ); +} + +// ------------------------------------------------------------------------------------------------ + +QDeclarativeMimeType *QDeclarativeMimeDatabase::findByFile ( + const QString &fileName + ) +{ + return new QDeclarativeMimeType ( + m_MimeDatabase.findByFile(fileName), + this // <- The new object will be released later + // when this registry is released. + ); +} diff --git a/src/imports/mimetypes/qdeclarativemimedatabase_p.h b/src/imports/mimetypes/qdeclarativemimedatabase_p.h new file mode 100644 index 0000000..e494f73 --- /dev/null +++ b/src/imports/mimetypes/qdeclarativemimedatabase_p.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMimeTypes addon 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$ +** +****************************************************************************/ + +#ifndef QT_DECLARATIVE_MIME_TYPE_REGISTRY_P_H_INCLUDED +#define QT_DECLARATIVE_MIME_TYPE_REGISTRY_P_H_INCLUDED + +#include "qmimedatabase.h" + +#include <QtDeclarative/qdeclarative.h> + +#include <QtCore/QObject> + +class QDeclarativeMimeType; + +// ------------------------------------------------------------------------------------------------ + +class QDeclarativeMimeDatabase : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QVariantList mimeTypeNames + READ mimeTypeNames + STORED false) + +protected: + // We keep this destructor with its default value of 0 protected since only + // QDeclarativePrivate::QDeclarativeElement<T> needs it: + QDeclarativeMimeDatabase(QObject *theParent = 0); + +public: + ~QDeclarativeMimeDatabase(); + + QMimeDatabase &mimeDatabase(); + + // -------------------------------------------------------------------------------------------- + + QVariantList mimeTypeNames() const; + + Q_INVOKABLE QDeclarativeMimeType *mimeTypeForName ( + const QString &mimeTypeName + ); + + // -------------------------------------------------------------------------------------------- + + Q_INVOKABLE QDeclarativeMimeType *findByName ( + const QString &fileName + ); + + // -------------------------------------------------------------------------------------------- + + Q_INVOKABLE QDeclarativeMimeType *findByFile ( + const QString &fileName + ); + + // -------------------------------------------------------------------------------------------- + +private: + QMimeDatabase m_MimeDatabase; +}; + +QML_DECLARE_TYPE(QDeclarativeMimeDatabase) + +#endif // QT_DECLARATIVE_MIME_TYPE_REGISTRY_P_H_INCLUDED diff --git a/src/imports/mimetypes/qdeclarativemimetype.cpp b/src/imports/mimetypes/qdeclarativemimetype.cpp new file mode 100644 index 0000000..4e66629 --- /dev/null +++ b/src/imports/mimetypes/qdeclarativemimetype.cpp @@ -0,0 +1,208 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMimeTypes addon 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$ +** +****************************************************************************/ + +#include "qdeclarativemimetype_p.h" + +#include "qmimetype_p.h" + +#include <QtCore/QDebug> + +// ------------------------------------------------------------------------------------------------ + +QDeclarativeMimeType::QDeclarativeMimeType(QObject *theParent) : + QObject(theParent), + m_MimeType() +{} + +// ------------------------------------------------------------------------------------------------ + +QDeclarativeMimeType::QDeclarativeMimeType(const QMimeType &other, QObject *theParent) : + QObject(theParent), + m_MimeType(other) +{} + +// ------------------------------------------------------------------------------------------------ + +QDeclarativeMimeType::~QDeclarativeMimeType() +{ + //qDebug() << Q_FUNC_INFO << "name():" << name(); +} + +// ------------------------------------------------------------------------------------------------ + +void QDeclarativeMimeType::assign(QDeclarativeMimeType *other) +{ + if (other == 0) { + qWarning() << Q_FUNC_INFO << "other:" << other; + return; + } + + m_MimeType = other->m_MimeType; +} + +// ------------------------------------------------------------------------------------------------ + +bool QDeclarativeMimeType::equals(QDeclarativeMimeType *other) const +{ + if (other == 0) { + qWarning() << Q_FUNC_INFO << "other:" << other; + return false; + } + + return m_MimeType == other->m_MimeType; +} + +// ------------------------------------------------------------------------------------------------ + +QMimeType QDeclarativeMimeType::mimeType() const +{ + return m_MimeType; +} + +// ------------------------------------------------------------------------------------------------ + +bool QDeclarativeMimeType::isValid() const +{ + return m_MimeType.isValid(); +} + +// ------------------------------------------------------------------------------------------------ + +const QString &QDeclarativeMimeType::name() const +{ + return m_MimeType.name(); +} + +// ------------------------------------------------------------------------------------------------ + +static QMimeType buildMimeType ( + const QString &name, + const QString &comment, + const QString &genericIconName, + const QStringList &suffixes + ) +{ + QMimeTypeData mimeTypeData; + mimeTypeData.name = name; + mimeTypeData.comment = comment; + mimeTypeData.genericIconName = genericIconName; + mimeTypeData.suffixes = suffixes; + return QMimeType(mimeTypeData); +} + +// ------------------------------------------------------------------------------------------------ + +void QDeclarativeMimeType::setName(const QString &newName) +{ + m_MimeType = buildMimeType(newName, m_MimeType.comment(), m_MimeType.genericIconName(), m_MimeType.suffixes()); +} + +// ------------------------------------------------------------------------------------------------ + +const QString &QDeclarativeMimeType::comment() const +{ + return m_MimeType.comment(); +} + +// ------------------------------------------------------------------------------------------------ + +void QDeclarativeMimeType::setComment(const QString &newComment) +{ + m_MimeType = buildMimeType(m_MimeType.name(), newComment, m_MimeType.genericIconName(), m_MimeType.suffixes()); +} + +// ------------------------------------------------------------------------------------------------ + +const QString &QDeclarativeMimeType::genericIconName() const +{ + return m_MimeType.genericIconName(); +} + +// ------------------------------------------------------------------------------------------------ + +void QDeclarativeMimeType::setGenericIconName(const QString &newGenericIconName) +{ + m_MimeType = buildMimeType(m_MimeType.name(), m_MimeType.comment(), newGenericIconName, m_MimeType.suffixes()); +} + +// ------------------------------------------------------------------------------------------------ + +QVariantList QDeclarativeMimeType::globPatterns() const +{ + QVariantList result; + + foreach (const QString &pattern, m_MimeType.globPatterns()) { + result << pattern; + } + + return result; +} + +// ------------------------------------------------------------------------------------------------ + +QVariantList QDeclarativeMimeType::suffixes() const +{ + QVariantList result; + + foreach (const QString &suffix, m_MimeType.suffixes()) { + result << suffix; + } + + return result; +} + +// ------------------------------------------------------------------------------------------------ + +void QDeclarativeMimeType::setSuffixes(const QVariantList &newSuffixes) +{ + QList<QString> result; + + foreach (const QVariant &newSuffix, newSuffixes) { + if (newSuffix.type() != QVariant::String) { + qWarning() << Q_FUNC_INFO << "newSuffix" << newSuffix << " is not a string!"; + continue; + } + + result << newSuffix.toString(); + } + + m_MimeType = buildMimeType(m_MimeType.name(), m_MimeType.comment(), m_MimeType.genericIconName(), result); +} diff --git a/src/imports/mimetypes/qdeclarativemimetype_p.h b/src/imports/mimetypes/qdeclarativemimetype_p.h new file mode 100644 index 0000000..a136dd8 --- /dev/null +++ b/src/imports/mimetypes/qdeclarativemimetype_p.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMimeTypes addon 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVE_MIME_TYPE_P_H_INCLUDED +#define DECLARATIVE_MIME_TYPE_P_H_INCLUDED + +#include "qmimetype.h" + +#include <QtDeclarative/qdeclarative.h> + +#include <QtCore/QObject> + +// ------------------------------------------------------------------------------------------------ + +class QDeclarativeMimeType : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name + READ name + WRITE setName) + + Q_PROPERTY(QString comment + READ comment + WRITE setComment) + + Q_PROPERTY(QString genericIconName + READ genericIconName + WRITE setGenericIconName) + + Q_PROPERTY(QVariantList globPatterns + READ globPatterns + STORED false) + + Q_PROPERTY(QVariantList suffixes + READ suffixes + WRITE setSuffixes + STORED false) + + Q_PROPERTY(bool isValid + READ isValid + STORED false) + +protected: + // We keep this destructor with its default value of 0 protected since only + // QDeclarativePrivate::QDeclarativeElement<T> needs it: + QDeclarativeMimeType(QObject *theParent = 0); + +public: + // We don't allow theParent to have a default value of 0 because in all + // likelyhood we want to force the caller to specify its QObject so the + // object will get destroyed in the caller's destructor: + QDeclarativeMimeType(const QMimeType &other, QObject *theParent); + + ~QDeclarativeMimeType(); + + Q_INVOKABLE void assign(QDeclarativeMimeType *other); + Q_INVOKABLE bool equals(QDeclarativeMimeType *other) const; + + QMimeType mimeType() const; + + bool isValid() const; + + const QString &name() const; + void setName(const QString &newName); + const QString &comment() const; + void setComment(const QString &newComment); + const QString &genericIconName() const; + void setGenericIconName(const QString &newGenericIconName); + QVariantList globPatterns() const; + QVariantList suffixes() const; + void setSuffixes(const QVariantList &newSuffixes); + +private: + QMimeType m_MimeType; +}; + +QML_DECLARE_TYPE(QDeclarativeMimeType) + +#endif diff --git a/src/imports/mimetypes/qmldir b/src/imports/mimetypes/qmldir new file mode 100644 index 0000000..a8d4763 --- /dev/null +++ b/src/imports/mimetypes/qmldir @@ -0,0 +1 @@ +plugin declarative_mimetypes diff --git a/src/src.pro b/src/src.pro index 9a845c3..a2e5f2f 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += mimetypes # imports +SUBDIRS += mimetypes imports diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index e0f7a82..e76a577 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -2,4 +2,6 @@ TEMPLATE = subdirs SUBDIRS += \ qmimetype \ - qmimedatabase + qmimedatabase \ + qdeclarativemimetype \ + qdeclarativemimedatabase diff --git a/tests/auto/qdeclarativemimedatabase/qdeclarativemimedatabase.pro b/tests/auto/qdeclarativemimedatabase/qdeclarativemimedatabase.pro new file mode 100644 index 0000000..921aaaf --- /dev/null +++ b/tests/auto/qdeclarativemimedatabase/qdeclarativemimedatabase.pro @@ -0,0 +1,17 @@ +TEMPLATE=app +TARGET=tst_qdeclarativemimedatabase +#CONFIG += warn_on qmltestcase +QT += qmltest + +# runtime environment +LIBS += -L../../../src/mimetypes -lQtMimeTypes + + +INCLUDEPATH += ../../../includes/QtMimeTypes ../../../src/mimetypes + + +SOURCES += tst_qdeclarativemimedatabase.cpp + + +# this reads the QML files from the same directory as this pro file +DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" diff --git a/tests/auto/qdeclarativemimedatabase/testdata_list.js b/tests/auto/qdeclarativemimedatabase/testdata_list.js new file mode 100644 index 0000000..42be544 --- /dev/null +++ b/tests/auto/qdeclarativemimedatabase/testdata_list.js @@ -0,0 +1,209 @@ +function list() { + return [ + { filePath: "../qmimedatabase/testfiles/test.bmp", mimeType: "image/bmp", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.cel", mimeType: "image/x-cel", xFail: "xxx" } + , { filePath: "../qmimedatabase/testfiles/test.dcm", mimeType: "application/dicom", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.eps", mimeType: "image/x-eps", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/GammaChart.exr", mimeType: "image/x-exr", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.fit", mimeType: "image/fits", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/test.fli", mimeType: "video/x-flic", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.gif", mimeType: "image/gif", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.ico", mimeType: "image/vnd.microsoft.icon", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.im1", mimeType: "image/x-sun-raster", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/test.jp2", mimeType: "image/jp2", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.jpg", mimeType: "image/jpeg", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.jpc", mimeType: "image/jp2", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.mng", mimeType: "video/x-mng", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.pat", mimeType: "image/x-pat", xFail: "xxx" } + , { filePath: "../qmimedatabase/testfiles/test.pbm", mimeType: "image/x-portable-bitmap", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.pcx", mimeType: "image/x-pcx", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.pgm", mimeType: "image/x-portable-graymap", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.pix", mimeType: "image/x-pix", xFail: "xxx" } + , { filePath: "../qmimedatabase/testfiles/test.png", mimeType: "image/png", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.ppm", mimeType: "image/x-portable-pixmap", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test2.ppm", mimeType: "image/x-portable-pixmap", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.ps", mimeType: "application/postscript", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.psd", mimeType: "image/vnd.adobe.photoshop", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.sgi", mimeType: "image/x-sgi", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.tga", mimeType: "image/x-tga", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.tif", mimeType: "image/tiff", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.xbm", mimeType: "image/x-xbitmap", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.xcf", mimeType: "image/x-xcf", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.xpm", mimeType: "image/x-xpixmap", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.xwd", mimeType: "image/x-xwindowdump", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/2001_compression_overview.djvu", mimeType: "image/vnd.djvu", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.kdc", mimeType: "image/x-kodak-kdc", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/bathead.sk", mimeType: "image/x-skencil", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/jc-win.ani", mimeType: "application/x-navi-animation", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/aero_alt.cur", mimeType: "image/x-win-bitmap", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/mypaint.ora", mimeType: "image/openraster", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.xml.in", mimeType: "application/xml", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/dia.shape", mimeType: "application/x-dia-shape", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/attachment.tif", mimeType: "image/jpeg", xFail: "xox" } + , { filePath: "../qmimedatabase/testfiles/panasonic_lumix_dmc_fz38_05.rw2", mimeType: "image/x-panasonic-raw2", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo-6.0.doc", mimeType: "application/msword", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo-95.doc", mimeType: "application/msword", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo.doc", mimeType: "application/msword", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo.rtf", mimeType: "application/rtf", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo.sdw", mimeType: "application/vnd.stardivision.writer", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo.stw", mimeType: "application/vnd.sun.xml.writer.template", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/ooo.sxw", mimeType: "application/vnd.sun.xml.writer", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/ooo.vor", mimeType: "application/vnd.stardivision.writer", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo-xp.doc", mimeType: "application/msword", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/office.doc", mimeType: "application/msword", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo-test.odg", mimeType: "application/vnd.oasis.opendocument.graphics", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo-test.odp", mimeType: "application/vnd.oasis.opendocument.presentation", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo-test.ods", mimeType: "application/vnd.oasis.opendocument.spreadsheet", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo-test.odt", mimeType: "application/vnd.oasis.opendocument.text", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ooo-test.fodg", mimeType: "application/vnd.oasis.opendocument.graphics-flat-xml", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/ooo-test.fodp", mimeType: "application/vnd.oasis.opendocument.presentation-flat-xml", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/ooo-test.fods", mimeType: "application/vnd.oasis.opendocument.spreadsheet-flat-xml", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/ooo-test.fodt", mimeType: "application/vnd.oasis.opendocument.text-flat-xml", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/foo.doc", mimeType: "application/msword", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test-template.dot", mimeType: "application/msword-template", xFail: "oxx" } + , { filePath: "../qmimedatabase/testfiles/ocf10-20060911.epub", mimeType: "application/epub+zip", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.wps", mimeType: "application/vnd.ms-works", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/sample.docx", mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", xFail: "oxo" } + , { filePath: "../qmimedatabase/testfiles/sample.xlsx", mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", xFail: "oxo" } + , { filePath: "../qmimedatabase/testfiles/sample.pptx", mimeType: "application/vnd.openxmlformats-officedocument.presentationml.presentation", xFail: "oxo" } + , { filePath: "../qmimedatabase/testfiles/sample.ppsx", mimeType: "application/vnd.openxmlformats-officedocument.presentationml.slideshow", xFail: "oxo" } + , { filePath: "../qmimedatabase/testfiles/pocket-word.psw", mimeType: "application/x-pocket-word", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/aportis.pdb", mimeType: "application/x-aportisdoc", xFail: "oox" } + , { filePath: "../qmimedatabase/testfiles/internet.ez", mimeType: "application/andrew-inset", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/Anaphraseus-1.21-beta.oxt", mimeType: "application/vnd.openofficeorg.extension", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/petite-ouverture-a-danser.ly", mimeType: "text/x-lilypond", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/sqlite2.kexi", mimeType: "application/x-kexiproject-sqlite2", xFail: "oxx" } + , { filePath: "../qmimedatabase/testfiles/sqlite3.kexi", mimeType: "application/x-kexiproject-sqlite3", xFail: "xxo" } + , { filePath: "../qmimedatabase/testfiles/combined.karbon", mimeType: "application/x-karbon", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/Empty.chrt", mimeType: "application/x-kchart", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/layersupdatesignals.flw", mimeType: "application/x-kivio", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/Presentation.kpt", mimeType: "application/x-kpresenter", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/testcases.ksp", mimeType: "application/x-kspread", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test-kounavail2.kwd", mimeType: "application/x-kword", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/white_640x480.kra", mimeType: "application/x-krita", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/stream.nsc", mimeType: "application/x-netshow-channel", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/stream.sdp", mimeType: "application/sdp", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/playlist.asx", mimeType: "audio/x-ms-asx", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/feed.rss", mimeType: "application/rss+xml", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/feed2", mimeType: "application/rss+xml", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/560051.xml", mimeType: "application/rss+xml", xFail: "xxx" } + , { filePath: "../qmimedatabase/testfiles/feed.atom", mimeType: "application/atom+xml", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/feeds.opml", mimeType: "text/x-opml+xml", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/subtitle.srt", mimeType: "application/x-subrip", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/subtitle.smi", mimeType: "application/x-sami", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/subtitle-microdvd.sub", mimeType: "text/x-microdvd", xFail: "oox" } + , { filePath: "../qmimedatabase/testfiles/subtitle-mpsub.sub", mimeType: "text/x-mpsub", xFail: "xox" } + , { filePath: "../qmimedatabase/testfiles/subtitle.ssa", mimeType: "text/x-ssa", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/subtitle-subviewer.sub", mimeType: "text/x-subviewer", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/ringtone.ime", mimeType: "text/x-iMelody", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ringtone.mmf", mimeType: "application/x-smaf", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/playlist.mrl", mimeType: "text/x-mrml", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/hbo-playlist.qtl", mimeType: "application/x-quicktime-media-link", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/playlist.wpl", mimeType: "application/vnd.ms-wpl", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.flac", mimeType: "audio/flac", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/live-streaming.m3u", mimeType: "application/vnd.apple.mpegurl", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/all_w.m3u8", mimeType: "application/vnd.apple.mpegurl", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/text-iso8859-15.txt", mimeType: "text/plain", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/text-utf8.txt", mimeType: "text/plain", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.tex", mimeType: "text/x-tex", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/registry.reg", mimeType: "text/x-ms-regedit", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/registry-nt.reg", mimeType: "text/x-ms-regedit", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.ext,v", mimeType: "text/plain", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.fl", mimeType: "application/x-fluid", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/helloworld.java", mimeType: "text/x-java", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/survey.js", mimeType: "application/javascript", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.cs", mimeType: "text/x-csharp", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.dot", mimeType: "text/vnd.graphviz", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/test.vala", mimeType: "text/x-vala", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.ooc", mimeType: "text/x-ooc", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.mof", mimeType: "text/x-mof", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test-cdda.toc", mimeType: "application/x-cdrdao-toc", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test-cdrom.toc", mimeType: "application/x-cdrdao-toc", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.iptables", mimeType: "text/x-iptables", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test-vpn.pcf", mimeType: "application/x-cisco-vpn-settings", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/test.php", mimeType: "application/x-php", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/evolution.eml", mimeType: "application/mbox", xFail: "xox" } + , { filePath: "../qmimedatabase/testfiles/tb-from-sentbox.eml", mimeType: "message/rfc822", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/tb-saved.eml", mimeType: "message/rfc822", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.url", mimeType: "application/x-mswinurl", xFail: "xox" } + , { filePath: "../qmimedatabase/testfiles/test.d", mimeType: "text/x-dsrc", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.v", mimeType: "text/x-verilog", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.sv", mimeType: "text/x-svsrc", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.svh", mimeType: "text/x-svhdr", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.manifest", mimeType: "text/cache-manifest", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.yaml", mimeType: "application/x-yaml", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/mysum.m", mimeType: "text/x-matlab", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/isdir.m", mimeType: "text/x-matlab", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/bibtex.bib", mimeType: "text/x-bibtex", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/simple-obj-c.m", mimeType: "text/x-objcsrc", xFail: "oox" } + , { filePath: "../qmimedatabase/testfiles/ssh-public-key.txt", mimeType: "text/plain", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.vcf", mimeType: "text/directory", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.go", mimeType: "text/x-go", xFail: "oxo" } + , { filePath: "../qmimedatabase/testfiles/test.ttx", mimeType: "application/x-font-ttx", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/project.glade", mimeType: "application/x-glade", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ISOcyr1.ent", mimeType: "application/xml-external-parsed-entity", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.metalink", mimeType: "application/metalink+xml", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.mml", mimeType: "application/mathml+xml", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/linguist.ts", mimeType: "text/vnd.trolltech.linguist", xFail: "oox" } + , { filePath: "../qmimedatabase/testfiles/test.xsl", mimeType: "application/xslt+xml", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.cbl", mimeType: "text/x-cobol", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.alz", mimeType: "application/x-alz", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.class", mimeType: "application/x-java", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/hello.pack", mimeType: "application/x-java-pack200", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.msi", mimeType: "application/x-msi", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/archive.7z", mimeType: "application/x-7z-compressed", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/comics.cb7", mimeType: "application/x-cb7", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/archive.tar", mimeType: "application/x-tar", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/comics.cbt", mimeType: "application/x-cbt", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/copying.cab", mimeType: "application/vnd.ms-cab-compressed", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/archive.gz", mimeType: "application/x-gzip", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/archive.tar.gz", mimeType: "application/x-compressed-tar", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/good-1-delta-lzma2.tiff.xz", mimeType: "application/x-xz", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/spinboxes-0.1.1-Linux.tar.xz", mimeType: "application/x-xz-compressed-tar", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.lz", mimeType: "application/x-lzip", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.lzo", mimeType: "application/x-lzop", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/archive.lrz", mimeType: "application/x-lrzip", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/fuji.themepack", mimeType: "application/x-windows-themepack", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/helloworld.xpi", mimeType: "application/x-xpinstall", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.wim", mimeType: "application/x-ms-wim", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.wav", mimeType: "audio/x-wav", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.avi", mimeType: "video/x-msvideo", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/hereyes_remake.mo3", mimeType: "audio/x-mo3", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/ccfilm.axv", mimeType: "video/annodex", xFail: "oxo" } + , { filePath: "../qmimedatabase/testfiles/ccfilm.axv", mimeType: "application/annodex", xFail: "xxx" } + , { filePath: "../qmimedatabase/testfiles/test.ogg", mimeType: "audio/ogg", xFail: "oxx" } + , { filePath: "../qmimedatabase/testfiles/test.ogg", mimeType: "audio/x-vorbis+ogg", xFail: "x" } + , { filePath: "../qmimedatabase/testfiles/msg0001.gsm", mimeType: "audio/x-gsm", xFail: "oxo" } + , { filePath: "../qmimedatabase/testfiles/small_wav.mxf", mimeType: "application/mxf", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/Elephants_Dream-360p-Stereo.webm", mimeType: "video/webm", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/settopbox.ts", mimeType: "video/mp2t", xFail: "xx" } + , { filePath: "../qmimedatabase/testfiles/bbc.ram", mimeType: "application/ram", xFail: "oxo" } + , { filePath: "../qmimedatabase/testfiles/bbc.ram", mimeType: "application/vnd.rn-realmedia", xFail: "xox" } + , { filePath: "../qmimedatabase/testfiles/text.pdf", mimeType: "application/pdf", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/README.pdf", mimeType: "application/pdf", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/testcase.is-really-a-pdf", mimeType: "application/pdf", xFail: "xo" } + , { filePath: "../qmimedatabase/testfiles/test.pdf.xz", mimeType: "application/x-xzpdf", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/Makefile", mimeType: "text/x-makefile", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/Makefile.gnu", mimeType: "text/x-makefile", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/googleearth.kml", mimeType: "application/vnd.google-earth.kml+xml", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.gnd", mimeType: "application/gnunet-directory", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/text.ps", mimeType: "application/postscript", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/text.ps.gz", mimeType: "application/x-gzpostscript", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/text.PS.gz", mimeType: "application/x-gzpostscript", xFail: "oxo" } + , { filePath: "../qmimedatabase/testfiles/test.cmake", mimeType: "text/x-cmake", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/bluerect.mdi", mimeType: "image/vnd.ms-modi", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/Stallman_Richard_-_The_GNU_Manifesto.fb2", mimeType: "application/x-fictionbook+xml", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.p7b", mimeType: "application/x-pkcs7-certificates", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.pkipath", mimeType: "application/pkix-pkipath", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/test.jks", mimeType: "application/x-java-keystore", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.jceks", mimeType: "application/x-java-jce-keystore", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.sav", mimeType: "application/x-spss-sav", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.por", mimeType: "application/x-spss-por", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/core", mimeType: "application/x-core", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/bluish.icc", mimeType: "application/vnd.iccprofile", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.it87", mimeType: "application/x-it87", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.hdf4", mimeType: "application/x-hdf", xFail: "" } + , { filePath: "../qmimedatabase/testfiles/test.h5", mimeType: "application/x-hdf", xFail: "ox" } + , { filePath: "../qmimedatabase/testfiles/without_an_extension", mimeType: "image/vnd.djvu", xFail: "x" } + ] +} diff --git a/tests/auto/qdeclarativemimedatabase/tst_qdeclarativemimedatabase.cpp b/tests/auto/qdeclarativemimedatabase/tst_qdeclarativemimedatabase.cpp new file mode 100644 index 0000000..4479743 --- /dev/null +++ b/tests/auto/qdeclarativemimedatabase/tst_qdeclarativemimedatabase.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMimeTypes addon 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$ +** +****************************************************************************/ + +#include <QtQuickTest/quicktest.h> + +QUICK_TEST_MAIN(mytest) diff --git a/tests/auto/qdeclarativemimedatabase/tst_qdeclarativemimedatabase.qml b/tests/auto/qdeclarativemimedatabase/tst_qdeclarativemimedatabase.qml new file mode 100644 index 0000000..9515c8c --- /dev/null +++ b/tests/auto/qdeclarativemimedatabase/tst_qdeclarativemimedatabase.qml @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMimeTypes addon 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$ +** +****************************************************************************/ + +import Qt 4.7 +import QtTest 1.0 +import QtMimeTypes 1.0 + +import "testdata_list.js" as TestData + +TestCase { + name: "tst_QDeclarativeMimedatabase" + + function pngMimeTypeName() { + return "image/png" + } + + function pngMimeTypeComment() { + return "PNG File"; + } + + function pngMimeTypeGenericIconName() { + return "/usr/share/icons/oxygen/64x64/mimetypes/image-x-generic.png" + } + + function firstPngMimeTypeSuffixes() { + return ".png" + } + + MimeType { + id: instantiatedPngMimeType + name: pngMimeTypeName() + comment: pngMimeTypeComment() + genericIconName: pngMimeTypeGenericIconName() + suffixes: [ firstPngMimeTypeSuffixes() ] + } + + MimeType { + id: otherPngMimeType + } + + function test_name() { + otherPngMimeType.assign(instantiatedPngMimeType) + otherPngMimeType.name = "" + + // Verify that the Id is part of the equality test: + compare(instantiatedPngMimeType.name, pngMimeTypeName()) + + compare(instantiatedPngMimeType.equals(otherPngMimeType), false) + } + + MimeDatabase { + id: database + } + + function list() { + return TestData.list() +// return [ +// { filePath: "test.bmp", mimeType: "image/bmp", xFail: "" }, +// { filePath: "archive.tar.gz", mimeType: "application/x-compressed-tar", xFail: "ox" } +// ] + } + + function listValue(ix) { + return list()[ix] + } + + function fileInfoSuffix(fileName) + { + var foundSuffix = ""; + + var mimeTypeNames = database.mimeTypeNames + for (var mimeTypeIx = 0; mimeTypeIx < mimeTypeNames.length; ++mimeTypeIx) { + var suffixes = database.mimeTypeForName(mimeTypeNames[mimeTypeIx]).suffixes + //print(mimeTypeNames[mimeTypeIx], suffixes.length) + for (var suffixIx = 0; suffixIx < suffixes.length; ++suffixIx) { + var suffix = suffixes[suffixIx] + //print(mimeTypeNames[mimeTypeIx], '*.' + suffix, suffix.length, '*.' + foundSuffix, foundSuffix.length) + if (fileName.length >= suffix.length + 1 && suffix.length > foundSuffix.length) { + if (fileName.slice(-(suffix.length + 1)) == '.' + suffix) { + //print(mimeTypeNames[mimeTypeIx], '*.' + suffix) + foundSuffix = suffix + } + } + } + } + + return foundSuffix + } + + function listContains(stringList, searchString) + { + // TODO sort the list and perform binary search! + for (var stringListIx = 0; stringListIx < stringList.length; ++stringListIx) { + if (stringList[stringListIx] == searchString) { + return true + } + } + + return false; + } + + function test_findByName() { + var ok = 0 + + for (var listIx = 0; listIx < list().length; ++listIx) { + //print(listValue(listIx).filePath) + + var resultMimeTypeName = database.findByName(listValue(listIx).filePath).name + //print("findByName(" + listValue(listIx).filePath + ") returned", resultMimeTypeName) + + // Results are ambiguous when multiple MIME types have the same glob + // -> accept the current result if the found MIME type actually + // matches the file's extension. + var foundMimeType = database.mimeTypeForName(resultMimeTypeName); + var extension = fileInfoSuffix(listValue(listIx).filePath); + //print("findNameSuffix() returned", extension) + //print("globPatterns:", foundMimeType.globPatterns, "- extension:", "*." + extension) + if (listContains(foundMimeType.globPatterns, "*." + extension)) { + ok = ok + 1 + continue; + } + + // Expected to fail + if (listValue(listIx).xFail.length >= 1 && listValue(listIx).xFail[0] == "x") { + if (resultMimeTypeName != listValue(listIx).mimeType) { + ok = ok + 1 + } + else { + print("Error:", listValue(listIx).filePath, "has xFail[0] == \"x\" but has a correct resultMimeTypeName") + } + } + else { + if (resultMimeTypeName == listValue(listIx).mimeType) { + ok = ok + 1 + } + else { + print("Error:", listValue(listIx).filePath, "has been identified incorrectly as", resultMimeTypeName) + } + } + } + + compare(ok, list().length) + } + + function test_findByFile() { + var ok = 0 + + for (var listIx = 0; listIx < list().length; ++listIx) { + //print(listValue(listIx).filePath) + + var resultMimeTypeName = database.findByFile(listValue(listIx).filePath).name + //print("findByFile(" + listValue(listIx).filePath + ") returned", resultMimeTypeName) + + // Expected to fail + if (listValue(listIx).xFail.length >= 3 && listValue(listIx).xFail[2] == "x") { + if (resultMimeTypeName != listValue(listIx).mimeType) { + ok = ok + 1 + } + else { + print("Error:", listValue(listIx).filePath, "has xFail[2] == \"x\" but has a correct resultMimeTypeName") + } + } + else { + if (resultMimeTypeName == listValue(listIx).mimeType) { + ok = ok + 1 + } + else { + print("Error:", listValue(listIx).filePath, "has been identified incorrectly as", resultMimeTypeName, listValue(listIx).xFail.length, listValue(listIx).xFail[2]) + } + } + } + + compare(ok, list().length) + } +} diff --git a/tests/auto/qdeclarativemimetype/qdeclarativemimetype.pro b/tests/auto/qdeclarativemimetype/qdeclarativemimetype.pro new file mode 100644 index 0000000..2e8052b --- /dev/null +++ b/tests/auto/qdeclarativemimetype/qdeclarativemimetype.pro @@ -0,0 +1,17 @@ +TEMPLATE=app +TARGET=tst_qdeclarativemimetype +#CONFIG += warn_on qmltestcase +QT += qmltest + +# runtime environment +LIBS += -L../../../src/mimetypes -lQtMimeTypes + + +INCLUDEPATH += ../../../includes/QtMimeTypes ../../../src/mimetypes + + +SOURCES += tst_qdeclarativemimetype.cpp + + +# this reads the QML files from the same directory as this pro file +DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" diff --git a/tests/auto/qdeclarativemimetype/tst_qdeclarativemimetype.cpp b/tests/auto/qdeclarativemimetype/tst_qdeclarativemimetype.cpp new file mode 100644 index 0000000..4479743 --- /dev/null +++ b/tests/auto/qdeclarativemimetype/tst_qdeclarativemimetype.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMimeTypes addon 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$ +** +****************************************************************************/ + +#include <QtQuickTest/quicktest.h> + +QUICK_TEST_MAIN(mytest) diff --git a/tests/auto/qdeclarativemimetype/tst_qdeclarativemimetype.qml b/tests/auto/qdeclarativemimetype/tst_qdeclarativemimetype.qml new file mode 100644 index 0000000..c365646 --- /dev/null +++ b/tests/auto/qdeclarativemimetype/tst_qdeclarativemimetype.qml @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMimeTypes addon 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$ +** +****************************************************************************/ + +import Qt 4.7 +import QtTest 1.0 +import QtMimeTypes 1.0 + +TestCase { + name: "tst_QDeclarativeMimetype" + + function pngMimeTypeName() { + return "image/png" + } + + function pngMimeTypeComment() { + return "PNG File"; + } + + function pngMimeTypeGenericIconName() { + return "/usr/share/icons/oxygen/64x64/mimetypes/image-x-generic.png" + } + + function firstPngMimeTypeSuffixes() { + return ".png" + } + + MimeType { + id: instantiatedPngMimeType + name: pngMimeTypeName() + comment: pngMimeTypeComment() + genericIconName: pngMimeTypeGenericIconName() + suffixes: [ firstPngMimeTypeSuffixes() ] + } + + MimeType { + id: otherPngMimeType + } + + MimeType { + id: defaultMimeType + } + + function test_isValid() { + compare(instantiatedPngMimeType.isValid, true) + + otherPngMimeType.assign(instantiatedPngMimeType) + + compare(otherPngMimeType.isValid, true) + compare(instantiatedPngMimeType.equals(otherPngMimeType), true) + compare(otherPngMimeType.equals(instantiatedPngMimeType), true) + + compare(defaultMimeType.isValid, false) + } + + function test_name() { + otherPngMimeType.assign(instantiatedPngMimeType) + otherPngMimeType.name = "" + + // Verify that the Id is part of the equality test: + compare(instantiatedPngMimeType.name, pngMimeTypeName()) + + compare(instantiatedPngMimeType.equals(otherPngMimeType), false) + } + + function test_comment() { + otherPngMimeType.assign(instantiatedPngMimeType) + otherPngMimeType.comment = "" + + // Verify that the Id is part of the equality test: + compare(instantiatedPngMimeType.comment, pngMimeTypeComment()) + + compare(instantiatedPngMimeType.equals(otherPngMimeType), false) + } + + function test_genericIconName() { + otherPngMimeType.assign(instantiatedPngMimeType) + otherPngMimeType.genericIconName = "" + + // Verify that the Id is part of the equality test: + compare(instantiatedPngMimeType.genericIconName, pngMimeTypeGenericIconName()) + + compare(instantiatedPngMimeType.equals(otherPngMimeType), false) + } + + function test_suffixes() { + otherPngMimeType.assign(instantiatedPngMimeType) + otherPngMimeType.suffixes = [] + compare(otherPngMimeType.suffixes.length, 0) + + // Verify that the Id is part of the equality test: + compare(instantiatedPngMimeType.suffixes.length, 1) + compare(instantiatedPngMimeType.suffixes[0], ".png") + + compare(instantiatedPngMimeType.equals(otherPngMimeType), false) + } +} |