API unit tests from Maemo API test team.

A large number of tweaks and changes to original tests, and refactor
a lot of the mock backends to reduce duplication.

Changed viewfinder test case to use mock service and provider so
that it matches the image capture test case.

Reviewed-by: Jonas Rabbe
(cherry picked from commit e40bef5508a4165cec4a46b97115aed461027fa5)

Also licence header fix:
(cherry picked from commit e9ee9e8c48b45b97d62ee4a82e400fa9d8ea8107)

Change-Id: Ic59891d75563bb2e008a336eea859e8c44d8d831
Reviewed-on: http://codereview.qt.nokia.com/2078
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
Michael Goddard
2011-07-25 15:02:51 +10:00
committed by Qt by Nokia
parent 1e4dda9710
commit a6128410da
94 changed files with 8814 additions and 2396 deletions

View File

@@ -81,6 +81,12 @@ private slots:
void compare();
void copy();
void assign();
void isValid();
void yCbCrColorSpaceEnum_data();
void yCbCrColorSpaceEnum ();
void copyAllParameters ();
void assignAllParameters ();
};
tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat()
@@ -733,6 +739,133 @@ void tst_QVideoSurfaceFormat::assign()
QCOMPARE(original != copy, true);
}
/* Test case for Enum YCbCr_BT601, YCbCr_xvYCC709 */
void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum_data()
{
QTest::addColumn<QVideoSurfaceFormat::YCbCrColorSpace>("colorspace");
QTest::newRow("YCbCr_BT601")
<< QVideoSurfaceFormat::YCbCr_BT601;
QTest::newRow("YCbCr_xvYCC709")
<< QVideoSurfaceFormat::YCbCr_xvYCC709;
}
/* Test case for Enum YCbCr_BT601, YCbCr_xvYCC709 */
void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum()
{
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);
}
}
/* Test case for api isValid */
void tst_QVideoSurfaceFormat::isValid()
{
/* When both pixel format and framesize is not valid */
QVideoSurfaceFormat format;
QVERIFY(!format.isValid());
/* When framesize is valid and pixel format is not valid */
format.setFrameSize(64,64);
QVERIFY(format.frameSize() == QSize(64,64));
QVERIFY(!format.pixelFormat());
QVERIFY(!format.isValid());
/* When both the pixel format and framesize is valid. */
QVideoSurfaceFormat format1(QSize(32, 32), QVideoFrame::Format_AYUV444);
QVERIFY(format1.isValid());
/* When pixel format is valid and frame size is not valid */
format1.setFrameSize(-1,-1);
QVERIFY(!format1.frameSize().isValid());
QVERIFY(!format1.isValid());
}
/* Test case for copy constructor with all the parameters. */
void tst_QVideoSurfaceFormat::copyAllParameters()
{
/* Create the instance and set all the parameters. */
QVideoSurfaceFormat original(
QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
original.setViewport(QRect(0, 0, 1024, 1024));
original.setFrameRate(qreal(15.0));
original.setPixelAspectRatio(QSize(320,480));
original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709);
/* Copy the original instance to copy and verify if both the instances
have the same parameters. */
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(copy.viewport(), QRect(0, 0, 1024, 1024));
QCOMPARE(copy.frameRate(), qreal(15.0));
QCOMPARE(copy.pixelAspectRatio(), QSize(320,480));
QCOMPARE(copy.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709);
/* Verify if both the instances are eqaul */
QCOMPARE(original == copy, true);
QCOMPARE(original != copy, false);
}
/* Test case for copy constructor with all the parameters. */
void tst_QVideoSurfaceFormat::assignAllParameters()
{
/* Create the instance and set all the parameters. */
QVideoSurfaceFormat copy(
QSize(64, 64), QVideoFrame::Format_AYUV444, QAbstractVideoBuffer::UserHandle);
copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
copy.setViewport(QRect(0, 0, 640, 320));
copy.setFrameRate(qreal(7.5));
copy.setPixelAspectRatio(QSize(640,320));
copy.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT601);
/* Create the instance and set all the parameters. */
QVideoSurfaceFormat original(
QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
original.setViewport(QRect(0, 0, 1024, 1024));
original.setFrameRate(qreal(15.0));
original.setPixelAspectRatio(QSize(320,480));
original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709);
/* Assign the original instance to copy and verify if both the instancess
have the same parameters. */
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(copy.viewport(), QRect(0, 0, 1024, 1024));
QCOMPARE(copy.frameRate(), qreal(15.0));
QCOMPARE(copy.pixelAspectRatio(), QSize(320,480));
QCOMPARE(copy.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709);
/* Verify if both the instances are eqaul */
QCOMPARE(original == copy, true);
QCOMPARE(original != copy, false);
}
QTEST_MAIN(tst_QVideoSurfaceFormat)
#include "tst_qvideosurfaceformat.moc"