Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
This commit is contained in:
18
tests/README
Normal file
18
tests/README
Normal file
@@ -0,0 +1,18 @@
|
||||
This directory contains autotests and benchmarks based on QTestlib. In order
|
||||
to run the autotests reliably, you need to configure a desktop to match the
|
||||
test environment that these tests are written for.
|
||||
|
||||
Linux X11:
|
||||
|
||||
* The user must be logged in to an active desktop; you can't run the
|
||||
autotests without a valid DISPLAY that allows X11 connections.
|
||||
|
||||
* The tests are run against a KDE3 or KDE4 desktop.
|
||||
|
||||
* Window manager uses "click to focus", and not "focus follows mouse". Many
|
||||
tests move the mouse cursor around and expect this to not affect focus
|
||||
and activation.
|
||||
|
||||
* Disable "click to activate", i.e., when a window is opened, the window
|
||||
manager should automatically activate it (give it input focus) and not
|
||||
wait for the user to click the window.
|
||||
11
tests/auto/auto.pro
Normal file
11
tests/auto/auto.pro
Normal file
@@ -0,0 +1,11 @@
|
||||
TEMPLATE=subdirs
|
||||
SUBDIRS=\
|
||||
qabstractvideobuffer \
|
||||
qabstractvideosurface \
|
||||
qaudiodeviceinfo \
|
||||
qaudioformat \
|
||||
qaudioinput \
|
||||
qaudiooutput \
|
||||
qvideoframe \
|
||||
qvideosurfaceformat
|
||||
|
||||
2
tests/auto/bic/.gitignore
vendored
Normal file
2
tests/auto/bic/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
qt_temp.*.*lass
|
||||
test.cpp
|
||||
17011
tests/auto/bic/data/QtMultimedia.4.6.0.linux-gcc-amd64.txt
Normal file
17011
tests/auto/bic/data/QtMultimedia.4.6.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
17065
tests/auto/bic/data/QtMultimedia.4.6.0.linux-gcc-ia32.txt
Normal file
17065
tests/auto/bic/data/QtMultimedia.4.6.0.linux-gcc-ia32.txt
Normal file
File diff suppressed because it is too large
Load Diff
17075
tests/auto/bic/data/QtMultimedia.4.7.0.linux-gcc-ia32.txt
Normal file
17075
tests/auto/bic/data/QtMultimedia.4.7.0.linux-gcc-ia32.txt
Normal file
File diff suppressed because it is too large
Load Diff
5
tests/auto/qabstractvideobuffer/qabstractvideobuffer.pro
Normal file
5
tests/auto/qabstractvideobuffer/qabstractvideobuffer.pro
Normal file
@@ -0,0 +1,5 @@
|
||||
load(qttest_p4)
|
||||
SOURCES += tst_qabstractvideobuffer.cpp
|
||||
|
||||
QT += multimedia
|
||||
requires(contains(QT_CONFIG, multimedia))
|
||||
132
tests/auto/qabstractvideobuffer/tst_qabstractvideobuffer.cpp
Normal file
132
tests/auto/qabstractvideobuffer/tst_qabstractvideobuffer.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include <QtMultimedia/QAbstractVideoBuffer>
|
||||
|
||||
class tst_QAbstractVideoBuffer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_QAbstractVideoBuffer();
|
||||
~tst_QAbstractVideoBuffer();
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void handleType_data();
|
||||
void handleType();
|
||||
void handle();
|
||||
};
|
||||
|
||||
class QtTestVideoBuffer : public QAbstractVideoBuffer
|
||||
{
|
||||
public:
|
||||
QtTestVideoBuffer(QAbstractVideoBuffer::HandleType type) : QAbstractVideoBuffer(type) {}
|
||||
|
||||
MapMode mapMode() const { return NotMapped; }
|
||||
|
||||
uchar *map(MapMode, int *, int *) { return 0; }
|
||||
void unmap() {}
|
||||
};
|
||||
|
||||
tst_QAbstractVideoBuffer::tst_QAbstractVideoBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
tst_QAbstractVideoBuffer::~tst_QAbstractVideoBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::cleanupTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::init()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::handleType_data()
|
||||
{
|
||||
QTest::addColumn<QAbstractVideoBuffer::HandleType>("type");
|
||||
|
||||
QTest::newRow("none")
|
||||
<< QAbstractVideoBuffer::NoHandle;
|
||||
QTest::newRow("opengl")
|
||||
<< QAbstractVideoBuffer::GLTextureHandle;
|
||||
QTest::newRow("user1")
|
||||
<< QAbstractVideoBuffer::UserHandle;
|
||||
QTest::newRow("user2")
|
||||
<< QAbstractVideoBuffer::HandleType(QAbstractVideoBuffer::UserHandle + 1);
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::handleType()
|
||||
{
|
||||
QFETCH(QAbstractVideoBuffer::HandleType, type);
|
||||
|
||||
QtTestVideoBuffer buffer(type);
|
||||
|
||||
QCOMPARE(buffer.handleType(), type);
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::handle()
|
||||
{
|
||||
QtTestVideoBuffer buffer(QAbstractVideoBuffer::NoHandle);
|
||||
|
||||
QVERIFY(buffer.handle().isNull());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAbstractVideoBuffer)
|
||||
|
||||
#include "tst_qabstractvideobuffer.moc"
|
||||
@@ -0,0 +1,5 @@
|
||||
load(qttest_p4)
|
||||
SOURCES += tst_qabstractvideosurface.cpp
|
||||
|
||||
QT += multimedia
|
||||
requires(contains(QT_CONFIG, multimedia))
|
||||
310
tests/auto/qabstractvideosurface/tst_qabstractvideosurface.cpp
Normal file
310
tests/auto/qabstractvideosurface/tst_qabstractvideosurface.cpp
Normal file
@@ -0,0 +1,310 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include <QtMultimedia/QAbstractVideoSurface>
|
||||
#include <QtMultimedia/QVideoSurfaceFormat>
|
||||
|
||||
class tst_QAbstractVideoSurface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_QAbstractVideoSurface();
|
||||
~tst_QAbstractVideoSurface();
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void setError();
|
||||
void isFormatSupported_data();
|
||||
void isFormatSupported();
|
||||
void nearestFormat_data();
|
||||
void nearestFormat();
|
||||
void start_data();
|
||||
void start();
|
||||
};
|
||||
|
||||
typedef QMap<QAbstractVideoBuffer::HandleType, QVideoFrame::PixelFormat> SupportedFormatMap;
|
||||
|
||||
Q_DECLARE_METATYPE(SupportedFormatMap)
|
||||
Q_DECLARE_METATYPE(QVideoSurfaceFormat)
|
||||
Q_DECLARE_METATYPE(QAbstractVideoSurface::Error);
|
||||
|
||||
class QtTestVideoSurface : public QAbstractVideoSurface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QtTestVideoSurface(QObject *parent = 0) : QAbstractVideoSurface(parent) {}
|
||||
explicit QtTestVideoSurface(SupportedFormatMap formats, QObject *parent = 0)
|
||||
: QAbstractVideoSurface(parent), supportedFormats(formats) {}
|
||||
|
||||
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const
|
||||
{
|
||||
return supportedFormats.values(handleType);
|
||||
}
|
||||
|
||||
bool present(const QVideoFrame &) { return false; }
|
||||
|
||||
using QAbstractVideoSurface::setError;
|
||||
|
||||
private:
|
||||
SupportedFormatMap supportedFormats;
|
||||
};
|
||||
|
||||
tst_QAbstractVideoSurface::tst_QAbstractVideoSurface()
|
||||
{
|
||||
}
|
||||
|
||||
tst_QAbstractVideoSurface::~tst_QAbstractVideoSurface()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::cleanupTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::init()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::setError()
|
||||
{
|
||||
qRegisterMetaType<QAbstractVideoSurface::Error>();
|
||||
|
||||
QtTestVideoSurface surface;
|
||||
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
|
||||
|
||||
surface.setError(QAbstractVideoSurface::StoppedError);
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::StoppedError);
|
||||
|
||||
surface.setError(QAbstractVideoSurface::ResourceError);
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::ResourceError);
|
||||
|
||||
surface.setError(QAbstractVideoSurface::NoError);
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::isFormatSupported_data()
|
||||
{
|
||||
QTest::addColumn<SupportedFormatMap>("supportedFormats");
|
||||
QTest::addColumn<QVideoSurfaceFormat>("format");
|
||||
QTest::addColumn<bool>("supported");
|
||||
|
||||
SupportedFormatMap formats;
|
||||
|
||||
QTest::newRow("no formats: rgb32")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB32)
|
||||
<< false;
|
||||
QTest::newRow("no formats: yv12")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12)
|
||||
<< false;
|
||||
QTest::newRow("no formats: rgb32 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB32,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< false;
|
||||
QTest::newRow("no formats: rgb24 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB24,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< false;
|
||||
|
||||
formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32);
|
||||
formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24);
|
||||
formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YUV444);
|
||||
formats.insertMulti(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB32);
|
||||
|
||||
QTest::newRow("supported: rgb32")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB32)
|
||||
<< true;
|
||||
QTest::newRow("supported: rgb24")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB24)
|
||||
<< true;
|
||||
QTest::newRow("unsupported: yv12")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12)
|
||||
<< false;
|
||||
QTest::newRow("supported: rgb32 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB32,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< true;
|
||||
QTest::newRow("unsupported: rgb24 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB24,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< false;
|
||||
QTest::newRow("unsupported: yv12 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_YV12,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< false;
|
||||
|
||||
formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YV12);
|
||||
formats.insertMulti(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB24);
|
||||
|
||||
QTest::newRow("supported: yv12")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12)
|
||||
<< true;
|
||||
QTest::newRow("supported: rgb24 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB24,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< true;
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::isFormatSupported()
|
||||
{
|
||||
QFETCH(SupportedFormatMap, supportedFormats);
|
||||
QFETCH(QVideoSurfaceFormat, format);
|
||||
QFETCH(bool, supported);
|
||||
|
||||
QtTestVideoSurface surface(supportedFormats);
|
||||
|
||||
QCOMPARE(surface.isFormatSupported(format), supported);
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::nearestFormat_data()
|
||||
{
|
||||
isFormatSupported_data();
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::nearestFormat()
|
||||
{
|
||||
QFETCH(SupportedFormatMap, supportedFormats);
|
||||
QFETCH(QVideoSurfaceFormat, format);
|
||||
QFETCH(bool, supported);
|
||||
|
||||
QtTestVideoSurface surface(supportedFormats);
|
||||
|
||||
QCOMPARE(surface.nearestFormat(format) == format, supported);
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::start_data()
|
||||
{
|
||||
QTest::addColumn<QVideoSurfaceFormat>("format");
|
||||
|
||||
QTest::newRow("rgb32") << QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB32);
|
||||
QTest::newRow("yv12") << QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_YV12);
|
||||
QTest::newRow("rgb32 gl") << QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB32,
|
||||
QAbstractVideoBuffer::GLTextureHandle);
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::start()
|
||||
{
|
||||
QFETCH(QVideoSurfaceFormat, format);
|
||||
|
||||
QtTestVideoSurface surface;
|
||||
surface.setError(QAbstractVideoSurface::ResourceError);
|
||||
|
||||
QSignalSpy formatSpy(&surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)));
|
||||
QSignalSpy activeSpy(&surface, SIGNAL(activeChanged(bool)));
|
||||
|
||||
QVERIFY(!surface.isActive());
|
||||
QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
|
||||
|
||||
QVERIFY(surface.start(format));
|
||||
|
||||
QVERIFY(surface.isActive());
|
||||
QCOMPARE(surface.surfaceFormat(), format);
|
||||
|
||||
QCOMPARE(formatSpy.count(), 1);
|
||||
QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), format);
|
||||
|
||||
QCOMPARE(activeSpy.count(), 1);
|
||||
QCOMPARE(activeSpy.last().at(0).toBool(), true);
|
||||
|
||||
// error() is reset on a successful start.
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
|
||||
|
||||
surface.stop();
|
||||
|
||||
QVERIFY(!surface.isActive());
|
||||
QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
|
||||
|
||||
QCOMPARE(formatSpy.count(), 2);
|
||||
QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), QVideoSurfaceFormat());
|
||||
|
||||
QCOMPARE(activeSpy.count(), 2);
|
||||
QCOMPARE(activeSpy.last().at(0).toBool(), false);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAbstractVideoSurface)
|
||||
|
||||
#include "tst_qabstractvideosurface.moc"
|
||||
7
tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro
Normal file
7
tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro
Normal file
@@ -0,0 +1,7 @@
|
||||
load(qttest_p4)
|
||||
|
||||
DEFINES += SRCDIR=\\\"$$PWD/\\\"
|
||||
|
||||
SOURCES += tst_qaudiodeviceinfo.cpp
|
||||
|
||||
QT = core multimedia
|
||||
194
tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
Normal file
194
tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
Normal file
@@ -0,0 +1,194 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore/qlocale.h>
|
||||
#include <qaudiodeviceinfo.h>
|
||||
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
|
||||
|
||||
class tst_QAudioDeviceInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_QAudioDeviceInfo(QObject* parent=0) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void checkAvailableDefaultInput();
|
||||
void checkAvailableDefaultOutput();
|
||||
void outputList();
|
||||
void codecs();
|
||||
void channels();
|
||||
void sampleSizes();
|
||||
void byteOrders();
|
||||
void sampleTypes();
|
||||
void frequencies();
|
||||
void isformat();
|
||||
void preferred();
|
||||
|
||||
private:
|
||||
bool available;
|
||||
QAudioDeviceInfo* device;
|
||||
};
|
||||
|
||||
void tst_QAudioDeviceInfo::initTestCase()
|
||||
{
|
||||
// Only perform tests if audio output device exists!
|
||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
if(devices.size() > 0)
|
||||
available = true;
|
||||
else {
|
||||
qWarning()<<"NOTE: no audio output device found, no test will be performed";
|
||||
available = false;
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::checkAvailableDefaultInput()
|
||||
{
|
||||
// Only perform tests if audio input device exists!
|
||||
bool storeAvailable = available;
|
||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
||||
if(devices.size() > 0)
|
||||
available = true;
|
||||
else {
|
||||
qWarning()<<"NOTE: no audio input device found, no test will be performed";
|
||||
available = false;
|
||||
}
|
||||
if(available)
|
||||
QVERIFY(!QAudioDeviceInfo::defaultInputDevice().isNull());
|
||||
available = storeAvailable;
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::checkAvailableDefaultOutput()
|
||||
{
|
||||
if(available)
|
||||
QVERIFY(!QAudioDeviceInfo::defaultOutputDevice().isNull());
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::outputList()
|
||||
{
|
||||
if(available) {
|
||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
QVERIFY(devices.size() > 0);
|
||||
device = new QAudioDeviceInfo(devices.at(0));
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::codecs()
|
||||
{
|
||||
if(available) {
|
||||
QStringList avail = device->supportedCodecs();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::channels()
|
||||
{
|
||||
if(available) {
|
||||
QList<int> avail = device->supportedChannels();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::sampleSizes()
|
||||
{
|
||||
if(available) {
|
||||
QList<int> avail = device->supportedSampleSizes();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::byteOrders()
|
||||
{
|
||||
if(available) {
|
||||
QList<QAudioFormat::Endian> avail = device->supportedByteOrders();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::sampleTypes()
|
||||
{
|
||||
if(available) {
|
||||
QList<QAudioFormat::SampleType> avail = device->supportedSampleTypes();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::frequencies()
|
||||
{
|
||||
if(available) {
|
||||
QList<int> avail = device->supportedFrequencies();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::isformat()
|
||||
{
|
||||
if(available) {
|
||||
QAudioFormat format;
|
||||
format.setFrequency(44100);
|
||||
format.setChannels(2);
|
||||
format.setSampleType(QAudioFormat::SignedInt);
|
||||
format.setByteOrder(QAudioFormat::LittleEndian);
|
||||
format.setSampleSize(16);
|
||||
format.setCodec("audio/pcm");
|
||||
|
||||
// Should always be true for these format
|
||||
QVERIFY(device->isFormatSupported(format));
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::preferred()
|
||||
{
|
||||
if(available) {
|
||||
QAudioFormat format = device->preferredFormat();
|
||||
QVERIFY(format.frequency() == 44100);
|
||||
QVERIFY(format.channels() == 2);
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAudioDeviceInfo)
|
||||
|
||||
#include "tst_qaudiodeviceinfo.moc"
|
||||
7
tests/auto/qaudioformat/qaudioformat.pro
Normal file
7
tests/auto/qaudioformat/qaudioformat.pro
Normal file
@@ -0,0 +1,7 @@
|
||||
load(qttest_p4)
|
||||
|
||||
DEFINES += SRCDIR=\\\"$$PWD/\\\"
|
||||
|
||||
SOURCES += tst_qaudioformat.cpp
|
||||
|
||||
QT = core multimedia
|
||||
183
tests/auto/qaudioformat/tst_qaudioformat.cpp
Normal file
183
tests/auto/qaudioformat/tst_qaudioformat.cpp
Normal file
@@ -0,0 +1,183 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore/qlocale.h>
|
||||
#include <qaudioformat.h>
|
||||
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
|
||||
|
||||
class tst_QAudioFormat : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tst_QAudioFormat(QObject* parent=0) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
void checkNull();
|
||||
void checkFrequency();
|
||||
void checkChannels();
|
||||
void checkSampleSize();
|
||||
void checkCodec();
|
||||
void checkByteOrder();
|
||||
void checkSampleType();
|
||||
void checkEquality();
|
||||
void checkAssignment();
|
||||
};
|
||||
|
||||
void tst_QAudioFormat::checkNull()
|
||||
{
|
||||
// Default constructed QAudioFormat is invalid.
|
||||
QAudioFormat audioFormat0;
|
||||
QVERIFY(!audioFormat0.isValid());
|
||||
|
||||
// validity is transferred
|
||||
QAudioFormat audioFormat1(audioFormat0);
|
||||
QVERIFY(!audioFormat1.isValid());
|
||||
|
||||
audioFormat0.setFrequency(44100);
|
||||
audioFormat0.setChannels(2);
|
||||
audioFormat0.setSampleSize(16);
|
||||
audioFormat0.setCodec("audio/pcm");
|
||||
audioFormat0.setSampleType(QAudioFormat::SignedInt);
|
||||
QVERIFY(audioFormat0.isValid());
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkFrequency()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setFrequency(44100);
|
||||
QVERIFY(audioFormat.frequency() == 44100);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkChannels()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setChannels(2);
|
||||
QVERIFY(audioFormat.channels() == 2);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkSampleSize()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setSampleSize(16);
|
||||
QVERIFY(audioFormat.sampleSize() == 16);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkCodec()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setCodec(QString::fromLatin1("audio/pcm"));
|
||||
QVERIFY(audioFormat.codec() == QString::fromLatin1("audio/pcm"));
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkByteOrder()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||
QVERIFY(audioFormat.byteOrder() == QAudioFormat::LittleEndian);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkSampleType()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setSampleType(QAudioFormat::SignedInt);
|
||||
QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkEquality()
|
||||
{
|
||||
QAudioFormat audioFormat0;
|
||||
QAudioFormat audioFormat1;
|
||||
|
||||
// Null formats are equivalent
|
||||
QVERIFY(audioFormat0 == audioFormat1);
|
||||
QVERIFY(!(audioFormat0 != audioFormat1));
|
||||
|
||||
// on filled formats
|
||||
audioFormat0.setFrequency(8000);
|
||||
audioFormat0.setChannels(1);
|
||||
audioFormat0.setSampleSize(8);
|
||||
audioFormat0.setCodec("audio/pcm");
|
||||
audioFormat0.setByteOrder(QAudioFormat::LittleEndian);
|
||||
audioFormat0.setSampleType(QAudioFormat::UnSignedInt);
|
||||
|
||||
audioFormat1.setFrequency(8000);
|
||||
audioFormat1.setChannels(1);
|
||||
audioFormat1.setSampleSize(8);
|
||||
audioFormat1.setCodec("audio/pcm");
|
||||
audioFormat1.setByteOrder(QAudioFormat::LittleEndian);
|
||||
audioFormat1.setSampleType(QAudioFormat::UnSignedInt);
|
||||
|
||||
QVERIFY(audioFormat0 == audioFormat1);
|
||||
QVERIFY(!(audioFormat0 != audioFormat1));
|
||||
|
||||
audioFormat0.setFrequency(44100);
|
||||
QVERIFY(audioFormat0 != audioFormat1);
|
||||
QVERIFY(!(audioFormat0 == audioFormat1));
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkAssignment()
|
||||
{
|
||||
QAudioFormat audioFormat0;
|
||||
QAudioFormat audioFormat1;
|
||||
|
||||
audioFormat0.setFrequency(8000);
|
||||
audioFormat0.setChannels(1);
|
||||
audioFormat0.setSampleSize(8);
|
||||
audioFormat0.setCodec("audio/pcm");
|
||||
audioFormat0.setByteOrder(QAudioFormat::LittleEndian);
|
||||
audioFormat0.setSampleType(QAudioFormat::UnSignedInt);
|
||||
|
||||
audioFormat1 = audioFormat0;
|
||||
QVERIFY(audioFormat1 == audioFormat0);
|
||||
|
||||
QAudioFormat audioFormat2(audioFormat0);
|
||||
QVERIFY(audioFormat2 == audioFormat0);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAudioFormat)
|
||||
|
||||
#include "tst_qaudioformat.moc"
|
||||
15
tests/auto/qaudioinput/qaudioinput.pro
Normal file
15
tests/auto/qaudioinput/qaudioinput.pro
Normal file
@@ -0,0 +1,15 @@
|
||||
load(qttest_p4)
|
||||
|
||||
SOURCES += tst_qaudioinput.cpp
|
||||
|
||||
QT = core multimedia
|
||||
|
||||
wince* {
|
||||
deploy.files += 4.wav
|
||||
DEPLOYMENT += deploy
|
||||
DEFINES += SRCDIR=\\\"\\\"
|
||||
QT += gui
|
||||
} else {
|
||||
!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\"
|
||||
}
|
||||
|
||||
222
tests/auto/qaudioinput/tst_qaudioinput.cpp
Normal file
222
tests/auto/qaudioinput/tst_qaudioinput.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore/qlocale.h>
|
||||
#include <qaudioinput.h>
|
||||
#include <qaudiodeviceinfo.h>
|
||||
#include <qaudio.h>
|
||||
#include <qaudioformat.h>
|
||||
|
||||
#if defined(Q_OS_SYMBIAN)
|
||||
#define SRCDIR ""
|
||||
#endif
|
||||
|
||||
Q_DECLARE_METATYPE(QAudioFormat)
|
||||
|
||||
class tst_QAudioInput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_QAudioInput(QObject* parent=0) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void invalidFormat_data();
|
||||
void invalidFormat();
|
||||
void settings();
|
||||
void buffers();
|
||||
void notifyInterval();
|
||||
void pullFile();
|
||||
|
||||
private:
|
||||
bool available;
|
||||
QAudioFormat format;
|
||||
QAudioInput* audio;
|
||||
};
|
||||
|
||||
void tst_QAudioInput::initTestCase()
|
||||
{
|
||||
qRegisterMetaType<QAudioFormat>();
|
||||
|
||||
format.setFrequency(8000);
|
||||
format.setChannels(1);
|
||||
format.setSampleSize(8);
|
||||
format.setCodec("audio/pcm");
|
||||
format.setByteOrder(QAudioFormat::LittleEndian);
|
||||
format.setSampleType(QAudioFormat::UnSignedInt);
|
||||
|
||||
// Only perform tests if audio input device exists!
|
||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
||||
if(devices.size() > 0)
|
||||
available = true;
|
||||
else {
|
||||
qWarning()<<"NOTE: no audio input device found, no test will be performed";
|
||||
available = false;
|
||||
}
|
||||
|
||||
if(available)
|
||||
audio = new QAudioInput(format, this);
|
||||
}
|
||||
|
||||
void tst_QAudioInput::invalidFormat_data()
|
||||
{
|
||||
QTest::addColumn<QAudioFormat>("invalidFormat");
|
||||
|
||||
QAudioFormat audioFormat;
|
||||
|
||||
QTest::newRow("Null Format")
|
||||
<< audioFormat;
|
||||
|
||||
audioFormat = format;
|
||||
audioFormat.setChannels(0);
|
||||
QTest::newRow("Channel count 0")
|
||||
<< audioFormat;
|
||||
|
||||
audioFormat = format;
|
||||
audioFormat.setFrequency(0);
|
||||
QTest::newRow("Sample rate 0")
|
||||
<< audioFormat;
|
||||
|
||||
audioFormat = format;
|
||||
audioFormat.setSampleSize(0);
|
||||
QTest::newRow("Sample size 0")
|
||||
<< audioFormat;
|
||||
}
|
||||
|
||||
void tst_QAudioInput::invalidFormat()
|
||||
{
|
||||
QFETCH(QAudioFormat, invalidFormat);
|
||||
|
||||
QAudioInput audioInput(invalidFormat, this);
|
||||
|
||||
// Check that we are in the default state before calling start
|
||||
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
|
||||
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
|
||||
|
||||
audioInput.start();
|
||||
|
||||
// Check that error is raised
|
||||
QVERIFY2((audioInput.error() == QAudio::OpenError),"error() was not set to QAudio::OpenError after start()");
|
||||
}
|
||||
|
||||
void tst_QAudioInput::settings()
|
||||
{
|
||||
if(available) {
|
||||
// Confirm the setting we added in the init function.
|
||||
QAudioFormat f = audio->format();
|
||||
|
||||
QVERIFY(format.channels() == f.channels());
|
||||
QVERIFY(format.frequency() == f.frequency());
|
||||
QVERIFY(format.sampleSize() == f.sampleSize());
|
||||
QVERIFY(format.codec() == f.codec());
|
||||
QVERIFY(format.byteOrder() == f.byteOrder());
|
||||
QVERIFY(format.sampleType() == f.sampleType());
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioInput::buffers()
|
||||
{
|
||||
if(available) {
|
||||
// Should always have a buffer size greater than zero.
|
||||
int store = audio->bufferSize();
|
||||
audio->setBufferSize(4096);
|
||||
QVERIFY(audio->bufferSize() > 0);
|
||||
audio->setBufferSize(store);
|
||||
QVERIFY(audio->bufferSize() == store);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioInput::notifyInterval()
|
||||
{
|
||||
if(available) {
|
||||
QVERIFY(audio->notifyInterval() == 1000); // Default
|
||||
|
||||
audio->setNotifyInterval(500);
|
||||
QVERIFY(audio->notifyInterval() == 500); // Custom
|
||||
|
||||
audio->setNotifyInterval(1000); // reset
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioInput::pullFile()
|
||||
{
|
||||
if(available) {
|
||||
QFile filename(SRCDIR"test.raw");
|
||||
filename.open( QIODevice::WriteOnly | QIODevice::Truncate );
|
||||
|
||||
QSignalSpy readSignal(audio, SIGNAL(notify()));
|
||||
QSignalSpy stateSignal(audio, SIGNAL(stateChanged(QAudio::State)));
|
||||
|
||||
// Always have default states, before start
|
||||
QVERIFY(audio->state() == QAudio::StoppedState);
|
||||
QVERIFY(audio->error() == QAudio::NoError);
|
||||
QVERIFY(audio->elapsedUSecs() == 0);
|
||||
|
||||
audio->start(&filename);
|
||||
QTest::qWait(20);
|
||||
// Check state and periodSize() are valid non-zero values.
|
||||
QVERIFY(audio->state() == QAudio::ActiveState);
|
||||
QVERIFY(audio->error() == QAudio::NoError);
|
||||
QVERIFY(audio->elapsedUSecs() > 10000 && audio->elapsedUSecs() < 800000);
|
||||
QVERIFY(audio->periodSize() > 0);
|
||||
QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState
|
||||
|
||||
// Wait until finished...
|
||||
QTest::qWait(5000);
|
||||
|
||||
QVERIFY(readSignal.count() > 0);
|
||||
QVERIFY(audio->processedUSecs() > 0);
|
||||
|
||||
audio->stop();
|
||||
QTest::qWait(20);
|
||||
QVERIFY(audio->state() == QAudio::StoppedState);
|
||||
QVERIFY(audio->elapsedUSecs() == 0);
|
||||
// Can only check to make sure we got at least 1 more signal, but can be more.
|
||||
QVERIFY(stateSignal.count() > 1);
|
||||
|
||||
filename.close();
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAudioInput)
|
||||
|
||||
#include "tst_qaudioinput.moc"
|
||||
BIN
tests/auto/qaudiooutput/4.wav
Normal file
BIN
tests/auto/qaudiooutput/4.wav
Normal file
Binary file not shown.
16
tests/auto/qaudiooutput/qaudiooutput.pro
Normal file
16
tests/auto/qaudiooutput/qaudiooutput.pro
Normal file
@@ -0,0 +1,16 @@
|
||||
load(qttest_p4)
|
||||
|
||||
SOURCES += tst_qaudiooutput.cpp
|
||||
|
||||
QT = core multimedia
|
||||
|
||||
wince*|symbian: {
|
||||
deploy.files += 4.wav
|
||||
DEPLOYMENT += deploy
|
||||
!symbian {
|
||||
DEFINES += SRCDIR=\\\"\\\"
|
||||
QT += gui
|
||||
}
|
||||
} else {
|
||||
DEFINES += SRCDIR=\\\"$$PWD/\\\"
|
||||
}
|
||||
263
tests/auto/qaudiooutput/tst_qaudiooutput.cpp
Normal file
263
tests/auto/qaudiooutput/tst_qaudiooutput.cpp
Normal file
@@ -0,0 +1,263 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore/qlocale.h>
|
||||
#include <qaudiooutput.h>
|
||||
#include <qaudiodeviceinfo.h>
|
||||
#include <qaudio.h>
|
||||
#include <qaudioformat.h>
|
||||
|
||||
#if defined(Q_OS_SYMBIAN)
|
||||
#define SRCDIR ""
|
||||
#endif
|
||||
|
||||
Q_DECLARE_METATYPE(QAudioFormat)
|
||||
|
||||
class tst_QAudioOutput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_QAudioOutput(QObject* parent=0) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void invalidFormat_data();
|
||||
void invalidFormat();
|
||||
void settings();
|
||||
void buffers();
|
||||
void notifyInterval();
|
||||
void pullFile();
|
||||
void pushFile();
|
||||
|
||||
private:
|
||||
bool available;
|
||||
QAudioFormat format;
|
||||
QAudioOutput* audio;
|
||||
};
|
||||
|
||||
void tst_QAudioOutput::initTestCase()
|
||||
{
|
||||
qRegisterMetaType<QAudioFormat>();
|
||||
|
||||
format.setFrequency(8000);
|
||||
format.setChannels(1);
|
||||
format.setSampleSize(8);
|
||||
format.setCodec("audio/pcm");
|
||||
format.setByteOrder(QAudioFormat::LittleEndian);
|
||||
format.setSampleType(QAudioFormat::UnSignedInt);
|
||||
|
||||
// Only perform tests if audio output device exists!
|
||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
if(devices.size() > 0)
|
||||
available = true;
|
||||
else {
|
||||
qWarning()<<"NOTE: no audio output device found, no test will be performed";
|
||||
available = false;
|
||||
}
|
||||
audio = new QAudioOutput(format, this);
|
||||
}
|
||||
|
||||
void tst_QAudioOutput::invalidFormat_data()
|
||||
{
|
||||
QTest::addColumn<QAudioFormat>("invalidFormat");
|
||||
|
||||
QAudioFormat audioFormat;
|
||||
|
||||
QTest::newRow("Null Format")
|
||||
<< audioFormat;
|
||||
|
||||
audioFormat = format;
|
||||
audioFormat.setChannels(0);
|
||||
QTest::newRow("Channel count 0")
|
||||
<< audioFormat;
|
||||
|
||||
audioFormat = format;
|
||||
audioFormat.setFrequency(0);
|
||||
QTest::newRow("Sample rate 0")
|
||||
<< audioFormat;
|
||||
|
||||
audioFormat = format;
|
||||
audioFormat.setSampleSize(0);
|
||||
QTest::newRow("Sample size 0")
|
||||
<< audioFormat;
|
||||
}
|
||||
|
||||
void tst_QAudioOutput::invalidFormat()
|
||||
{
|
||||
QFETCH(QAudioFormat, invalidFormat);
|
||||
|
||||
QAudioOutput audioOutput(invalidFormat, this);
|
||||
|
||||
// Check that we are in the default state before calling start
|
||||
QVERIFY2((audioOutput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
|
||||
QVERIFY2((audioOutput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
|
||||
|
||||
audioOutput.start();
|
||||
|
||||
// Check that error is raised
|
||||
QVERIFY2((audioOutput.error() == QAudio::OpenError),"error() was not set to QAudio::OpenError after start()");
|
||||
}
|
||||
|
||||
void tst_QAudioOutput::settings()
|
||||
{
|
||||
if(available) {
|
||||
// Confirm the setting we added in the init function.
|
||||
QAudioFormat f = audio->format();
|
||||
|
||||
QVERIFY(format.channels() == f.channels());
|
||||
QVERIFY(format.frequency() == f.frequency());
|
||||
QVERIFY(format.sampleSize() == f.sampleSize());
|
||||
QVERIFY(format.codec() == f.codec());
|
||||
QVERIFY(format.byteOrder() == f.byteOrder());
|
||||
QVERIFY(format.sampleType() == f.sampleType());
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioOutput::buffers()
|
||||
{
|
||||
if(available) {
|
||||
// Should always have a buffer size greater than zero.
|
||||
int store = audio->bufferSize();
|
||||
audio->setBufferSize(4096);
|
||||
QVERIFY(audio->bufferSize() > 0);
|
||||
audio->setBufferSize(store);
|
||||
QVERIFY(audio->bufferSize() == store);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioOutput::notifyInterval()
|
||||
{
|
||||
if(available) {
|
||||
QVERIFY(audio->notifyInterval() == 1000); // Default
|
||||
|
||||
audio->setNotifyInterval(500);
|
||||
QVERIFY(audio->notifyInterval() == 500); // Custom
|
||||
|
||||
audio->setNotifyInterval(1000); // reset
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioOutput::pullFile()
|
||||
{
|
||||
if(available) {
|
||||
QFile file(SRCDIR"4.wav");
|
||||
QVERIFY(file.exists());
|
||||
file.open(QIODevice::ReadOnly);
|
||||
|
||||
QSignalSpy readSignal(audio, SIGNAL(notify()));
|
||||
QSignalSpy stateSignal(audio, SIGNAL(stateChanged(QAudio::State)));
|
||||
audio->setNotifyInterval(100);
|
||||
|
||||
// Always have default states, before start
|
||||
QVERIFY(audio->state() == QAudio::StoppedState);
|
||||
QVERIFY(audio->error() == QAudio::NoError);
|
||||
QVERIFY(audio->elapsedUSecs() == 0);
|
||||
|
||||
audio->start(&file);
|
||||
QTest::qWait(20); // wait 20ms
|
||||
// Check state, bytesFree() and periodSize() are valid non-zero values.
|
||||
QVERIFY(audio->state() == QAudio::ActiveState);
|
||||
QVERIFY(audio->error() == QAudio::NoError);
|
||||
QVERIFY(audio->periodSize() > 0);
|
||||
QVERIFY(audio->elapsedUSecs() > 10000 && audio->elapsedUSecs() < 800000);
|
||||
QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState
|
||||
|
||||
// Wait until finished...
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
QCOMPARE(audio->processedUSecs(), qint64(692250));
|
||||
|
||||
#ifdef Q_OS_WINCE
|
||||
// 4.wav is a little less than 700ms, so notify should fire 4 times on Wince!
|
||||
QVERIFY(readSignal.count() >= 4);
|
||||
#else
|
||||
// 4.wav is a little less than 700ms, so notify should fire 6 times!
|
||||
QVERIFY(readSignal.count() >= 6);
|
||||
#endif
|
||||
audio->stop();
|
||||
QTest::qWait(20); // wait 20ms
|
||||
QVERIFY(audio->state() == QAudio::StoppedState);
|
||||
QVERIFY(audio->elapsedUSecs() == 0);
|
||||
// Can only check to make sure we got at least 1 more signal, but can be more.
|
||||
QVERIFY(stateSignal.count() > 1);
|
||||
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioOutput::pushFile()
|
||||
{
|
||||
if(available) {
|
||||
QFile file(SRCDIR"4.wav");
|
||||
QVERIFY(file.exists());
|
||||
file.open(QIODevice::ReadOnly);
|
||||
|
||||
const qint64 fileSize = file.size();
|
||||
|
||||
QIODevice* feed = audio->start();
|
||||
|
||||
char* buffer = new char[fileSize];
|
||||
file.read(buffer, fileSize);
|
||||
|
||||
qint64 counter=0;
|
||||
qint64 written=0;
|
||||
while(written < fileSize) {
|
||||
written+=feed->write(buffer+written,fileSize-written);
|
||||
QTest::qWait(20);
|
||||
counter++;
|
||||
}
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QVERIFY(written == fileSize);
|
||||
QVERIFY(audio->processedUSecs() == 692250);
|
||||
|
||||
audio->stop();
|
||||
file.close();
|
||||
delete [] buffer;
|
||||
delete audio;
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAudioOutput)
|
||||
|
||||
#include "tst_qaudiooutput.moc"
|
||||
5
tests/auto/qvideoframe/qvideoframe.pro
Normal file
5
tests/auto/qvideoframe/qvideoframe.pro
Normal file
@@ -0,0 +1,5 @@
|
||||
load(qttest_p4)
|
||||
SOURCES += tst_qvideoframe.cpp
|
||||
|
||||
QT += multimedia
|
||||
requires(contains(QT_CONFIG, multimedia))
|
||||
791
tests/auto/qvideoframe/tst_qvideoframe.cpp
Normal file
791
tests/auto/qvideoframe/tst_qvideoframe.cpp
Normal file
@@ -0,0 +1,791 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include <QtMultimedia/QVideoFrame>
|
||||
#include <QtGui/QImage>
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
class tst_QVideoFrame : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_QVideoFrame();
|
||||
~tst_QVideoFrame();
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void create_data();
|
||||
void create();
|
||||
void createInvalid_data();
|
||||
void createInvalid();
|
||||
void createFromBuffer_data();
|
||||
void createFromBuffer();
|
||||
void createFromImage_data();
|
||||
void createFromImage();
|
||||
void createFromIncompatibleImage();
|
||||
void createNull();
|
||||
void destructor();
|
||||
void copy_data();
|
||||
void copy();
|
||||
void assign_data();
|
||||
void assign();
|
||||
void map_data();
|
||||
void map();
|
||||
void mapImage_data();
|
||||
void mapImage();
|
||||
void imageDetach();
|
||||
void formatConversion_data();
|
||||
void formatConversion();
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(QImage::Format)
|
||||
Q_DECLARE_METATYPE(QVideoFrame)
|
||||
|
||||
class QtTestVideoBuffer : public QObject, public QAbstractVideoBuffer
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtTestVideoBuffer()
|
||||
: QAbstractVideoBuffer(NoHandle) {}
|
||||
explicit QtTestVideoBuffer(QAbstractVideoBuffer::HandleType type)
|
||||
: QAbstractVideoBuffer(type) {}
|
||||
|
||||
MapMode mapMode() const { return NotMapped; }
|
||||
|
||||
uchar *map(MapMode, int *, int *) { return 0; }
|
||||
void unmap() {}
|
||||
};
|
||||
|
||||
tst_QVideoFrame::tst_QVideoFrame()
|
||||
{
|
||||
}
|
||||
|
||||
tst_QVideoFrame::~tst_QVideoFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::cleanupTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::init()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::create_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("size");
|
||||
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
|
||||
QTest::addColumn<int>("bytes");
|
||||
QTest::addColumn<int>("bytesPerLine");
|
||||
|
||||
QTest::newRow("64x64 ARGB32")
|
||||
<< QSize(64, 64)
|
||||
<< QVideoFrame::Format_ARGB32
|
||||
<< 16384
|
||||
<< 256;
|
||||
QTest::newRow("32x256 YUV420P")
|
||||
<< QSize(32, 256)
|
||||
<< QVideoFrame::Format_YUV420P
|
||||
<< 13288
|
||||
<< 32;
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::create()
|
||||
{
|
||||
QFETCH(QSize, size);
|
||||
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
||||
QFETCH(int, bytes);
|
||||
QFETCH(int, bytesPerLine);
|
||||
|
||||
QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat);
|
||||
|
||||
QVERIFY(frame.isValid());
|
||||
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(frame.size(), size);
|
||||
QCOMPARE(frame.width(), size.width());
|
||||
QCOMPARE(frame.height(), size.height());
|
||||
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
|
||||
QCOMPARE(frame.startTime(), qint64(-1));
|
||||
QCOMPARE(frame.endTime(), qint64(-1));
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::createInvalid_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("size");
|
||||
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
|
||||
QTest::addColumn<int>("bytes");
|
||||
QTest::addColumn<int>("bytesPerLine");
|
||||
|
||||
QTest::newRow("64x64 ARGB32 0 size")
|
||||
<< QSize(64, 64)
|
||||
<< QVideoFrame::Format_ARGB32
|
||||
<< 0
|
||||
<< 45;
|
||||
QTest::newRow("32x256 YUV420P negative size")
|
||||
<< QSize(32, 256)
|
||||
<< QVideoFrame::Format_YUV420P
|
||||
<< -13288
|
||||
<< 32;
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::createInvalid()
|
||||
{
|
||||
QFETCH(QSize, size);
|
||||
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
||||
QFETCH(int, bytes);
|
||||
QFETCH(int, bytesPerLine);
|
||||
|
||||
QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat);
|
||||
|
||||
QVERIFY(!frame.isValid());
|
||||
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(frame.size(), size);
|
||||
QCOMPARE(frame.width(), size.width());
|
||||
QCOMPARE(frame.height(), size.height());
|
||||
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
|
||||
QCOMPARE(frame.startTime(), qint64(-1));
|
||||
QCOMPARE(frame.endTime(), qint64(-1));
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::createFromBuffer_data()
|
||||
{
|
||||
QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType");
|
||||
QTest::addColumn<QSize>("size");
|
||||
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
|
||||
|
||||
QTest::newRow("64x64 ARGB32 no handle")
|
||||
<< QAbstractVideoBuffer::NoHandle
|
||||
<< QSize(64, 64)
|
||||
<< QVideoFrame::Format_ARGB32;
|
||||
QTest::newRow("64x64 ARGB32 gl handle")
|
||||
<< QAbstractVideoBuffer::GLTextureHandle
|
||||
<< QSize(64, 64)
|
||||
<< QVideoFrame::Format_ARGB32;
|
||||
QTest::newRow("64x64 ARGB32 user handle")
|
||||
<< QAbstractVideoBuffer::UserHandle
|
||||
<< QSize(64, 64)
|
||||
<< QVideoFrame::Format_ARGB32;
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::createFromBuffer()
|
||||
{
|
||||
QFETCH(QAbstractVideoBuffer::HandleType, handleType);
|
||||
QFETCH(QSize, size);
|
||||
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
||||
|
||||
QVideoFrame frame(new QtTestVideoBuffer(handleType), size, pixelFormat);
|
||||
|
||||
QVERIFY(frame.isValid());
|
||||
QCOMPARE(frame.handleType(), handleType);
|
||||
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(frame.size(), size);
|
||||
QCOMPARE(frame.width(), size.width());
|
||||
QCOMPARE(frame.height(), size.height());
|
||||
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
|
||||
QCOMPARE(frame.startTime(), qint64(-1));
|
||||
QCOMPARE(frame.endTime(), qint64(-1));
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::createFromImage_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("size");
|
||||
QTest::addColumn<QImage::Format>("imageFormat");
|
||||
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
|
||||
|
||||
QTest::newRow("64x64 RGB32")
|
||||
<< QSize(64, 64)
|
||||
<< QImage::Format_RGB32
|
||||
<< QVideoFrame::Format_RGB32;
|
||||
QTest::newRow("12x45 RGB16")
|
||||
<< QSize(12, 45)
|
||||
<< QImage::Format_RGB16
|
||||
<< QVideoFrame::Format_RGB565;
|
||||
QTest::newRow("19x46 ARGB32_Premultiplied")
|
||||
<< QSize(19, 46)
|
||||
<< QImage::Format_ARGB32_Premultiplied
|
||||
<< QVideoFrame::Format_ARGB32_Premultiplied;
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::createFromImage()
|
||||
{
|
||||
QFETCH(QSize, size);
|
||||
QFETCH(QImage::Format, imageFormat);
|
||||
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
||||
|
||||
const QImage image(size.width(), size.height(), imageFormat);
|
||||
|
||||
QVideoFrame frame(image);
|
||||
|
||||
QVERIFY(frame.isValid());
|
||||
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(frame.size(), size);
|
||||
QCOMPARE(frame.width(), size.width());
|
||||
QCOMPARE(frame.height(), size.height());
|
||||
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
|
||||
QCOMPARE(frame.startTime(), qint64(-1));
|
||||
QCOMPARE(frame.endTime(), qint64(-1));
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::createFromIncompatibleImage()
|
||||
{
|
||||
const QImage image(64, 64, QImage::Format_Mono);
|
||||
|
||||
QVideoFrame frame(image);
|
||||
|
||||
QVERIFY(!frame.isValid());
|
||||
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||
QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid);
|
||||
QCOMPARE(frame.size(), QSize(64, 64));
|
||||
QCOMPARE(frame.width(), 64);
|
||||
QCOMPARE(frame.height(), 64);
|
||||
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
|
||||
QCOMPARE(frame.startTime(), qint64(-1));
|
||||
QCOMPARE(frame.endTime(), qint64(-1));
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::createNull()
|
||||
{
|
||||
QVideoFrame frame;
|
||||
|
||||
QVERIFY(!frame.isValid());
|
||||
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||
QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid);
|
||||
QCOMPARE(frame.size(), QSize());
|
||||
QCOMPARE(frame.width(), -1);
|
||||
QCOMPARE(frame.height(), -1);
|
||||
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
|
||||
QCOMPARE(frame.startTime(), qint64(-1));
|
||||
QCOMPARE(frame.endTime(), qint64(-1));
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::destructor()
|
||||
{
|
||||
QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer;
|
||||
|
||||
{
|
||||
QVideoFrame frame(buffer, QSize(4, 1), QVideoFrame::Format_ARGB32);
|
||||
}
|
||||
|
||||
QVERIFY(buffer.isNull());
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::copy_data()
|
||||
{
|
||||
QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType");
|
||||
QTest::addColumn<QSize>("size");
|
||||
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
|
||||
QTest::addColumn<QVideoFrame::FieldType>("fieldType");
|
||||
QTest::addColumn<qint64>("startTime");
|
||||
QTest::addColumn<qint64>("endTime");
|
||||
|
||||
QTest::newRow("64x64 ARGB32")
|
||||
<< QAbstractVideoBuffer::GLTextureHandle
|
||||
<< QSize(64, 64)
|
||||
<< QVideoFrame::Format_ARGB32
|
||||
<< QVideoFrame::TopField
|
||||
<< qint64(63641740)
|
||||
<< qint64(63641954);
|
||||
QTest::newRow("32x256 YUV420P")
|
||||
<< QAbstractVideoBuffer::UserHandle
|
||||
<< QSize(32, 256)
|
||||
<< QVideoFrame::Format_YUV420P
|
||||
<< QVideoFrame::InterlacedFrame
|
||||
<< qint64(12345)
|
||||
<< qint64(12389);
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::copy()
|
||||
{
|
||||
QFETCH(QAbstractVideoBuffer::HandleType, handleType);
|
||||
QFETCH(QSize, size);
|
||||
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
||||
QFETCH(QVideoFrame::FieldType, fieldType);
|
||||
QFETCH(qint64, startTime);
|
||||
QFETCH(qint64, endTime);
|
||||
|
||||
QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType);
|
||||
|
||||
{
|
||||
QVideoFrame frame(buffer, size, pixelFormat);
|
||||
frame.setFieldType(QVideoFrame::FieldType(fieldType));
|
||||
frame.setStartTime(startTime);
|
||||
frame.setEndTime(endTime);
|
||||
|
||||
QVERIFY(frame.isValid());
|
||||
QCOMPARE(frame.handleType(), handleType);
|
||||
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(frame.size(), size);
|
||||
QCOMPARE(frame.width(), size.width());
|
||||
QCOMPARE(frame.height(), size.height());
|
||||
QCOMPARE(frame.fieldType(), fieldType);
|
||||
QCOMPARE(frame.startTime(), startTime);
|
||||
QCOMPARE(frame.endTime(), endTime);
|
||||
|
||||
{
|
||||
QVideoFrame otherFrame(frame);
|
||||
|
||||
QVERIFY(!buffer.isNull());
|
||||
|
||||
QVERIFY(otherFrame.isValid());
|
||||
QCOMPARE(otherFrame.handleType(), handleType);
|
||||
QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(otherFrame.size(), size);
|
||||
QCOMPARE(otherFrame.width(), size.width());
|
||||
QCOMPARE(otherFrame.height(), size.height());
|
||||
QCOMPARE(otherFrame.fieldType(), fieldType);
|
||||
QCOMPARE(otherFrame.startTime(), startTime);
|
||||
QCOMPARE(otherFrame.endTime(), endTime);
|
||||
|
||||
otherFrame.setEndTime(-1);
|
||||
|
||||
QVERIFY(!buffer.isNull());
|
||||
|
||||
QVERIFY(otherFrame.isValid());
|
||||
QCOMPARE(otherFrame.handleType(), handleType);
|
||||
QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(otherFrame.size(), size);
|
||||
QCOMPARE(otherFrame.width(), size.width());
|
||||
QCOMPARE(otherFrame.height(), size.height());
|
||||
QCOMPARE(otherFrame.fieldType(), fieldType);
|
||||
QCOMPARE(otherFrame.startTime(), startTime);
|
||||
QCOMPARE(otherFrame.endTime(), qint64(-1));
|
||||
}
|
||||
|
||||
QVERIFY(!buffer.isNull());
|
||||
|
||||
QVERIFY(frame.isValid());
|
||||
QCOMPARE(frame.handleType(), handleType);
|
||||
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(frame.size(), size);
|
||||
QCOMPARE(frame.width(), size.width());
|
||||
QCOMPARE(frame.height(), size.height());
|
||||
QCOMPARE(frame.fieldType(), fieldType);
|
||||
QCOMPARE(frame.startTime(), startTime);
|
||||
QCOMPARE(frame.endTime(), qint64(-1)); // Explicitly shared.
|
||||
}
|
||||
|
||||
QVERIFY(buffer.isNull());
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::assign_data()
|
||||
{
|
||||
QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType");
|
||||
QTest::addColumn<QSize>("size");
|
||||
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
|
||||
QTest::addColumn<QVideoFrame::FieldType>("fieldType");
|
||||
QTest::addColumn<qint64>("startTime");
|
||||
QTest::addColumn<qint64>("endTime");
|
||||
|
||||
QTest::newRow("64x64 ARGB32")
|
||||
<< QAbstractVideoBuffer::GLTextureHandle
|
||||
<< QSize(64, 64)
|
||||
<< QVideoFrame::Format_ARGB32
|
||||
<< QVideoFrame::TopField
|
||||
<< qint64(63641740)
|
||||
<< qint64(63641954);
|
||||
QTest::newRow("32x256 YUV420P")
|
||||
<< QAbstractVideoBuffer::UserHandle
|
||||
<< QSize(32, 256)
|
||||
<< QVideoFrame::Format_YUV420P
|
||||
<< QVideoFrame::InterlacedFrame
|
||||
<< qint64(12345)
|
||||
<< qint64(12389);
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::assign()
|
||||
{
|
||||
QFETCH(QAbstractVideoBuffer::HandleType, handleType);
|
||||
QFETCH(QSize, size);
|
||||
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
||||
QFETCH(QVideoFrame::FieldType, fieldType);
|
||||
QFETCH(qint64, startTime);
|
||||
QFETCH(qint64, endTime);
|
||||
|
||||
QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType);
|
||||
|
||||
QVideoFrame frame;
|
||||
{
|
||||
QVideoFrame otherFrame(buffer, size, pixelFormat);
|
||||
otherFrame.setFieldType(fieldType);
|
||||
otherFrame.setStartTime(startTime);
|
||||
otherFrame.setEndTime(endTime);
|
||||
|
||||
frame = otherFrame;
|
||||
|
||||
QVERIFY(!buffer.isNull());
|
||||
|
||||
QVERIFY(otherFrame.isValid());
|
||||
QCOMPARE(otherFrame.handleType(), handleType);
|
||||
QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(otherFrame.size(), size);
|
||||
QCOMPARE(otherFrame.width(), size.width());
|
||||
QCOMPARE(otherFrame.height(), size.height());
|
||||
QCOMPARE(otherFrame.fieldType(), fieldType);
|
||||
QCOMPARE(otherFrame.startTime(), startTime);
|
||||
QCOMPARE(otherFrame.endTime(), endTime);
|
||||
|
||||
otherFrame.setStartTime(-1);
|
||||
|
||||
QVERIFY(!buffer.isNull());
|
||||
|
||||
QVERIFY(otherFrame.isValid());
|
||||
QCOMPARE(otherFrame.handleType(), handleType);
|
||||
QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(otherFrame.size(), size);
|
||||
QCOMPARE(otherFrame.width(), size.width());
|
||||
QCOMPARE(otherFrame.height(), size.height());
|
||||
QCOMPARE(otherFrame.fieldType(), fieldType);
|
||||
QCOMPARE(otherFrame.startTime(), qint64(-1));
|
||||
QCOMPARE(otherFrame.endTime(), endTime);
|
||||
}
|
||||
|
||||
QVERIFY(!buffer.isNull());
|
||||
|
||||
QVERIFY(frame.isValid());
|
||||
QCOMPARE(frame.handleType(), handleType);
|
||||
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(frame.size(), size);
|
||||
QCOMPARE(frame.width(), size.width());
|
||||
QCOMPARE(frame.height(), size.height());
|
||||
QCOMPARE(frame.fieldType(), fieldType);
|
||||
QCOMPARE(frame.startTime(), qint64(-1));
|
||||
QCOMPARE(frame.endTime(), endTime);
|
||||
|
||||
frame = QVideoFrame();
|
||||
|
||||
QVERIFY(buffer.isNull());
|
||||
|
||||
QVERIFY(!frame.isValid());
|
||||
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||
QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid);
|
||||
QCOMPARE(frame.size(), QSize());
|
||||
QCOMPARE(frame.width(), -1);
|
||||
QCOMPARE(frame.height(), -1);
|
||||
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
|
||||
QCOMPARE(frame.startTime(), qint64(-1));
|
||||
QCOMPARE(frame.endTime(), qint64(-1));
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::map_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("size");
|
||||
QTest::addColumn<int>("mappedBytes");
|
||||
QTest::addColumn<int>("bytesPerLine");
|
||||
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
|
||||
QTest::addColumn<QAbstractVideoBuffer::MapMode>("mode");
|
||||
|
||||
QTest::newRow("read-only")
|
||||
<< QSize(64, 64)
|
||||
<< 16384
|
||||
<< 256
|
||||
<< QVideoFrame::Format_ARGB32
|
||||
<< QAbstractVideoBuffer::ReadOnly;
|
||||
|
||||
QTest::newRow("write-only")
|
||||
<< QSize(64, 64)
|
||||
<< 16384
|
||||
<< 256
|
||||
<< QVideoFrame::Format_ARGB32
|
||||
<< QAbstractVideoBuffer::WriteOnly;
|
||||
|
||||
QTest::newRow("read-write")
|
||||
<< QSize(64, 64)
|
||||
<< 16384
|
||||
<< 256
|
||||
<< QVideoFrame::Format_ARGB32
|
||||
<< QAbstractVideoBuffer::ReadWrite;
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::map()
|
||||
{
|
||||
QFETCH(QSize, size);
|
||||
QFETCH(int, mappedBytes);
|
||||
QFETCH(int, bytesPerLine);
|
||||
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
||||
QFETCH(QAbstractVideoBuffer::MapMode, mode);
|
||||
|
||||
QVideoFrame frame(mappedBytes, size, bytesPerLine, pixelFormat);
|
||||
|
||||
QVERIFY(!frame.bits());
|
||||
QCOMPARE(frame.mappedBytes(), 0);
|
||||
QCOMPARE(frame.bytesPerLine(), 0);
|
||||
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
|
||||
|
||||
QVERIFY(frame.map(mode));
|
||||
|
||||
QVERIFY(frame.bits());
|
||||
QCOMPARE(frame.mappedBytes(), mappedBytes);
|
||||
QCOMPARE(frame.bytesPerLine(), bytesPerLine);
|
||||
QCOMPARE(frame.mapMode(), mode);
|
||||
|
||||
frame.unmap();
|
||||
|
||||
QVERIFY(!frame.bits());
|
||||
QCOMPARE(frame.mappedBytes(), 0);
|
||||
QCOMPARE(frame.bytesPerLine(), 0);
|
||||
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::mapImage_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("size");
|
||||
QTest::addColumn<QImage::Format>("format");
|
||||
QTest::addColumn<QAbstractVideoBuffer::MapMode>("mode");
|
||||
|
||||
QTest::newRow("read-only")
|
||||
<< QSize(64, 64)
|
||||
<< QImage::Format_ARGB32
|
||||
<< QAbstractVideoBuffer::ReadOnly;
|
||||
|
||||
QTest::newRow("write-only")
|
||||
<< QSize(15, 106)
|
||||
<< QImage::Format_RGB32
|
||||
<< QAbstractVideoBuffer::WriteOnly;
|
||||
|
||||
QTest::newRow("read-write")
|
||||
<< QSize(23, 111)
|
||||
<< QImage::Format_RGB16
|
||||
<< QAbstractVideoBuffer::ReadWrite;
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::mapImage()
|
||||
{
|
||||
QFETCH(QSize, size);
|
||||
QFETCH(QImage::Format, format);
|
||||
QFETCH(QAbstractVideoBuffer::MapMode, mode);
|
||||
|
||||
QImage image(size.width(), size.height(), format);
|
||||
|
||||
QVideoFrame frame(image);
|
||||
|
||||
QVERIFY(!frame.bits());
|
||||
QCOMPARE(frame.mappedBytes(), 0);
|
||||
QCOMPARE(frame.bytesPerLine(), 0);
|
||||
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
|
||||
|
||||
QVERIFY(frame.map(mode));
|
||||
|
||||
QVERIFY(frame.bits());
|
||||
QCOMPARE(frame.mappedBytes(), image.numBytes());
|
||||
QCOMPARE(frame.bytesPerLine(), image.bytesPerLine());
|
||||
QCOMPARE(frame.mapMode(), mode);
|
||||
|
||||
frame.unmap();
|
||||
|
||||
QVERIFY(!frame.bits());
|
||||
QCOMPARE(frame.mappedBytes(), 0);
|
||||
QCOMPARE(frame.bytesPerLine(), 0);
|
||||
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::imageDetach()
|
||||
{
|
||||
const uint red = qRgb(255, 0, 0);
|
||||
const uint blue = qRgb(0, 0, 255);
|
||||
|
||||
QImage image(8, 8, QImage::Format_RGB32);
|
||||
|
||||
image.fill(red);
|
||||
QCOMPARE(image.pixel(4, 4), red);
|
||||
|
||||
QVideoFrame frame(image);
|
||||
|
||||
QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite));
|
||||
|
||||
QImage frameImage(frame.bits(), 8, 8, frame.bytesPerLine(), QImage::Format_RGB32);
|
||||
|
||||
QCOMPARE(frameImage.pixel(4, 4), red);
|
||||
|
||||
frameImage.fill(blue);
|
||||
QCOMPARE(frameImage.pixel(4, 4), blue);
|
||||
|
||||
// Original image has detached and is therefore unchanged.
|
||||
QCOMPARE(image.pixel(4, 4), red);
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::formatConversion_data()
|
||||
{
|
||||
QTest::addColumn<QImage::Format>("imageFormat");
|
||||
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
|
||||
|
||||
QTest::newRow("QImage::Format_RGB32 | QVideoFrame::Format_RGB32")
|
||||
<< QImage::Format_RGB32
|
||||
<< QVideoFrame::Format_RGB32;
|
||||
QTest::newRow("QImage::Format_ARGB32 | QVideoFrame::Format_ARGB32")
|
||||
<< QImage::Format_ARGB32
|
||||
<< QVideoFrame::Format_ARGB32;
|
||||
QTest::newRow("QImage::Format_ARGB32_Premultiplied | QVideoFrame::Format_ARGB32_Premultiplied")
|
||||
<< QImage::Format_ARGB32_Premultiplied
|
||||
<< QVideoFrame::Format_ARGB32_Premultiplied;
|
||||
QTest::newRow("QImage::Format_RGB16 | QVideoFrame::Format_RGB565")
|
||||
<< QImage::Format_RGB16
|
||||
<< QVideoFrame::Format_RGB565;
|
||||
QTest::newRow("QImage::Format_ARGB8565_Premultiplied | QVideoFrame::Format_ARGB8565_Premultiplied")
|
||||
<< QImage::Format_ARGB8565_Premultiplied
|
||||
<< QVideoFrame::Format_ARGB8565_Premultiplied;
|
||||
QTest::newRow("QImage::Format_RGB555 | QVideoFrame::Format_RGB555")
|
||||
<< QImage::Format_RGB555
|
||||
<< QVideoFrame::Format_RGB555;
|
||||
QTest::newRow("QImage::Format_RGB888 | QVideoFrame::Format_RGB24")
|
||||
<< QImage::Format_RGB888
|
||||
<< QVideoFrame::Format_RGB24;
|
||||
|
||||
QTest::newRow("QImage::Format_MonoLSB")
|
||||
<< QImage::Format_MonoLSB
|
||||
<< QVideoFrame::Format_Invalid;
|
||||
QTest::newRow("QImage::Format_Indexed8")
|
||||
<< QImage::Format_Indexed8
|
||||
<< QVideoFrame::Format_Invalid;
|
||||
QTest::newRow("QImage::Format_ARGB6666_Premultiplied")
|
||||
<< QImage::Format_ARGB6666_Premultiplied
|
||||
<< QVideoFrame::Format_Invalid;
|
||||
QTest::newRow("QImage::Format_ARGB8555_Premultiplied")
|
||||
<< QImage::Format_ARGB8555_Premultiplied
|
||||
<< QVideoFrame::Format_Invalid;
|
||||
QTest::newRow("QImage::Format_RGB666")
|
||||
<< QImage::Format_RGB666
|
||||
<< QVideoFrame::Format_Invalid;
|
||||
QTest::newRow("QImage::Format_RGB444")
|
||||
<< QImage::Format_RGB444
|
||||
<< QVideoFrame::Format_Invalid;
|
||||
QTest::newRow("QImage::Format_ARGB4444_Premultiplied")
|
||||
<< QImage::Format_ARGB4444_Premultiplied
|
||||
<< QVideoFrame::Format_Invalid;
|
||||
|
||||
QTest::newRow("QVideoFrame::Format_BGRA32")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_BGRA32;
|
||||
QTest::newRow("QVideoFrame::Format_BGRA32_Premultiplied")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_BGRA32_Premultiplied;
|
||||
QTest::newRow("QVideoFrame::Format_BGR32")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_BGR32;
|
||||
QTest::newRow("QVideoFrame::Format_BGR24")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_BGR24;
|
||||
QTest::newRow("QVideoFrame::Format_BGR565")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_BGR565;
|
||||
QTest::newRow("QVideoFrame::Format_BGR555")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_BGR555;
|
||||
QTest::newRow("QVideoFrame::Format_BGRA5658_Premultiplied")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_BGRA5658_Premultiplied;
|
||||
QTest::newRow("QVideoFrame::Format_AYUV444")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_AYUV444;
|
||||
QTest::newRow("QVideoFrame::Format_AYUV444_Premultiplied")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_AYUV444_Premultiplied;
|
||||
QTest::newRow("QVideoFrame::Format_YUV444")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_YUV420P;
|
||||
QTest::newRow("QVideoFrame::Format_YV12")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_YV12;
|
||||
QTest::newRow("QVideoFrame::Format_UYVY")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_UYVY;
|
||||
QTest::newRow("QVideoFrame::Format_YUYV")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_YUYV;
|
||||
QTest::newRow("QVideoFrame::Format_NV12")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_NV12;
|
||||
QTest::newRow("QVideoFrame::Format_NV21")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_NV21;
|
||||
QTest::newRow("QVideoFrame::Format_IMC1")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_IMC1;
|
||||
QTest::newRow("QVideoFrame::Format_IMC2")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_IMC2;
|
||||
QTest::newRow("QVideoFrame::Format_IMC3")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_IMC3;
|
||||
QTest::newRow("QVideoFrame::Format_IMC4")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_IMC4;
|
||||
QTest::newRow("QVideoFrame::Format_Y8")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_Y8;
|
||||
QTest::newRow("QVideoFrame::Format_Y16")
|
||||
<< QImage::Format_Invalid
|
||||
<< QVideoFrame::Format_Y16;
|
||||
}
|
||||
|
||||
void tst_QVideoFrame::formatConversion()
|
||||
{
|
||||
QFETCH(QImage::Format, imageFormat);
|
||||
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
||||
|
||||
QCOMPARE(QVideoFrame::pixelFormatFromImageFormat(imageFormat) == pixelFormat,
|
||||
imageFormat != QImage::Format_Invalid);
|
||||
|
||||
QCOMPARE(QVideoFrame::imageFormatFromPixelFormat(pixelFormat) == imageFormat,
|
||||
pixelFormat != QVideoFrame::Format_Invalid);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QVideoFrame)
|
||||
|
||||
#include "tst_qvideoframe.moc"
|
||||
5
tests/auto/qvideosurfaceformat/qvideosurfaceformat.pro
Normal file
5
tests/auto/qvideosurfaceformat/qvideosurfaceformat.pro
Normal file
@@ -0,0 +1,5 @@
|
||||
load(qttest_p4)
|
||||
SOURCES += tst_qvideosurfaceformat.cpp
|
||||
|
||||
QT += multimedia
|
||||
requires(contains(QT_CONFIG, multimedia))
|
||||
736
tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp
Normal file
736
tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp
Normal file
@@ -0,0 +1,736 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include <QtMultimedia/QVideoSurfaceFormat>
|
||||
|
||||
class tst_QVideoSurfaceFormat : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_QVideoSurfaceFormat();
|
||||
~tst_QVideoSurfaceFormat();
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void constructNull();
|
||||
void construct_data();
|
||||
void construct();
|
||||
void frameSize_data();
|
||||
void frameSize();
|
||||
void viewport_data();
|
||||
void viewport();
|
||||
void scanLineDirection_data();
|
||||
void scanLineDirection();
|
||||
void frameRate_data();
|
||||
void frameRate();
|
||||
void yCbCrColorSpace_data();
|
||||
void yCbCrColorSpace();
|
||||
void pixelAspectRatio_data();
|
||||
void pixelAspectRatio();
|
||||
void sizeHint_data();
|
||||
void sizeHint();
|
||||
void staticPropertyNames();
|
||||
void dynamicProperty();
|
||||
void compare();
|
||||
void copy();
|
||||
void assign();
|
||||
};
|
||||
|
||||
tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat()
|
||||
{
|
||||
}
|
||||
|
||||
tst_QVideoSurfaceFormat::~tst_QVideoSurfaceFormat()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::cleanupTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::init()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::constructNull()
|
||||
{
|
||||
QVideoSurfaceFormat format;
|
||||
|
||||
QVERIFY(!format.isValid());
|
||||
QCOMPARE(format.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||
QCOMPARE(format.pixelFormat(), QVideoFrame::Format_Invalid);
|
||||
QCOMPARE(format.frameSize(), QSize());
|
||||
QCOMPARE(format.frameWidth(), -1);
|
||||
QCOMPARE(format.frameHeight(), -1);
|
||||
QCOMPARE(format.viewport(), QRect());
|
||||
QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
|
||||
QCOMPARE(format.frameRate(), 0.0);
|
||||
QCOMPARE(format.pixelAspectRatio(), QSize(1, 1));
|
||||
QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::construct_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("frameSize");
|
||||
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
|
||||
QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType");
|
||||
QTest::addColumn<bool>("valid");
|
||||
|
||||
QTest::newRow("32x32 rgb32 no handle")
|
||||
<< QSize(32, 32)
|
||||
<< QVideoFrame::Format_RGB32
|
||||
<< QAbstractVideoBuffer::NoHandle
|
||||
<< true;
|
||||
|
||||
QTest::newRow("1024x768 YUV444 GL texture")
|
||||
<< QSize(32, 32)
|
||||
<< QVideoFrame::Format_YUV444
|
||||
<< QAbstractVideoBuffer::GLTextureHandle
|
||||
<< true;
|
||||
|
||||
QTest::newRow("32x32 invalid no handle")
|
||||
<< QSize(32, 32)
|
||||
<< QVideoFrame::Format_Invalid
|
||||
<< QAbstractVideoBuffer::NoHandle
|
||||
<< false;
|
||||
|
||||
QTest::newRow("invalid size, rgb32 no handle")
|
||||
<< QSize()
|
||||
<< QVideoFrame::Format_RGB32
|
||||
<< QAbstractVideoBuffer::NoHandle
|
||||
<< false;
|
||||
|
||||
QTest::newRow("0x0 rgb32 no handle")
|
||||
<< QSize(0,0)
|
||||
<< QVideoFrame::Format_RGB32
|
||||
<< QAbstractVideoBuffer::NoHandle
|
||||
<< true;
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::construct()
|
||||
{
|
||||
QFETCH(QSize, frameSize);
|
||||
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
||||
QFETCH(QAbstractVideoBuffer::HandleType, handleType);
|
||||
QFETCH(bool, valid);
|
||||
|
||||
QRect viewport(QPoint(0, 0), frameSize);
|
||||
|
||||
QVideoSurfaceFormat format(frameSize, pixelFormat, handleType);
|
||||
|
||||
QCOMPARE(format.handleType(), handleType);
|
||||
QCOMPARE(format.pixelFormat(), pixelFormat);
|
||||
QCOMPARE(format.frameSize(), frameSize);
|
||||
QCOMPARE(format.frameWidth(), frameSize.width());
|
||||
QCOMPARE(format.frameHeight(), frameSize.height());
|
||||
QCOMPARE(format.isValid(), valid);
|
||||
QCOMPARE(format.viewport(), viewport);
|
||||
QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
|
||||
QCOMPARE(format.frameRate(), 0.0);
|
||||
QCOMPARE(format.pixelAspectRatio(), QSize(1, 1));
|
||||
QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::frameSize_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("initialSize");
|
||||
QTest::addColumn<QSize>("newSize");
|
||||
|
||||
QTest::newRow("grow")
|
||||
<< QSize(64, 64)
|
||||
<< QSize(1024, 1024);
|
||||
QTest::newRow("shrink")
|
||||
<< QSize(1024, 1024)
|
||||
<< QSize(64, 64);
|
||||
QTest::newRow("unchanged")
|
||||
<< QSize(512, 512)
|
||||
<< QSize(512, 512);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::frameSize()
|
||||
{
|
||||
QFETCH(QSize, initialSize);
|
||||
QFETCH(QSize, newSize);
|
||||
|
||||
QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32);
|
||||
|
||||
format.setFrameSize(newSize);
|
||||
|
||||
QCOMPARE(format.frameSize(), newSize);
|
||||
QCOMPARE(format.property("frameSize").toSize(), newSize);
|
||||
QCOMPARE(format.frameWidth(), newSize.width());
|
||||
QCOMPARE(format.property("frameWidth").toInt(), newSize.width());
|
||||
QCOMPARE(format.frameHeight(), newSize.height());
|
||||
QCOMPARE(format.property("frameHeight").toInt(), newSize.height());
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::viewport_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("initialSize");
|
||||
QTest::addColumn<QRect>("viewport");
|
||||
QTest::addColumn<QSize>("newSize");
|
||||
QTest::addColumn<QRect>("expectedViewport");
|
||||
|
||||
QTest::newRow("grow reset")
|
||||
<< QSize(64, 64)
|
||||
<< QRect(8, 8, 48, 48)
|
||||
<< QSize(1024, 1024)
|
||||
<< QRect(0, 0, 1024, 1024);
|
||||
QTest::newRow("shrink reset")
|
||||
<< QSize(1024, 1024)
|
||||
<< QRect(8, 8, 1008, 1008)
|
||||
<< QSize(64, 64)
|
||||
<< QRect(0, 0, 64, 64);
|
||||
QTest::newRow("unchanged reset")
|
||||
<< QSize(512, 512)
|
||||
<< QRect(8, 8, 496, 496)
|
||||
<< QSize(512, 512)
|
||||
<< QRect(0, 0, 512, 512);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::viewport()
|
||||
{
|
||||
QFETCH(QSize, initialSize);
|
||||
QFETCH(QRect, viewport);
|
||||
QFETCH(QSize, newSize);
|
||||
QFETCH(QRect, expectedViewport);
|
||||
|
||||
{
|
||||
QRect initialViewport(QPoint(0, 0), initialSize);
|
||||
|
||||
QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32);
|
||||
|
||||
format.setViewport(viewport);
|
||||
|
||||
QCOMPARE(format.viewport(), viewport);
|
||||
QCOMPARE(format.property("viewport").toRect(), viewport);
|
||||
|
||||
format.setFrameSize(newSize);
|
||||
|
||||
QCOMPARE(format.viewport(), expectedViewport);
|
||||
QCOMPARE(format.property("viewport").toRect(), expectedViewport);
|
||||
}
|
||||
{
|
||||
QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32);
|
||||
|
||||
format.setProperty("viewport", viewport);
|
||||
|
||||
QCOMPARE(format.viewport(), viewport);
|
||||
QCOMPARE(format.property("viewport").toRect(), viewport);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::scanLineDirection_data()
|
||||
{
|
||||
QTest::addColumn<QVideoSurfaceFormat::Direction>("direction");
|
||||
|
||||
QTest::newRow("top to bottom")
|
||||
<< QVideoSurfaceFormat::TopToBottom;
|
||||
|
||||
QTest::newRow("bottom to top")
|
||||
<< QVideoSurfaceFormat::BottomToTop;
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::scanLineDirection()
|
||||
{
|
||||
QFETCH(QVideoSurfaceFormat::Direction, direction);
|
||||
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32);
|
||||
|
||||
format.setScanLineDirection(direction);
|
||||
|
||||
QCOMPARE(format.scanLineDirection(), direction);
|
||||
QCOMPARE(
|
||||
qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection")),
|
||||
direction);
|
||||
}
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32);
|
||||
|
||||
format.setProperty("scanLineDirection", qVariantFromValue(direction));
|
||||
|
||||
QCOMPARE(format.scanLineDirection(), direction);
|
||||
QCOMPARE(
|
||||
qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection")),
|
||||
direction);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::frameRate_data()
|
||||
{
|
||||
QTest::addColumn<qreal>("frameRate");
|
||||
|
||||
QTest::newRow("null")
|
||||
<< qreal(0.0);
|
||||
QTest::newRow("1/1")
|
||||
<< qreal(1.0);
|
||||
QTest::newRow("24/1")
|
||||
<< qreal(24.0);
|
||||
QTest::newRow("15/2")
|
||||
<< qreal(7.5);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::frameRate()
|
||||
{
|
||||
QFETCH(qreal, frameRate);
|
||||
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||
|
||||
format.setFrameRate(frameRate);
|
||||
|
||||
QCOMPARE(format.frameRate(), frameRate);
|
||||
QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate);
|
||||
}
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||
|
||||
format.setFrameRate(frameRate);
|
||||
format.setProperty("frameRate", frameRate);
|
||||
|
||||
QCOMPARE(format.frameRate(), frameRate);
|
||||
QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::yCbCrColorSpace_data()
|
||||
{
|
||||
QTest::addColumn<QVideoSurfaceFormat::YCbCrColorSpace>("colorspace");
|
||||
|
||||
QTest::newRow("undefined")
|
||||
<< QVideoSurfaceFormat::YCbCr_Undefined;
|
||||
QTest::newRow("bt709")
|
||||
<< QVideoSurfaceFormat::YCbCr_BT709;
|
||||
QTest::newRow("xvYCC601")
|
||||
<< QVideoSurfaceFormat::YCbCr_xvYCC601;
|
||||
QTest::newRow("JPEG")
|
||||
<< QVideoSurfaceFormat::YCbCr_JPEG;
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::yCbCrColorSpace()
|
||||
{
|
||||
QFETCH(QVideoSurfaceFormat::YCbCrColorSpace, colorspace);
|
||||
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||
format.setYCbCrColorSpace(colorspace);
|
||||
|
||||
QCOMPARE(format.yCbCrColorSpace(), colorspace);
|
||||
QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")),
|
||||
colorspace);
|
||||
}
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||
format.setProperty("yCbCrColorSpace", qVariantFromValue(colorspace));
|
||||
|
||||
QCOMPARE(format.yCbCrColorSpace(), colorspace);
|
||||
QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")),
|
||||
colorspace);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::pixelAspectRatio_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("aspectRatio");
|
||||
|
||||
QTest::newRow("1:1")
|
||||
<< QSize(1, 1);
|
||||
QTest::newRow("4:3")
|
||||
<< QSize(4, 3);
|
||||
QTest::newRow("16:9")
|
||||
<< QSize(16, 9);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::pixelAspectRatio()
|
||||
{
|
||||
QFETCH(QSize, aspectRatio);
|
||||
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||
format.setPixelAspectRatio(aspectRatio);
|
||||
|
||||
QCOMPARE(format.pixelAspectRatio(), aspectRatio);
|
||||
QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio);
|
||||
}
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||
format.setPixelAspectRatio(aspectRatio.width(), aspectRatio.height());
|
||||
|
||||
QCOMPARE(format.pixelAspectRatio(), aspectRatio);
|
||||
QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio);
|
||||
}
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||
format.setProperty("pixelAspectRatio", aspectRatio);
|
||||
|
||||
QCOMPARE(format.pixelAspectRatio(), aspectRatio);
|
||||
QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::sizeHint_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("frameSize");
|
||||
QTest::addColumn<QRect>("viewport");
|
||||
QTest::addColumn<QSize>("aspectRatio");
|
||||
QTest::addColumn<QSize>("sizeHint");
|
||||
|
||||
QTest::newRow("(0, 0, 1024x768), 1:1")
|
||||
<< QSize(1024, 768)
|
||||
<< QRect(0, 0, 1024, 768)
|
||||
<< QSize(1, 1)
|
||||
<< QSize(1024, 768);
|
||||
QTest::newRow("0, 0, 1024x768), 4:3")
|
||||
<< QSize(1024, 768)
|
||||
<< QRect(0, 0, 1024, 768)
|
||||
<< QSize(4, 3)
|
||||
<< QSize(1365, 768);
|
||||
QTest::newRow("(168, 84, 800x600), 1:1")
|
||||
<< QSize(1024, 768)
|
||||
<< QRect(168, 84, 800, 600)
|
||||
<< QSize(1, 1)
|
||||
<< QSize(800, 600);
|
||||
QTest::newRow("(168, 84, 800x600), 4:3")
|
||||
<< QSize(1024, 768)
|
||||
<< QRect(168, 84, 800, 600)
|
||||
<< QSize(4, 3)
|
||||
<< QSize(1066, 600);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::sizeHint()
|
||||
{
|
||||
QFETCH(QSize, frameSize);
|
||||
QFETCH(QRect, viewport);
|
||||
QFETCH(QSize, aspectRatio);
|
||||
QFETCH(QSize, sizeHint);
|
||||
|
||||
QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_RGB32);
|
||||
format.setViewport(viewport);
|
||||
format.setPixelAspectRatio(aspectRatio);
|
||||
|
||||
QCOMPARE(format.sizeHint(), sizeHint);
|
||||
QCOMPARE(format.property("sizeHint").toSize(), sizeHint);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::staticPropertyNames()
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||
|
||||
QList<QByteArray> propertyNames = format.propertyNames();
|
||||
|
||||
QVERIFY(propertyNames.contains("handleType"));
|
||||
QVERIFY(propertyNames.contains("pixelFormat"));
|
||||
QVERIFY(propertyNames.contains("frameSize"));
|
||||
QVERIFY(propertyNames.contains("frameWidth"));
|
||||
QVERIFY(propertyNames.contains("viewport"));
|
||||
QVERIFY(propertyNames.contains("scanLineDirection"));
|
||||
QVERIFY(propertyNames.contains("frameRate"));
|
||||
QVERIFY(propertyNames.contains("pixelAspectRatio"));
|
||||
QVERIFY(propertyNames.contains("yCbCrColorSpace"));
|
||||
QVERIFY(propertyNames.contains("sizeHint"));
|
||||
QCOMPARE(propertyNames.count(), 10);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::dynamicProperty()
|
||||
{
|
||||
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||
|
||||
QCOMPARE(format.property("integer"), QVariant());
|
||||
QCOMPARE(format.property("size"), QVariant());
|
||||
QCOMPARE(format.property("string"), QVariant());
|
||||
QCOMPARE(format.property("null"), QVariant());
|
||||
|
||||
QList<QByteArray> propertyNames = format.propertyNames();
|
||||
|
||||
QCOMPARE(propertyNames.count(QByteArray("integer")), 0);
|
||||
QCOMPARE(propertyNames.count(QByteArray("string")), 0);
|
||||
QCOMPARE(propertyNames.count(QByteArray("size")), 0);
|
||||
QCOMPARE(propertyNames.count(QByteArray("null")), 0);
|
||||
|
||||
format.setProperty("string", QString::fromLatin1("Hello"));
|
||||
format.setProperty("integer", 198);
|
||||
format.setProperty("size", QSize(43, 65));
|
||||
|
||||
QCOMPARE(format.property("integer").toInt(), 198);
|
||||
QCOMPARE(format.property("size").toSize(), QSize(43, 65));
|
||||
QCOMPARE(format.property("string").toString(), QString::fromLatin1("Hello"));
|
||||
|
||||
propertyNames = format.propertyNames();
|
||||
|
||||
QCOMPARE(propertyNames.count(QByteArray("integer")), 1);
|
||||
QCOMPARE(propertyNames.count(QByteArray("string")), 1);
|
||||
QCOMPARE(propertyNames.count(QByteArray("size")), 1);
|
||||
|
||||
format.setProperty("integer", 125423);
|
||||
format.setProperty("size", QSize(1, 986));
|
||||
|
||||
QCOMPARE(format.property("integer").toInt(), 125423);
|
||||
QCOMPARE(format.property("size").toSize(), QSize(1, 986));
|
||||
QCOMPARE(format.property("string").toString(), QString::fromLatin1("Hello"));
|
||||
|
||||
propertyNames = format.propertyNames();
|
||||
|
||||
QCOMPARE(propertyNames.count(QByteArray("integer")), 1);
|
||||
QCOMPARE(propertyNames.count(QByteArray("string")), 1);
|
||||
QCOMPARE(propertyNames.count(QByteArray("size")), 1);
|
||||
|
||||
format.setProperty("string", QVariant());
|
||||
format.setProperty("size", QVariant());
|
||||
format.setProperty("null", QVariant());
|
||||
|
||||
QCOMPARE(format.property("integer").toInt(), 125423);
|
||||
QCOMPARE(format.property("size"), QVariant());
|
||||
QCOMPARE(format.property("string"), QVariant());
|
||||
QCOMPARE(format.property("null"), QVariant());
|
||||
|
||||
propertyNames = format.propertyNames();
|
||||
|
||||
QCOMPARE(propertyNames.count(QByteArray("integer")), 1);
|
||||
QCOMPARE(propertyNames.count(QByteArray("string")), 0);
|
||||
QCOMPARE(propertyNames.count(QByteArray("size")), 0);
|
||||
QCOMPARE(propertyNames.count(QByteArray("null")), 0);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::compare()
|
||||
{
|
||||
QVideoSurfaceFormat format1(
|
||||
QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle);
|
||||
QVideoSurfaceFormat format2(
|
||||
QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle);
|
||||
QVideoSurfaceFormat format3(
|
||||
QSize(32, 32), QVideoFrame::Format_YUV444, QAbstractVideoBuffer::GLTextureHandle);
|
||||
QVideoSurfaceFormat format4(
|
||||
QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::UserHandle);
|
||||
|
||||
QCOMPARE(format1 == format2, true);
|
||||
QCOMPARE(format1 != format2, false);
|
||||
QCOMPARE(format1 == format3, false);
|
||||
QCOMPARE(format1 != format3, true);
|
||||
QCOMPARE(format1 == format4, false);
|
||||
QCOMPARE(format1 != format4, true);
|
||||
|
||||
format2.setFrameSize(1024, 768);
|
||||
|
||||
// Not equal, frame size differs.
|
||||
QCOMPARE(format1 == format2, false);
|
||||
QCOMPARE(format1 != format2, true);
|
||||
|
||||
format1.setFrameSize(1024, 768);
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(format1 == format2, true);
|
||||
QCOMPARE(format1 != format2, false);
|
||||
|
||||
format1.setViewport(QRect(0, 0, 800, 600));
|
||||
format2.setViewport(QRect(112, 84, 800, 600));
|
||||
|
||||
// Not equal, viewports differ.
|
||||
QCOMPARE(format1 == format2, false);
|
||||
QCOMPARE(format1 != format2, true);
|
||||
|
||||
format1.setViewport(QRect(112, 84, 800, 600));
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(format1 == format2, true);
|
||||
QCOMPARE(format1 != format2, false);
|
||||
|
||||
format2.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
|
||||
|
||||
// Not equal scan line direction differs.
|
||||
QCOMPARE(format1 == format2, false);
|
||||
QCOMPARE(format1 != format2, true);
|
||||
|
||||
format1.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(format1 == format2, true);
|
||||
QCOMPARE(format1 != format2, false);
|
||||
|
||||
format1.setFrameRate(7.5);
|
||||
|
||||
// Not equal frame rate differs.
|
||||
QCOMPARE(format1 == format2, false);
|
||||
QCOMPARE(format1 != format2, true);
|
||||
|
||||
format2.setFrameRate(qreal(7.50001));
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(format1 == format2, true);
|
||||
QCOMPARE(format1 != format2, false);
|
||||
|
||||
format2.setPixelAspectRatio(4, 3);
|
||||
|
||||
// Not equal pixel aspect ratio differs.
|
||||
QCOMPARE(format1 == format2, false);
|
||||
QCOMPARE(format1 != format2, true);
|
||||
|
||||
format1.setPixelAspectRatio(QSize(4, 3));
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(format1 == format2, true);
|
||||
QCOMPARE(format1 != format2, false);
|
||||
|
||||
format2.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601);
|
||||
|
||||
// Not equal yuv color space differs.
|
||||
QCOMPARE(format1 == format2, false);
|
||||
QCOMPARE(format1 != format2, true);
|
||||
|
||||
format1.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601);
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(format1 == format2, true);
|
||||
QCOMPARE(format1 != format2, false);
|
||||
|
||||
format1.setProperty("integer", 12);
|
||||
|
||||
// Not equal, property mismatch.
|
||||
QCOMPARE(format1 == format2, false);
|
||||
QCOMPARE(format1 != format2, true);
|
||||
|
||||
format2.setProperty("integer", 45);
|
||||
|
||||
// Not equal, integer differs.
|
||||
QCOMPARE(format1 == format2, false);
|
||||
QCOMPARE(format1 != format2, true);
|
||||
|
||||
format2.setProperty("integer", 12);
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(format1 == format2, true);
|
||||
QCOMPARE(format1 != format2, false);
|
||||
|
||||
format1.setProperty("string", QString::fromLatin1("Hello"));
|
||||
format2.setProperty("size", QSize(12, 54));
|
||||
|
||||
// Not equal, property mismatch.
|
||||
QCOMPARE(format1 == format2, false);
|
||||
QCOMPARE(format1 != format2, true);
|
||||
|
||||
format2.setProperty("string", QString::fromLatin1("Hello"));
|
||||
format1.setProperty("size", QSize(12, 54));
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(format1 == format2, true);
|
||||
QCOMPARE(format1 != format2, false);
|
||||
|
||||
format1.setProperty("string", QVariant());
|
||||
|
||||
// Not equal, property mismatch.
|
||||
QCOMPARE(format1 == format2, false);
|
||||
QCOMPARE(format1 != format2, true);
|
||||
}
|
||||
|
||||
|
||||
void tst_QVideoSurfaceFormat::copy()
|
||||
{
|
||||
QVideoSurfaceFormat original(
|
||||
QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
|
||||
original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
|
||||
|
||||
QVideoSurfaceFormat copy(original);
|
||||
|
||||
QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle);
|
||||
QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32);
|
||||
QCOMPARE(copy.frameSize(), QSize(1024, 768));
|
||||
QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
|
||||
|
||||
QCOMPARE(original == copy, true);
|
||||
QCOMPARE(original != copy, false);
|
||||
|
||||
copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
|
||||
|
||||
QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
|
||||
|
||||
QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
|
||||
|
||||
QCOMPARE(original == copy, false);
|
||||
QCOMPARE(original != copy, true);
|
||||
}
|
||||
|
||||
void tst_QVideoSurfaceFormat::assign()
|
||||
{
|
||||
QVideoSurfaceFormat copy(
|
||||
QSize(64, 64), QVideoFrame::Format_AYUV444, QAbstractVideoBuffer::UserHandle);
|
||||
|
||||
QVideoSurfaceFormat original(
|
||||
QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
|
||||
original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
|
||||
|
||||
copy = original;
|
||||
|
||||
QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle);
|
||||
QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32);
|
||||
QCOMPARE(copy.frameSize(), QSize(1024, 768));
|
||||
QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
|
||||
|
||||
QCOMPARE(original == copy, true);
|
||||
QCOMPARE(original != copy, false);
|
||||
|
||||
copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
|
||||
|
||||
QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
|
||||
|
||||
QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
|
||||
|
||||
QCOMPARE(original == copy, false);
|
||||
QCOMPARE(original != copy, true);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QVideoSurfaceFormat)
|
||||
|
||||
#include "tst_qvideosurfaceformat.moc"
|
||||
2
tests/global/.gitignore
vendored
Normal file
2
tests/global/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
global.pro
|
||||
2
tests/tests.pro
Normal file
2
tests/tests.pro
Normal file
@@ -0,0 +1,2 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS += auto
|
||||
Reference in New Issue
Block a user