Initial copy of QtMultimediaKit.
Comes from original repo, with SHA1: 2c82d5611655e5967f5c5095af50c0991c4378b2
This commit is contained in:
77
tests/auto/qmediaobject/main.cpp
Normal file
77
tests/auto/qmediaobject/main.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $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 <QtCore/qcoreapplication.h>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "tst_qmediaobject.h"
|
||||
#ifdef Q_OS_SYMBIAN
|
||||
#include "tst_qmediaobject_xa.h"
|
||||
#include "tst_qmediaobject_mmf.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
QApplication app(argc,argv);
|
||||
int ret;
|
||||
tst_QMediaObject test_api;
|
||||
ret = QTest::qExec(&test_api, argc, argv);
|
||||
#ifdef Q_OS_SYMBIAN
|
||||
char *new_argv[3];
|
||||
QString str = "C:\\data\\" + QFileInfo(QCoreApplication::applicationFilePath()).baseName() + "_xa.log";
|
||||
QByteArray bytes = str.toAscii();
|
||||
char arg1[] = "-o";
|
||||
new_argv[0] = argv[0];
|
||||
new_argv[1] = arg1;
|
||||
new_argv[2] = bytes.data();
|
||||
tst_QMetadata_xa test_xa;
|
||||
ret = QTest::qExec(&test_xa, 3, new_argv);
|
||||
char *new_argv1[3];
|
||||
QString str1 = "C:\\data\\" + QFileInfo(QCoreApplication::applicationFilePath()).baseName() + "_s60.log";
|
||||
QByteArray bytes1 = str1.toAscii();
|
||||
char arg2[] = "-o";
|
||||
new_argv1[0] = argv[0];
|
||||
new_argv1[1] = arg2;
|
||||
new_argv1[2] = bytes1.data();
|
||||
tst_QMediaObject_mmf test_mmf;
|
||||
ret = QTest::qExec(&test_mmf, 3, new_argv1);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
27
tests/auto/qmediaobject/qmediaobject.pro
Normal file
27
tests/auto/qmediaobject/qmediaobject.pro
Normal file
@@ -0,0 +1,27 @@
|
||||
load(qttest_p4)
|
||||
|
||||
QT += multimediakit-private
|
||||
|
||||
# TARGET = tst_qmediaobject
|
||||
# CONFIG += testcase
|
||||
|
||||
symbian {
|
||||
HEADERS += tst_qmediaobject_xa.h
|
||||
SOURCES += tst_qmediaobject_xa.cpp
|
||||
TARGET.CAPABILITY = ALL -TCB
|
||||
|
||||
testFiles.sources = testfiles/*
|
||||
testFiles.path = /Data/testfiles
|
||||
DEPLOYMENT += testFiles
|
||||
HEADERS += tst_qmediaobject_mmf.h
|
||||
SOURCES += tst_qmediaobject_mmf.cpp
|
||||
TARGET.CAPABILITY = ALL -TCB
|
||||
|
||||
testFiles.sources = testfiles/*
|
||||
testFiles.path = /Data/testfiles
|
||||
DEPLOYMENT += testFiles
|
||||
}
|
||||
|
||||
HEADERS+= tst_qmediaobject.h
|
||||
SOURCES += main.cpp tst_qmediaobject.cpp
|
||||
|
||||
359
tests/auto/qmediaobject/tst_qmediaobject.cpp
Normal file
359
tests/auto/qmediaobject/tst_qmediaobject.cpp
Normal file
@@ -0,0 +1,359 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $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/multimedia
|
||||
|
||||
#include "tst_qmediaobject.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
void tst_QMediaObject::propertyWatch()
|
||||
{
|
||||
QtTestMediaObject object;
|
||||
object.setNotifyInterval(0);
|
||||
|
||||
QEventLoop loop;
|
||||
connect(&object, SIGNAL(aChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
connect(&object, SIGNAL(bChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
connect(&object, SIGNAL(cChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
|
||||
QSignalSpy aSpy(&object, SIGNAL(aChanged(int)));
|
||||
QSignalSpy bSpy(&object, SIGNAL(bChanged(int)));
|
||||
QSignalSpy cSpy(&object, SIGNAL(cChanged(int)));
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(aSpy.count(), 0);
|
||||
QCOMPARE(bSpy.count(), 0);
|
||||
QCOMPARE(cSpy.count(), 0);
|
||||
|
||||
int aCount = 0;
|
||||
int bCount = 0;
|
||||
int cCount = 0;
|
||||
|
||||
object.addPropertyWatch("a");
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QVERIFY(aSpy.count() > aCount);
|
||||
QCOMPARE(bSpy.count(), 0);
|
||||
QCOMPARE(cSpy.count(), 0);
|
||||
QCOMPARE(aSpy.last().value(0).toInt(), 0);
|
||||
|
||||
aCount = aSpy.count();
|
||||
|
||||
object.setA(54);
|
||||
object.setB(342);
|
||||
object.setC(233);
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QVERIFY(aSpy.count() > aCount);
|
||||
QCOMPARE(bSpy.count(), 0);
|
||||
QCOMPARE(cSpy.count(), 0);
|
||||
QCOMPARE(aSpy.last().value(0).toInt(), 54);
|
||||
|
||||
aCount = aSpy.count();
|
||||
|
||||
object.addPropertyWatch("b");
|
||||
object.addPropertyWatch("d");
|
||||
object.removePropertyWatch("e");
|
||||
object.setA(43);
|
||||
object.setB(235);
|
||||
object.setC(90);
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QVERIFY(aSpy.count() > aCount);
|
||||
QVERIFY(bSpy.count() > bCount);
|
||||
QCOMPARE(cSpy.count(), 0);
|
||||
QCOMPARE(aSpy.last().value(0).toInt(), 43);
|
||||
QCOMPARE(bSpy.last().value(0).toInt(), 235);
|
||||
|
||||
aCount = aSpy.count();
|
||||
bCount = bSpy.count();
|
||||
|
||||
object.removePropertyWatch("a");
|
||||
object.addPropertyWatch("c");
|
||||
object.addPropertyWatch("e");
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(aSpy.count(), aCount);
|
||||
QVERIFY(bSpy.count() > bCount);
|
||||
QVERIFY(cSpy.count() > cCount);
|
||||
QCOMPARE(bSpy.last().value(0).toInt(), 235);
|
||||
QCOMPARE(cSpy.last().value(0).toInt(), 90);
|
||||
|
||||
bCount = bSpy.count();
|
||||
cCount = cSpy.count();
|
||||
|
||||
object.setA(435);
|
||||
object.setC(9845);
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(aSpy.count(), aCount);
|
||||
QVERIFY(bSpy.count() > bCount);
|
||||
QVERIFY(cSpy.count() > cCount);
|
||||
QCOMPARE(bSpy.last().value(0).toInt(), 235);
|
||||
QCOMPARE(cSpy.last().value(0).toInt(), 9845);
|
||||
|
||||
bCount = bSpy.count();
|
||||
cCount = cSpy.count();
|
||||
|
||||
object.setA(8432);
|
||||
object.setB(324);
|
||||
object.setC(443);
|
||||
object.removePropertyWatch("c");
|
||||
object.removePropertyWatch("d");
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(aSpy.count(), aCount);
|
||||
QVERIFY(bSpy.count() > bCount);
|
||||
QCOMPARE(cSpy.count(), cCount);
|
||||
QCOMPARE(bSpy.last().value(0).toInt(), 324);
|
||||
QCOMPARE(cSpy.last().value(0).toInt(), 9845);
|
||||
|
||||
bCount = bSpy.count();
|
||||
|
||||
object.removePropertyWatch("b");
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(aSpy.count(), aCount);
|
||||
QCOMPARE(bSpy.count(), bCount);
|
||||
QCOMPARE(cSpy.count(), cCount);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::setupNotifyTests()
|
||||
{
|
||||
QTest::addColumn<int>("interval");
|
||||
QTest::addColumn<int>("count");
|
||||
|
||||
QTest::newRow("single 750ms")
|
||||
<< 750
|
||||
<< 1;
|
||||
QTest::newRow("single 600ms")
|
||||
<< 600
|
||||
<< 1;
|
||||
QTest::newRow("x3 300ms")
|
||||
<< 300
|
||||
<< 3;
|
||||
QTest::newRow("x5 180ms")
|
||||
<< 180
|
||||
<< 5;
|
||||
}
|
||||
|
||||
void tst_QMediaObject::notifySignals_data()
|
||||
{
|
||||
setupNotifyTests();
|
||||
}
|
||||
|
||||
void tst_QMediaObject::notifySignals()
|
||||
{
|
||||
QFETCH(int, interval);
|
||||
QFETCH(int, count);
|
||||
|
||||
QtTestMediaObject object;
|
||||
object.setNotifyInterval(interval);
|
||||
object.addPropertyWatch("a");
|
||||
|
||||
QSignalSpy spy(&object, SIGNAL(aChanged(int)));
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(spy.count(), count);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::notifyInterval_data()
|
||||
{
|
||||
setupNotifyTests();
|
||||
}
|
||||
|
||||
void tst_QMediaObject::notifyInterval()
|
||||
{
|
||||
QFETCH(int, interval);
|
||||
|
||||
QtTestMediaObject object;
|
||||
QSignalSpy spy(&object, SIGNAL(notifyIntervalChanged(int)));
|
||||
|
||||
object.setNotifyInterval(interval);
|
||||
QCOMPARE(object.notifyInterval(), interval);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.last().value(0).toInt(), interval);
|
||||
|
||||
object.setNotifyInterval(interval);
|
||||
QCOMPARE(object.notifyInterval(), interval);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::nullMetaDataControl()
|
||||
{
|
||||
const QString titleKey(QLatin1String("Title"));
|
||||
const QString title(QLatin1String("Host of Seraphim"));
|
||||
|
||||
QtTestMetaDataService service;
|
||||
service.hasMetaData = false;
|
||||
|
||||
QtTestMediaObject object(&service);
|
||||
|
||||
QSignalSpy spy(&object, SIGNAL(metaDataChanged()));
|
||||
|
||||
QCOMPARE(object.isMetaDataAvailable(), false);
|
||||
|
||||
QCOMPARE(object.metaData(QtMultimediaKit::Title).toString(), QString());
|
||||
QCOMPARE(object.extendedMetaData(titleKey).toString(), QString());
|
||||
QCOMPARE(object.availableMetaData(), QList<QtMultimediaKit::MetaData>());
|
||||
QCOMPARE(object.availableExtendedMetaData(), QStringList());
|
||||
QCOMPARE(spy.count(), 0);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::isMetaDataAvailable()
|
||||
{
|
||||
QtTestMetaDataService service;
|
||||
service.metaData.setMetaDataAvailable(false);
|
||||
|
||||
QtTestMediaObject object(&service);
|
||||
QCOMPARE(object.isMetaDataAvailable(), false);
|
||||
|
||||
QSignalSpy spy(&object, SIGNAL(metaDataAvailableChanged(bool)));
|
||||
service.metaData.setMetaDataAvailable(true);
|
||||
|
||||
QCOMPARE(object.isMetaDataAvailable(), true);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.at(0).at(0).toBool(), true);
|
||||
|
||||
service.metaData.setMetaDataAvailable(false);
|
||||
|
||||
QCOMPARE(object.isMetaDataAvailable(), false);
|
||||
QCOMPARE(spy.count(), 2);
|
||||
QCOMPARE(spy.at(1).at(0).toBool(), false);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::metaDataChanged()
|
||||
{
|
||||
QtTestMetaDataService service;
|
||||
QtTestMediaObject object(&service);
|
||||
|
||||
QSignalSpy spy(&object, SIGNAL(metaDataChanged()));
|
||||
|
||||
service.metaData.metaDataChanged();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
|
||||
service.metaData.metaDataChanged();
|
||||
QCOMPARE(spy.count(), 2);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::metaData_data()
|
||||
{
|
||||
QTest::addColumn<QString>("artist");
|
||||
QTest::addColumn<QString>("title");
|
||||
QTest::addColumn<QString>("genre");
|
||||
|
||||
QTest::newRow("")
|
||||
<< QString::fromLatin1("Dead Can Dance")
|
||||
<< QString::fromLatin1("Host of Seraphim")
|
||||
<< QString::fromLatin1("Awesome");
|
||||
}
|
||||
|
||||
void tst_QMediaObject::metaData()
|
||||
{
|
||||
QFETCH(QString, artist);
|
||||
QFETCH(QString, title);
|
||||
QFETCH(QString, genre);
|
||||
|
||||
QtTestMetaDataService service;
|
||||
service.metaData.populateMetaData();
|
||||
|
||||
QtTestMediaObject object(&service);
|
||||
QVERIFY(object.availableMetaData().isEmpty());
|
||||
|
||||
service.metaData.m_data.insert(QtMultimediaKit::AlbumArtist, artist);
|
||||
service.metaData.m_data.insert(QtMultimediaKit::Title, title);
|
||||
service.metaData.m_data.insert(QtMultimediaKit::Genre, genre);
|
||||
|
||||
QCOMPARE(object.metaData(QtMultimediaKit::AlbumArtist).toString(), artist);
|
||||
QCOMPARE(object.metaData(QtMultimediaKit::Title).toString(), title);
|
||||
|
||||
QList<QtMultimediaKit::MetaData> metaDataKeys = object.availableMetaData();
|
||||
QCOMPARE(metaDataKeys.size(), 3);
|
||||
QVERIFY(metaDataKeys.contains(QtMultimediaKit::AlbumArtist));
|
||||
QVERIFY(metaDataKeys.contains(QtMultimediaKit::Title));
|
||||
QVERIFY(metaDataKeys.contains(QtMultimediaKit::Genre));
|
||||
}
|
||||
|
||||
void tst_QMediaObject::extendedMetaData()
|
||||
{
|
||||
QFETCH(QString, artist);
|
||||
QFETCH(QString, title);
|
||||
QFETCH(QString, genre);
|
||||
|
||||
QtTestMetaDataService service;
|
||||
QtTestMediaObject object(&service);
|
||||
QVERIFY(object.availableExtendedMetaData().isEmpty());
|
||||
|
||||
service.metaData.m_extendedData.insert(QLatin1String("Artist"), artist);
|
||||
service.metaData.m_extendedData.insert(QLatin1String("Title"), title);
|
||||
service.metaData.m_extendedData.insert(QLatin1String("Genre"), genre);
|
||||
|
||||
QCOMPARE(object.extendedMetaData(QLatin1String("Artist")).toString(), artist);
|
||||
QCOMPARE(object.extendedMetaData(QLatin1String("Title")).toString(), title);
|
||||
|
||||
QStringList extendedKeys = object.availableExtendedMetaData();
|
||||
QCOMPARE(extendedKeys.size(), 3);
|
||||
QVERIFY(extendedKeys.contains(QLatin1String("Artist")));
|
||||
QVERIFY(extendedKeys.contains(QLatin1String("Title")));
|
||||
QVERIFY(extendedKeys.contains(QLatin1String("Genre")));
|
||||
}
|
||||
|
||||
void tst_QMediaObject::availability()
|
||||
{
|
||||
QtTestMediaObject nullObject(0);
|
||||
QCOMPARE(nullObject.isAvailable(), false);
|
||||
QCOMPARE(nullObject.availabilityError(), QtMultimediaKit::ServiceMissingError);
|
||||
|
||||
QtTestMetaDataService service;
|
||||
QtTestMediaObject object(&service);
|
||||
QCOMPARE(object.isAvailable(), true);
|
||||
QCOMPARE(object.availabilityError(), QtMultimediaKit::NoError);
|
||||
}
|
||||
177
tests/auto/qmediaobject/tst_qmediaobject.h
Normal file
177
tests/auto/qmediaobject/tst_qmediaobject.h
Normal file
@@ -0,0 +1,177 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $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 TST_QMEDIAOBJECT_H
|
||||
#define TST_QMEDIAOBJECT_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include <QtCore/qtimer.h>
|
||||
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qmetadatareadercontrol.h>
|
||||
|
||||
//TESTED_COMPONENT=src/multimedia
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class tst_QMediaObject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void propertyWatch();
|
||||
void notifySignals_data();
|
||||
void notifySignals();
|
||||
void notifyInterval_data();
|
||||
void notifyInterval();
|
||||
|
||||
void nullMetaDataControl();
|
||||
void isMetaDataAvailable();
|
||||
void metaDataChanged();
|
||||
void metaData_data();
|
||||
void metaData();
|
||||
void availability();
|
||||
void extendedMetaData_data() { metaData_data(); }
|
||||
void extendedMetaData();
|
||||
|
||||
|
||||
private:
|
||||
void setupNotifyTests();
|
||||
};
|
||||
|
||||
class QtTestMetaDataProvider : public QMetaDataReaderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtTestMetaDataProvider(QObject *parent = 0)
|
||||
: QMetaDataReaderControl(parent)
|
||||
, m_available(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool isMetaDataAvailable() const { return m_available; }
|
||||
void setMetaDataAvailable(bool available) {
|
||||
if (m_available != available)
|
||||
emit metaDataAvailableChanged(m_available = available);
|
||||
}
|
||||
QList<QtMultimediaKit::MetaData> availableMetaData() const { return m_data.keys(); }
|
||||
|
||||
|
||||
QVariant metaData(QtMultimediaKit::MetaData key) const { return m_data.value(key); }
|
||||
|
||||
QVariant extendedMetaData(const QString &key) const { return m_extendedData.value(key); }
|
||||
|
||||
QStringList availableExtendedMetaData() const { return m_extendedData.keys(); }
|
||||
|
||||
using QMetaDataReaderControl::metaDataChanged;
|
||||
|
||||
void populateMetaData()
|
||||
{
|
||||
m_available = true;
|
||||
}
|
||||
|
||||
bool m_available;
|
||||
QMap<QtMultimediaKit::MetaData, QVariant> m_data;
|
||||
QMap<QString, QVariant> m_extendedData;
|
||||
};
|
||||
|
||||
class QtTestMetaDataService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtTestMetaDataService(QObject *parent = 0):QMediaService(parent), metaDataRef(0), hasMetaData(true)
|
||||
{
|
||||
}
|
||||
|
||||
QMediaControl *requestControl(const char *iid)
|
||||
{
|
||||
if (hasMetaData && qstrcmp(iid, QMetaDataReaderControl_iid) == 0)
|
||||
return &metaData;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void releaseControl(QMediaControl *)
|
||||
{
|
||||
}
|
||||
|
||||
QtTestMetaDataProvider metaData;
|
||||
int metaDataRef;
|
||||
bool hasMetaData;
|
||||
};
|
||||
|
||||
class QtTestMediaObject : public QMediaObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int a READ a WRITE setA NOTIFY aChanged)
|
||||
Q_PROPERTY(int b READ b WRITE setB NOTIFY bChanged)
|
||||
Q_PROPERTY(int c READ c WRITE setC NOTIFY cChanged)
|
||||
Q_PROPERTY(int d READ d WRITE setD)
|
||||
public:
|
||||
QtTestMediaObject(QMediaService *service = 0): QMediaObject(0, service), m_a(0), m_b(0), m_c(0), m_d(0) {}
|
||||
|
||||
using QMediaObject::addPropertyWatch;
|
||||
using QMediaObject::removePropertyWatch;
|
||||
|
||||
int a() const { return m_a; }
|
||||
void setA(int a) { m_a = a; }
|
||||
|
||||
int b() const { return m_b; }
|
||||
void setB(int b) { m_b = b; }
|
||||
|
||||
int c() const { return m_c; }
|
||||
void setC(int c) { m_c = c; }
|
||||
|
||||
int d() const { return m_d; }
|
||||
void setD(int d) { m_d = d; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void aChanged(int a);
|
||||
void bChanged(int b);
|
||||
void cChanged(int c);
|
||||
|
||||
private:
|
||||
int m_a;
|
||||
int m_b;
|
||||
int m_c;
|
||||
int m_d;
|
||||
};
|
||||
#endif //TST_QMEDIAOBJECT_H
|
||||
278
tests/auto/qmediaobject/tst_qmediaobject_mmf.cpp
Normal file
278
tests/auto/qmediaobject/tst_qmediaobject_mmf.cpp
Normal file
@@ -0,0 +1,278 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $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 <tst_qmediaobject_mmf.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
void tst_QMediaObject_mmf::initTestCase_data()
|
||||
{
|
||||
QTest::addColumn<bool>("valid");
|
||||
QTest::addColumn<QMediaContent>("mediaContent");
|
||||
QTest::addColumn<bool>("metaDataAvailable");
|
||||
|
||||
QTest::newRow("TestDataNull")
|
||||
<< false // valid
|
||||
<< QMediaContent() // mediaContent
|
||||
<< false; // metaDataAvailable
|
||||
|
||||
QTest::newRow("test_amr.amr")
|
||||
<< true // valid
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/test_amr.amr")) // mediaContent
|
||||
<< false; // metaDataAvailable
|
||||
|
||||
QTest::newRow("test_flash_video.flv")
|
||||
<< true // valid
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/test_flash_video.flv")) // mediaContent
|
||||
<< false; // metaDataAvailable
|
||||
|
||||
QTest::newRow("test_invalid_extension_mp4.xyz")
|
||||
<< true // valid
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/test_invalid_extension_mp4.xyz")) // mediaContent
|
||||
<< false; // metaDataAvailable
|
||||
|
||||
QTest::newRow("test_invalid_extension_wav.xyz")
|
||||
<< true // valid
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/test_invalid_extension_wav.xyz")) // mediaContent
|
||||
<< false; // metaDataAvailable
|
||||
|
||||
QTest::newRow("test_mp3.mp3")
|
||||
<< true // valid
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/test_mp3.mp3")) // mediaContent
|
||||
#if !defined(__WINS__) || !defined(__WINSCW__)
|
||||
<< true; // metaDataAvailable
|
||||
#else
|
||||
<< false; // metaDataAvailable
|
||||
#endif // !defined(__WINS__) || defined(__WINSCW__)
|
||||
|
||||
QTest::newRow("test_mp3_no_metadata.mp3")
|
||||
<< true // valid
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/test_mp3_no_metadata.mp3")) // mediaContent
|
||||
<< false; // metaDataAvailable
|
||||
|
||||
QTest::newRow("test_mp4.mp4")
|
||||
<< true // valid
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/test_mp4.mp4")) // mediaContent
|
||||
#if defined(__WINS__) || defined(__WINSCW__)
|
||||
<< true; // metaDataAvailable
|
||||
#else
|
||||
<< false; // metaDataAvailable
|
||||
#endif // !defined(__WINS__) || defined(__WINSCW__)
|
||||
|
||||
QTest::newRow("test_wav.wav")
|
||||
<< true // valid
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/test_wav.wav")) // mediaContent
|
||||
<< false; // metaDataAvailable
|
||||
|
||||
QTest::newRow("test_wmv9.wmv")
|
||||
<< true // valid
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/test_wmv9.wmv")) // mediaContent
|
||||
<< false; // metaDataAvailable
|
||||
|
||||
QTest::newRow("test youtube stream")
|
||||
<< true // valid
|
||||
<< QMediaContent(QUrl("rtsp://v3.cache4.c.youtube.com/CkgLENy73wIaPwlU2rm7yu8PFhMYESARFEIJbXYtZ29vZ2xlSARSB3JlbGF0ZWRaDkNsaWNrVGh1bWJuYWlsYPi6_IXT2rvpSgw=/0/0/0/video.3gp")) // mediaContent
|
||||
<< false; // metaDataAvailable
|
||||
}
|
||||
|
||||
void tst_QMediaObject_mmf::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QMediaObject_mmf::cleanupTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QMediaObject_mmf::init()
|
||||
{
|
||||
qRegisterMetaType<QMediaContent>("QMediaContent");
|
||||
}
|
||||
|
||||
void tst_QMediaObject_mmf::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QMediaObject_mmf::isMetaDataAvailable()
|
||||
{
|
||||
QFETCH_GLOBAL(QMediaContent, mediaContent);
|
||||
QFETCH_GLOBAL(bool, metaDataAvailable);
|
||||
QMediaPlayer player;
|
||||
|
||||
player.setMedia(mediaContent);
|
||||
QTest::qWait(700);
|
||||
QVERIFY(player.isMetaDataAvailable() == metaDataAvailable);
|
||||
}
|
||||
|
||||
void tst_QMediaObject_mmf::metaData()
|
||||
{
|
||||
QFETCH_GLOBAL(QMediaContent, mediaContent);
|
||||
QFETCH_GLOBAL(bool, metaDataAvailable);
|
||||
QMediaPlayer player;
|
||||
|
||||
player.setMedia(mediaContent);
|
||||
QTest::qWait(700);
|
||||
const QString artist(QLatin1String("Artist"));
|
||||
const QString title(QLatin1String("Title"));
|
||||
|
||||
if (player.isMetaDataAvailable()) {
|
||||
QCOMPARE(player.metaData(QtMultimediaKit::AlbumArtist).toString(), artist);
|
||||
QCOMPARE(player.metaData(QtMultimediaKit::Title).toString(), title);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QMediaObject_mmf::availableMetaData()
|
||||
{
|
||||
QFETCH_GLOBAL(QMediaContent, mediaContent);
|
||||
QFETCH_GLOBAL(bool, metaDataAvailable);
|
||||
QMediaPlayer player;
|
||||
|
||||
player.setMedia(mediaContent);
|
||||
QTest::qWait(700);
|
||||
|
||||
if (player.isMetaDataAvailable()) {
|
||||
QList<QtMultimediaKit::MetaData> metaDataKeys = player.availableMetaData();
|
||||
QVERIFY(metaDataKeys.count() > 0);
|
||||
QVERIFY(metaDataKeys.contains(QtMultimediaKit::AlbumArtist));
|
||||
QVERIFY(metaDataKeys.contains(QtMultimediaKit::Title));
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QMediaObject_mmf::extendedMetaData()
|
||||
{
|
||||
QFETCH_GLOBAL(QMediaContent, mediaContent);
|
||||
QMediaPlayer player;
|
||||
|
||||
player.setMedia(mediaContent);
|
||||
QTest::qWait(700);
|
||||
const QString artist(QLatin1String("Artist"));
|
||||
const QString title(QLatin1String("Title"));
|
||||
|
||||
if (player.isMetaDataAvailable()) {
|
||||
QCOMPARE(player.extendedMetaData(metaDataKeyAsString(QtMultimediaKit::AlbumArtist)).toString(), artist);
|
||||
QCOMPARE(player.extendedMetaData(metaDataKeyAsString(QtMultimediaKit::Title)).toString(), title);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QMediaObject_mmf::availableExtendedMetaData()
|
||||
{
|
||||
QFETCH_GLOBAL(QMediaContent, mediaContent);
|
||||
QMediaPlayer player;
|
||||
|
||||
player.setMedia(mediaContent);
|
||||
QTest::qWait(700);
|
||||
const QString artist(QLatin1String("Artist"));
|
||||
const QString title(QLatin1String("Title"));
|
||||
|
||||
if (player.isMetaDataAvailable()) {
|
||||
QStringList metaDataKeys = player.availableExtendedMetaData();
|
||||
QVERIFY(metaDataKeys.count() > 0);
|
||||
/* qWarning() << "metaDataKeys.count: " << metaDataKeys.count();
|
||||
int count = metaDataKeys.count();
|
||||
count = count-1;
|
||||
int i = 0;
|
||||
while(count >= i)
|
||||
{
|
||||
qWarning() << "metaDataKeys "<<i<<"." << metaDataKeys.at(i);
|
||||
i++;
|
||||
}*/
|
||||
QVERIFY(metaDataKeys.contains(metaDataKeyAsString(QtMultimediaKit::AlbumArtist)));
|
||||
QVERIFY(metaDataKeys.contains(metaDataKeyAsString(QtMultimediaKit::Title)));
|
||||
}
|
||||
}
|
||||
|
||||
QString tst_QMediaObject_mmf::metaDataKeyAsString(QtMultimediaKit::MetaData key) const
|
||||
{
|
||||
switch(key) {
|
||||
case QtMultimediaKit::Title: return "title";
|
||||
case QtMultimediaKit::AlbumArtist: return "artist";
|
||||
case QtMultimediaKit::Comment: return "comment";
|
||||
case QtMultimediaKit::Genre: return "genre";
|
||||
case QtMultimediaKit::Year: return "year";
|
||||
case QtMultimediaKit::Copyright: return "copyright";
|
||||
case QtMultimediaKit::AlbumTitle: return "album";
|
||||
case QtMultimediaKit::Composer: return "composer";
|
||||
case QtMultimediaKit::TrackNumber: return "albumtrack";
|
||||
case QtMultimediaKit::AudioBitRate: return "audiobitrate";
|
||||
case QtMultimediaKit::VideoBitRate: return "videobitrate";
|
||||
case QtMultimediaKit::Duration: return "duration";
|
||||
case QtMultimediaKit::MediaType: return "contenttype";
|
||||
case QtMultimediaKit::SubTitle:
|
||||
case QtMultimediaKit::Description:
|
||||
case QtMultimediaKit::Category:
|
||||
case QtMultimediaKit::Date:
|
||||
case QtMultimediaKit::UserRating:
|
||||
case QtMultimediaKit::Keywords:
|
||||
case QtMultimediaKit::Language:
|
||||
case QtMultimediaKit::Publisher:
|
||||
case QtMultimediaKit::ParentalRating:
|
||||
case QtMultimediaKit::RatingOrganisation:
|
||||
case QtMultimediaKit::Size:
|
||||
case QtMultimediaKit::AudioCodec:
|
||||
case QtMultimediaKit::AverageLevel:
|
||||
case QtMultimediaKit::ChannelCount:
|
||||
case QtMultimediaKit::PeakValue:
|
||||
case QtMultimediaKit::SampleRate:
|
||||
case QtMultimediaKit::Author:
|
||||
case QtMultimediaKit::ContributingArtist:
|
||||
case QtMultimediaKit::Conductor:
|
||||
case QtMultimediaKit::Lyrics:
|
||||
case QtMultimediaKit::Mood:
|
||||
case QtMultimediaKit::TrackCount:
|
||||
case QtMultimediaKit::CoverArtUrlSmall:
|
||||
case QtMultimediaKit::CoverArtUrlLarge:
|
||||
case QtMultimediaKit::Resolution:
|
||||
case QtMultimediaKit::PixelAspectRatio:
|
||||
case QtMultimediaKit::VideoFrameRate:
|
||||
case QtMultimediaKit::VideoCodec:
|
||||
case QtMultimediaKit::PosterUrl:
|
||||
case QtMultimediaKit::ChapterNumber:
|
||||
case QtMultimediaKit::Director:
|
||||
case QtMultimediaKit::LeadPerformer:
|
||||
case QtMultimediaKit::Writer:
|
||||
case QtMultimediaKit::CameraManufacturer:
|
||||
case QtMultimediaKit::CameraModel:
|
||||
case QtMultimediaKit::Event:
|
||||
case QtMultimediaKit::Subject:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
81
tests/auto/qmediaobject/tst_qmediaobject_mmf.h
Normal file
81
tests/auto/qmediaobject/tst_qmediaobject_mmf.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $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 TST_QMEDIAOBJECT_MMF_H
|
||||
#define TST_QMEDIAOBJECT_MMF_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
|
||||
#include <qtmedianamespace.h>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMediaPlayerControl>
|
||||
#include <QMediaPlaylist>
|
||||
#include <QMediaService>
|
||||
#include <QMediaStreamsControl>
|
||||
#include <QVideoWidget>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class tst_QMediaObject_mmf : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase_data();
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void isMetaDataAvailable();
|
||||
void metaData();
|
||||
void availableMetaData();
|
||||
void extendedMetaData();
|
||||
void availableExtendedMetaData();
|
||||
|
||||
private:
|
||||
QString metaDataKeyAsString(QtMultimediaKit::MetaData key) const;
|
||||
};
|
||||
|
||||
#endif // TST_QMEDIAOBJECT_MMF_H
|
||||
158
tests/auto/qmediaobject/tst_qmediaobject_xa.cpp
Normal file
158
tests/auto/qmediaobject/tst_qmediaobject_xa.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $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 "tst_qmediaobject_xa.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
#define WAIT_FOR_CONDITION(a,e) \
|
||||
for (int _i = 0; _i < 500; _i += 1) { \
|
||||
if ((a) == (e)) break; \
|
||||
QTest::qWait(10);}
|
||||
|
||||
|
||||
#define WAIT_LONG_FOR_CONDITION(a,e) \
|
||||
for (int _i = 0; _i < 1800; _i += 1) { \
|
||||
if ((a) == (e)) break; \
|
||||
QTest::qWait(100);}
|
||||
|
||||
Q_DECLARE_METATYPE(QtMultimediaKit::MetaData)
|
||||
|
||||
void tst_QMetadata_xa::initTestCase_data()
|
||||
{
|
||||
QTest::addColumn<QMediaContent>("mediaContent");
|
||||
QTest::addColumn<int>("count");
|
||||
QTest::addColumn<QtMultimediaKit::MetaData>("key");
|
||||
QTest::addColumn<qint64>("intValue");
|
||||
QTest::addColumn<QString>("strValue");
|
||||
|
||||
QTest::newRow("testmp3.mp3 - No Metadata")
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/test.mp3")) // mediaContent
|
||||
<< 0 //count
|
||||
<< QtMultimediaKit::Title //key - irrelavant when count 0
|
||||
<< qint64(-1) //intValue
|
||||
<< QString(); //strValue
|
||||
|
||||
QTest::newRow("JapJap.mp3 - Title")
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/JapJap.mp3")) // mediaContent
|
||||
<< -1 //count - ignore
|
||||
<< QtMultimediaKit::Title //key
|
||||
<< qint64(-1) //intValue
|
||||
<< QString("JapJap");//strValue
|
||||
|
||||
QTest::newRow("JapJap.mp3 - Artist")
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/JapJap.mp3")) // mediaContent
|
||||
<< -1 //count - ignore
|
||||
<< QtMultimediaKit::AlbumArtist //key
|
||||
<< qint64(-1) //intValue
|
||||
<< QString("Screaming trees");//strValue
|
||||
|
||||
QTest::newRow("JapJap.mp3 - Album")
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/JapJap.mp3")) // mediaContent
|
||||
<< -1 //count - ignore
|
||||
<< QtMultimediaKit::AlbumTitle //key
|
||||
<< qint64(-1) //intValue
|
||||
<< QString("Sweet oblivion"); //strValue
|
||||
|
||||
QTest::newRow("JapJap.mp3 - CoverArt")
|
||||
<< QMediaContent(QUrl("file:///C:/data/testfiles/JapJap.mp3")) // mediaContent
|
||||
<< -1 //count - ignore
|
||||
<< QtMultimediaKit::CoverArtImage //key
|
||||
<< qint64(28521) //intValue
|
||||
<< QString("C:/data/testfiles/JapJapCoverArt.jpeg"); //strValue
|
||||
}
|
||||
|
||||
void tst_QMetadata_xa::initTestCase()
|
||||
{
|
||||
m_player = new QMediaPlayer();
|
||||
|
||||
// Symbian back end needs coecontrol for creation.
|
||||
m_widget = new QVideoWidget();
|
||||
//m_widget->setMediaObject(m_player);
|
||||
m_widget->show();
|
||||
runonce = false;
|
||||
}
|
||||
|
||||
void tst_QMetadata_xa::cleanupTestCase()
|
||||
{
|
||||
delete m_player;
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
void tst_QMetadata_xa::init()
|
||||
{
|
||||
qRegisterMetaType<QMediaContent>("QMediaContent");
|
||||
qRegisterMetaType<QtMultimediaKit::MetaData>("QtMultimediaKit::MetaData");
|
||||
}
|
||||
|
||||
void tst_QMetadata_xa::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QMetadata_xa::testMetadata()
|
||||
{
|
||||
QFETCH_GLOBAL(QMediaContent, mediaContent);
|
||||
QFETCH_GLOBAL(int, count);
|
||||
QFETCH_GLOBAL(QtMultimediaKit::MetaData, key);
|
||||
QFETCH_GLOBAL(QString, strValue);
|
||||
QFETCH_GLOBAL(qint64, intValue);
|
||||
|
||||
QSignalSpy spy(m_player, SIGNAL(metaDataAvailableChanged(bool)));
|
||||
m_player->setMedia(mediaContent);
|
||||
|
||||
WAIT_FOR_CONDITION(spy.count(), 1);
|
||||
//get metadata count
|
||||
QList<QtMultimediaKit::MetaData> mdList = m_player->availableMetaData ();
|
||||
QStringList amdList = m_player->availableExtendedMetaData();
|
||||
|
||||
int numMetadataItems = mdList.size() + amdList.size();
|
||||
if (count>=0) //-1 indicate ignore count
|
||||
QVERIFY(count==numMetadataItems);
|
||||
|
||||
if (numMetadataItems>0 && !strValue.isEmpty()) {
|
||||
QVariant val = m_player->metaData(key);
|
||||
|
||||
if(key == QtMultimediaKit::CoverArtImage)
|
||||
val.value<QImage>().save(strValue);
|
||||
else
|
||||
QVERIFY(strValue == val.toString());
|
||||
}
|
||||
}
|
||||
83
tests/auto/qmediaobject/tst_qmediaobject_xa.h
Normal file
83
tests/auto/qmediaobject/tst_qmediaobject_xa.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $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 TST_QMEDIAOBJECT_XA_H
|
||||
#define TST_QMEDIAOBJECT_XA_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
|
||||
#include <QMediaPlayer>
|
||||
#include <QMediaPlayerControl>
|
||||
#include <QMediaPlaylist>
|
||||
#include <QMediaService>
|
||||
#include <QMediaStreamsControl>
|
||||
#include <QVideoWidget>
|
||||
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class tst_QMetadata_xa: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase_data();
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void testMetadata();
|
||||
|
||||
|
||||
private:
|
||||
void displayImage(QImage);
|
||||
QMediaPlayer *m_player;
|
||||
QVideoWidget *m_widget;
|
||||
bool runonce;
|
||||
};
|
||||
|
||||
#endif //TST_QMEDIAOBJECT_XA_H
|
||||
Reference in New Issue
Block a user