Rearrange the automatic tests.

Split them into unit and integration tests.  Integration tests really
need to be run on the real platform (not in a VM etc) since they are
somewhat unstable or nonfunctional otherwise.

A few tests were previously broken by QUrl changes and they were repaired.
Removed one test since it was not providing a lot of value.

There are still a number of tests that rely on Q_AUTOTEST_EXPORT symbols.

Change-Id: Ic402abf0af946baa5945075d975b3f584f9ef280
Reviewed-by: Kalle Lehtonen <kalle.ju.lehtonen@nokia.com>
This commit is contained in:
Michael Goddard
2011-11-04 13:38:44 +10:00
committed by Qt by Nokia
parent 7dfb883df6
commit e3a8c165ea
190 changed files with 39 additions and 596 deletions

View File

@@ -1,12 +1,4 @@
TEMPLATE = subdirs
SUBDIRS += multimedia.pro
contains(QT_CONFIG,multimediawidgets): SUBDIRS += multimediawidgets.pro
# These autotests consist of things such as static code checks
# which require that the autotest is run on the same machine
# doing the build - i.e. cross-compilation is not allowed.
win32|mac|linux-g++* {
# NOTE: Disabled until we have established which tests fall into this category
# !contains(QT_CONFIG,embedded):!maemo5:!maemo6:SUBDIRS+=host.pro
}
TEMPLATE=subdirs
SUBDIRS += \
unit \
integration

View File

@@ -0,0 +1,3 @@
TEMPLATE = subdirs
SUBDIRS += multimedia.pro

View File

@@ -0,0 +1,9 @@
TEMPLATE = subdirs
SUBDIRS += \
qaudioinput \
qaudiooutput \
qmediaplayerbackend \
qcamerabackend \
qsoundeffect

View File

@@ -1,10 +0,0 @@
CONFIG += testcase
TARGET = tst_qmediastreamscontrol
QT += multimedia-private testlib
CONFIG += no_private_qt_headers_warning
SOURCES += \
tst_qmediastreamscontrol.cpp
include(../multimedia_common.pri)

View File

@@ -1,408 +0,0 @@
/****************************************************************************
**
** 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 test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
//TESTED_COMPONENT=src/multimedia
#include <QtCore/QString>
#include <QtTest/QtTest>
#include <QtCore/QCoreApplication>
#include <qmediaplayercontrol.h>
#include <qmediaservice.h>
#include <qmediastreamscontrol.h>
#include <QtGui/QImage>
#include <QtCore/QPointer>
QT_USE_NAMESPACE
#define WAIT_FOR_CONDITION(a,e) \
for (int _i = 0; _i < 500; _i += 1) { \
if ((a) == (e)) break; \
QTest::qWait(10);}
class tst_qmediastreamscontrol : public QObject
{
Q_OBJECT
public:
tst_qmediastreamscontrol();
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
void control_iid();
void control();
void isActive();
void streamCount();
void streamsChanged();
void metadata();
};
class mediaStatusList : public QObject, public QList<QMediaStreamsControl::StreamType>
{
Q_OBJECT
public slots:
void mediaStatus(QMediaStreamsControl::StreamType status) {
append(status);
}
public:
mediaStatusList(QObject *obj, const char *aSignal)
: QObject()
{
QObject::connect(obj, aSignal, this, SLOT(mediaStatus(QMediaStreamsControl::StreamType)));
}
};
class QtTestMediaStreamsControl: public QMediaStreamsControl
{
public:
QtTestMediaStreamsControl(QObject *parent = 0)
: QMediaStreamsControl(parent)
{
}
int streamCount()
{
QList <StreamType> m_stype;
return streams.count();
}
void setStreamCount(int count)
{
streams.resize(count);
}
StreamType streamType(int index)
{
return streams.at(index).type;
}
void setStreamType(int index, StreamType type)
{
streams[index].type = type;
}
QVariant metaData(int index, QtMultimedia::MetaData key)
{
QtMultimedia::MetaData keys = key;
return keys;
}
void setMetaData(int index, QtMultimedia::MetaData key, const QVariant &value)
{
streams[index].metaData.insert(key, value);
}
bool isActive(int index)
{
return streams.at(index).active;
}
void setActive(int index, bool state)
{
streams[index].active = state;
}
void setAudioOnlyContent()
{
mediaContent = audioOnlyContent;
m_player->setMedia(*mediaContent);
}
void setVideoOnlyContent()
{
mediaContent = videoOnlyContent;
duration = 60000;
m_player->setMedia(*mediaContent);
}
void setAudioVideoContent()
{
if (mediaContent == audioVideoContent)
{
mediaContent = audioVideoAltContent;
duration = 101840;
}
else
{
mediaContent = audioVideoContent;
duration = 141000;
}
m_player->setMedia(*mediaContent);
}
void setStreamingContent()
{
mediaContent = streamingContent;
m_player->setMedia(*mediaContent);
}
public:
struct Stream
{
Stream() : type(UnknownStream), active(false) {}
StreamType type;
QMap<QtMultimedia::MetaData, QVariant> metaData;
bool active;
};
QVector<Stream> streams;
QMediaContent* audioOnlyContent;
QMediaContent* videoOnlyContent;
QMediaContent* audioVideoContent;
QMediaContent* audioVideoAltContent;
QMediaContent* mediaContent;
QMediaContent* streamingContent;
qint64 duration;
QMediaPlayer *m_player;
QVideoWidget *m_widget;
QWidget *m_windowWidget;
};
class QTestMediaStreamsControlA : public QMediaControl
{
Q_OBJECT
};
#define QTestMediaStreamsControlA_iid "com.nokia.QTestMediaStreamsControlA"
Q_MEDIA_DECLARE_CONTROL(QTestMediaStreamsControlA, QTestMediaStreamsControlA_iid)
class QTestMediaStreamsControlB : public QMediaControl
{
Q_OBJECT
public:
QTestMediaStreamsControlB()
: QMediaControl(0)
,ctrlA(0)
,ctrlB(0)
,ctrlC(0) {}
bool isActive(int stream)
{
return 1;
}
int ctrlA;
int ctrlB;
int ctrlC;
};
#define QTestMediaStreamsControlB_iid "com.nokia.QTestMediaStreamsControlB"
Q_MEDIA_DECLARE_CONTROL(QTestMediaStreamsControlB, QTestMediaStreamsControlB_iid)
class QTestMediaStreamsControlC : public QMediaControl
{
Q_OBJECT
};
#define QTestMediaStreamsControlC_iid "com.nokia.QTestMediaStreamsControlC"
Q_MEDIA_DECLARE_CONTROL(QTestMediaStreamsControlC, QTestMediaStreamsControlC_iid) // Yes A.
class QTestMediaStreamsControlD : public QMediaControl
{
Q_OBJECT
};
#define QTestMediaStreamsControlD_iid "com.nokia.QTestMediaStreamsControlD"
Q_MEDIA_DECLARE_CONTROL(QTestMediaStreamsControlD, QTestMediaStreamsControlD_iid)
class QtTestMediaService : public QMediaService
{
Q_OBJECT
public:
QtTestMediaService()
: QMediaService(0)
, refA(0)
, refB(0)
, refC(0)
{
}
QMediaControl *requestControl(const char *name)
{
if (strcmp(name, QTestMediaStreamsControlA_iid) == 0) {
refA += 1;
return &controlA;
} else if (strcmp(name, QTestMediaStreamsControlB_iid) == 0) {
refB += 1;
return &controlB;
} else if (strcmp(name, QTestMediaStreamsControlC_iid) == 0) {
refA += 1;
return &controlA;
} else {
return 0;
}
}
void releaseControl(QMediaControl *control)
{
if (control == &controlA)
refA -= 1;
else if (control == &controlB)
refB -= 1;
else if (control == &controlC)
refC -= 1;
}
using QMediaService::requestControl;
int refA;
int refB;
int refC;
QTestMediaStreamsControlA controlA;
QTestMediaStreamsControlB controlB;
QTestMediaStreamsControlC controlC;
};
tst_qmediastreamscontrol::tst_qmediastreamscontrol()
{
}
void tst_qmediastreamscontrol::initTestCase()
{
}
void tst_qmediastreamscontrol::cleanupTestCase()
{
}
void tst_qmediastreamscontrol::control_iid()
{
// Default implementation.
QCOMPARE(qmediacontrol_iid<QTestMediaStreamsControlA *>(), QTestMediaStreamsControlA_iid);
// Partial template.
QVERIFY(qstrcmp(qmediacontrol_iid<QTestMediaStreamsControlA *>(), QTestMediaStreamsControlA_iid) == 0);
}
void tst_qmediastreamscontrol::control()
{
QtTestMediaService *service = new QtTestMediaService();
QMediaStreamsControl *control = qobject_cast<QMediaStreamsControl *>
(service->requestControl("com.nokia.Qt.MediaStreamsControl/1.0"));
// QCOMPARE(control,service->controlA.objectName());
QTestMediaStreamsControlA *controlA = (QTestMediaStreamsControlA *)service->requestControl("controlA");
// QCOMPARE(controlA,service->controlA);
QVERIFY(service->requestControl<QTestMediaStreamsControlA *>());
service->releaseControl(controlA);
delete service;
}
void tst_qmediastreamscontrol::isActive()
{
QTestMediaStreamsControlB ser;
QVERIFY(ser.isActive(1));
QtTestMediaStreamsControl m_active;
//setActive
m_active.setActive(1,1);
QVERIFY(m_active.isActive(1));
//set InActive
m_active.setActive(2,0);
QVERIFY(!m_active.isActive(0));
}
//Returns the number of media streams.
void tst_qmediastreamscontrol::streamCount()
{
QtTestMediaStreamsControl m_cnt;
m_cnt.setStreamType(0,QMediaStreamsControl::UnknownStream);
m_cnt.setStreamType(1,QMediaStreamsControl::VideoStream);
m_cnt.setStreamType(2,QMediaStreamsControl::AudioStream);
m_cnt.setStreamType(3,QMediaStreamsControl::SubPictureStream);
m_cnt.setStreamType(4,QMediaStreamsControl::DataStream);
m_cnt.setStreamCount(5);
QVERIFY(m_cnt.streamCount() == m_cnt.streams.count());
}
//The signal is emitted when the available streams list is changed.
void tst_qmediastreamscontrol::streamsChanged()
{
QMediaPlayer *m_player = new QMediaPlayer(0);
QMediaStreamsControl* m_streamControl = (QMediaStreamsControl*)
(m_player->service()->requestControl(QTestMediaStreamsControlA_iid));
QMediaContent videoOnlyContent;
m_player->setMedia(videoOnlyContent);
if (m_streamControl) {
QSignalSpy m_strm_lst_chgSpy(m_streamControl,SIGNAL(streamsChanged()));
QVERIFY(m_strm_lst_chgSpy.isValid());
QVERIFY(m_strm_lst_chgSpy.isEmpty());
WAIT_FOR_CONDITION(m_player->mediaStatus(),QMediaPlayer::LoadedMedia);
QVERIFY(m_streamControl->streamCount() == 1);
QVERIFY(m_strm_lst_chgSpy.count() == 1);
}
delete m_player;
m_player = NULL;
}
void tst_qmediastreamscontrol::metadata()
{
QtTestMediaStreamsControl m_metadata;
m_metadata.metaData(1,QtMultimedia::AlbumArtist);
qDebug() << m_metadata.metaData(1,QtMultimedia::AlbumArtist);
}
QTEST_MAIN(tst_qmediastreamscontrol);
#include "tst_qmediastreamscontrol.moc"

View File

@@ -1,7 +0,0 @@
CONFIG += testcase
TARGET = tst_qvideodevicecontrol
QT += multimedia-private testlib
CONFIG += no_private_qt_headers_warning
SOURCES += tst_qvideodevicecontrol.cpp

View File

@@ -1,110 +0,0 @@
/****************************************************************************
**
** 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 test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
//TESTED_COMPONENT=src/multimedia
#include <QtTest/QtTest>
#include "qvideodevicecontrol.h"
class TestClass: public QVideoDeviceControl
{
Q_OBJECT
public:
TestClass(QObject *parent = 0 ):QVideoDeviceControl(parent)
{
}
~TestClass(){}
virtual int deviceCount() const { return 0; }
QString deviceName(int index) const
{
QString str;
return str;
}
QString deviceDescription(int index) const
{
QString str;
return str;
}
QIcon deviceIcon(int index) const
{
QIcon icon;
return icon;
}
int defaultDevice() const { return 0; }
int selectedDevice() const { return 0; }
public Q_SLOTS:
void setSelectedDevice(int index)
{
emit devicesChanged();
emit selectedDeviceChanged(index);
emit selectedDeviceChanged("abc");
}
};
class tst_QVideoDeviceControl : public QObject
{
Q_OBJECT
public:
tst_QVideoDeviceControl(){}
~tst_QVideoDeviceControl(){}
private slots:
void testQVideoDeviceControl();
};
//MaemoAPI-1859:QVideoDeviceControl constructor
void tst_QVideoDeviceControl::testQVideoDeviceControl()
{
TestClass *testClass = new TestClass(this);
QVERIFY(testClass != NULL);
}
QTEST_MAIN(tst_QVideoDeviceControl)
#include "tst_qvideodevicecontrol.moc"

View File

@@ -6,53 +6,36 @@ SUBDIRS += \
qaudiocapturesource \
qaudiodeviceinfo \
qaudioformat \
qaudioinput \
qaudionamespace \
qaudiooutput \
qcamera \
qcameraimagecapture \
qmediabindableinterface \
qmediacontainercontrol \
qmediacontent \
qmediaplayerbackend \
qmediaobject \
qmediaplayer \
qmediaplaylistnavigator \
qmediarecorder \
qmediaresource \
qmediaservice \
qmediatimerange \
qradiotuner \
qradiodata \
qvideoframe \
qvideosurfaceformat \
qmetadatareadercontrol \
qmetadatawritercontrol \
qmediaplayer \
qcameraimagecapture \
qmediaobject \
qcamera \
qcamerabackend \
qradiodata \
qradiotuner \
qvideoencodercontrol \
qvideoframe \
qvideosurfaceformat \
qwavedecoder
# These is disabled until intent is clearer
# qvideodevicecontrol \
# qvideoencodercontrol \
# This is a commment for the mock backend directory so that maketestselftest
# doesn't believe it's an untested directory
# qmultimedia_common
# Tests depending on private interfaces should only be built if
# these interfaces are exported.
contains (QT_CONFIG, private_tests) {
# These depend on controlling the set of plugins loaded (in qmediapluginloader)
SUBDIRS += \
qdeclarativeaudio \
qmediaplaylist \
qmediapluginloader \
qmediaimageviewer \
qmediaserviceprovider
contains (QT_CONFIG, declarative) {
# All the declarative tests depend on private interfaces
SUBDIRS += \
qsoundeffect \
qdeclarativeaudio
}
}

View File

@@ -5,10 +5,6 @@ SUBDIRS += \
qcamerawidgets \
qmediaplayerwidgets \
# This is a commment for the mock backend directory so that maketestselftest
# doesn't believe it's an untested directory
# qmultimedia_common
# Tests depending on private interfaces should only be built if
# these interfaces are exported.
contains (QT_CONFIG, private_tests) {
@@ -17,9 +13,5 @@ contains (QT_CONFIG, private_tests) {
qpaintervideosurface \
qmediaimageviewerwidgets \
qvideowidget \
contains (QT_CONFIG, declarative) {
disabled:SUBDIRS += qdeclarativevideo
}
}

View File

@@ -8,5 +8,3 @@ include (../qmultimedia_common/mock.pri)
include (../qmultimedia_common/mockcamera.pri)
SOURCES += tst_qcamera.cpp
maemo*:CONFIG += insignificant_test

View File

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 230 B

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 230 B

View File

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 230 B

View File

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 230 B

View File

@@ -1,9 +1,6 @@
CONFIG += testcase
TARGET = tst_qmediaplaylist
# temporarily blacklist test because is fails miserably
CONFIG += insignificant_test
include (../qmultimedia_common/mockplaylist.pri)
QT += multimedia-private testlib

View File

@@ -368,13 +368,13 @@ void tst_QMediaPlaylist::saveAndLoad()
QVERIFY(playlist.error() != QMediaPlaylist::NoError);
QVERIFY(!playlist.errorString().isEmpty());
res = playlist.save(QUrl(QLatin1String("tmp.unsupported_format")), "unsupported_format");
res = playlist.save(QUrl::fromLocalFile(QLatin1String("tmp.unsupported_format")), "unsupported_format");
QVERIFY(!res);
QVERIFY(playlist.error() != QMediaPlaylist::NoError);
QVERIFY(!playlist.errorString().isEmpty());
errorSignal.clear();
playlist.load(QUrl(QLatin1String("tmp.unsupported_format")), "unsupported_format");
playlist.load(QUrl::fromLocalFile(QLatin1String("tmp.unsupported_format")), "unsupported_format");
QCOMPARE(errorSignal.size(), 1);
QVERIFY(playlist.error() == QMediaPlaylist::FormatNotSupportedError);
QVERIFY(!playlist.errorString().isEmpty());
@@ -393,12 +393,12 @@ void tst_QMediaPlaylist::saveAndLoad()
QCOMPARE(playlist.media(0), playlist2.media(0));
QCOMPARE(playlist.media(1), playlist2.media(1));
QCOMPARE(playlist.media(3), playlist2.media(3));
res = playlist.save(QUrl(QLatin1String("tmp.m3u")), "m3u");
res = playlist.save(QUrl::fromLocalFile(QLatin1String("tmp.m3u")), "m3u");
QVERIFY(res);
playlist2.clear();
QVERIFY(playlist2.isEmpty());
playlist2.load(QUrl(QLatin1String("tmp.m3u")), "m3u");
playlist2.load(QUrl::fromLocalFile(QLatin1String("tmp.m3u")), "m3u");
QCOMPARE(playlist.error(), QMediaPlaylist::NoError);
QCOMPARE(playlist.mediaCount(), playlist2.mediaCount());
@@ -488,7 +488,7 @@ void tst_QMediaPlaylist::shuffle()
QList<QMediaContent> contentList;
for (int i=0; i<100; i++) {
QMediaContent content(QUrl(QString::number(i)));
QMediaContent content(QUrl::fromLocalFile(QString::number(i)));
contentList.append(content);
playlist.addMedia(content);
}
@@ -561,7 +561,7 @@ void tst_QMediaPlaylist::readOnlyPlaylist()
QCOMPARE(playlist.mediaCount(), 3);
errorSignal.clear();
playlist.load(QUrl(QLatin1String("tmp.m3u")), "m3u");
playlist.load(QUrl::fromLocalFile(QLatin1String("tmp.m3u")), "m3u");
QCOMPARE(errorSignal.size(), 1);
QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError);

Some files were not shown because too many files have changed in this diff Show More