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:
committed by
Qt by Nokia
parent
1e4dda9710
commit
a6128410da
@@ -57,6 +57,9 @@ private slots:
|
||||
void equality();
|
||||
void copy();
|
||||
void assign();
|
||||
|
||||
void constructorRequest();
|
||||
void copyConstructor();
|
||||
};
|
||||
|
||||
void tst_QMediaResource::constructNull()
|
||||
@@ -447,6 +450,61 @@ void tst_QMediaResource::equality()
|
||||
// Equal
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
/* equality tests for constructor of QMediaresource(QNetworkrequest,mimeType)*/
|
||||
QNetworkRequest request2(QUrl(QString::fromLatin1("http://test.com/test.mp4")));
|
||||
QUrl url(QString::fromLatin1("http://test.com/test.mp4"));
|
||||
QString mimeType(QLatin1String("video/mp4"));
|
||||
|
||||
QMediaResource resource6(request2,mimeType);
|
||||
QMediaResource resource7(request2,mimeType);
|
||||
|
||||
|
||||
QVERIFY(resource6.request()==request2);
|
||||
QVERIFY(resource6.mimeType()==mimeType);
|
||||
|
||||
|
||||
QVERIFY(resource7.request()==request2);
|
||||
QVERIFY(resource7.mimeType()==mimeType);
|
||||
|
||||
QVERIFY(resource6.request()==resource7.request());
|
||||
QVERIFY(resource6.mimeType()==resource7.mimeType());
|
||||
|
||||
QVERIFY(resource6==resource7);
|
||||
|
||||
/*for copy constructor*/
|
||||
QMediaResource resource8(resource7);
|
||||
|
||||
QVERIFY(resource8.request()==request2);
|
||||
QVERIFY(resource8.mimeType()==mimeType);
|
||||
|
||||
|
||||
QVERIFY(resource7.request()==request2);
|
||||
QVERIFY(resource7.mimeType()==mimeType);
|
||||
|
||||
QVERIFY(resource8.request()==resource7.request());
|
||||
QVERIFY(resource8.mimeType()==resource7.mimeType());
|
||||
|
||||
|
||||
QVERIFY(resource8==resource7);
|
||||
|
||||
/*for assign constructor*/
|
||||
|
||||
QMediaResource resource9(request2,mimeType);
|
||||
|
||||
QMediaResource resource10=resource9;
|
||||
|
||||
QVERIFY(resource10.request()==request2);
|
||||
QVERIFY(resource10.mimeType()==mimeType);
|
||||
|
||||
|
||||
QVERIFY(resource9.request()==request2);
|
||||
QVERIFY(resource9.mimeType()==mimeType);
|
||||
|
||||
QVERIFY(resource8.request()==resource7.request());
|
||||
QVERIFY(resource8.mimeType()==resource7.mimeType());
|
||||
|
||||
QVERIFY(resource8==resource7);
|
||||
}
|
||||
|
||||
void tst_QMediaResource::copy()
|
||||
@@ -494,6 +552,12 @@ void tst_QMediaResource::assign()
|
||||
const QString aacCodec(QLatin1String("aac"));
|
||||
const QString h264Codec(QLatin1String("h264"));
|
||||
|
||||
QNetworkRequest request(QUrl(QString::fromLatin1("http://test.com/test.mp4")));
|
||||
const qint64 dataSize(23600);
|
||||
int audioBitRate = 1, sampleRate = 2, channelCount = 3, videoBitRate = 4;
|
||||
QSize resolution(QSize(640, 480));
|
||||
QString language("eng");
|
||||
|
||||
QMediaResource copy(QUrl(QString::fromLatin1("file:///thumbs/test.jpg")));
|
||||
|
||||
QMediaResource original(url, mimeType);
|
||||
@@ -521,6 +585,114 @@ void tst_QMediaResource::assign()
|
||||
QCOMPARE(copy.mimeType(), mimeType);
|
||||
|
||||
QCOMPARE(original.audioCodec(), mp3Codec);
|
||||
|
||||
/* for constructor of QMediaresource(QNetworkrequest,mimeType)*/
|
||||
|
||||
QMediaResource copy1(QNetworkRequest(QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))));
|
||||
|
||||
QMediaResource original1(request, mimeType);
|
||||
|
||||
original1.setAudioCodec(amrCodec);
|
||||
original1.setLanguage(QString("eng"));
|
||||
original1.setVideoCodec(h264Codec);
|
||||
original1.setDataSize(dataSize);
|
||||
original1.setAudioBitRate(audioBitRate);
|
||||
original1.setSampleRate(sampleRate);
|
||||
original1.setChannelCount(channelCount);
|
||||
original1.setVideoBitRate(videoBitRate);
|
||||
original1.setResolution(resolution);
|
||||
|
||||
copy1 = original1;
|
||||
|
||||
QCOMPARE(original1 == copy1, true);
|
||||
}
|
||||
|
||||
// Constructor for request without passing mimetype.
|
||||
void tst_QMediaResource::constructorRequest()
|
||||
{
|
||||
//Initialise the request and url.
|
||||
QNetworkRequest request(QUrl(QString::fromLatin1("http:://test.com/test.mp3")));
|
||||
QUrl url(QString::fromLatin1("http:://test.com/test.mp3"));
|
||||
|
||||
// Create the instance with request as parameter.
|
||||
QMediaResource resource(request);
|
||||
|
||||
// Verify all the parameters of objects.
|
||||
QCOMPARE(resource.isNull(), false);
|
||||
QCOMPARE(resource.url(), url);
|
||||
QCOMPARE(resource.request(), request);
|
||||
QCOMPARE(resource.mimeType(), QString());
|
||||
QCOMPARE(resource.language(), QString());
|
||||
QCOMPARE(resource.audioCodec(), QString());
|
||||
QCOMPARE(resource.videoCodec(), QString());
|
||||
QCOMPARE(resource.dataSize(), qint64(0));
|
||||
QCOMPARE(resource.audioBitRate(), 0);
|
||||
QCOMPARE(resource.sampleRate(), 0);
|
||||
QCOMPARE(resource.channelCount(), 0);
|
||||
QCOMPARE(resource.videoBitRate(), 0);
|
||||
QCOMPARE(resource.resolution(), QSize());
|
||||
}
|
||||
|
||||
// Copy constructor with all the parameter and copy constructor for constructor with request and mimetype as parameter.
|
||||
void tst_QMediaResource::copyConstructor()
|
||||
{
|
||||
// Initialise all the parameters.
|
||||
const QUrl url(QString::fromLatin1("http://test.com/test.mp4"));
|
||||
const QString mimeType(QLatin1String("video/mp4"));
|
||||
const QString amrCodec(QLatin1String("amr"));
|
||||
const QString h264Codec(QLatin1String("h264"));
|
||||
|
||||
const qint64 dataSize(23600);
|
||||
int audioBitRate = 1, sampleRate = 2, channelCount = 3, videoBitRate = 4;
|
||||
QSize resolution(QSize(640, 480));
|
||||
QString language("eng");
|
||||
|
||||
// Create the instance with url and mimetype.
|
||||
QMediaResource original(url, mimeType);
|
||||
|
||||
// Set all the parameters.
|
||||
original.setAudioCodec(amrCodec);
|
||||
original.setLanguage(QString("eng"));
|
||||
original.setVideoCodec(h264Codec);
|
||||
original.setDataSize(dataSize);
|
||||
original.setAudioBitRate(audioBitRate);
|
||||
original.setSampleRate(sampleRate);
|
||||
original.setChannelCount(channelCount);
|
||||
original.setVideoBitRate(videoBitRate);
|
||||
original.setResolution(resolution);
|
||||
|
||||
// Copy the instance to new object.
|
||||
QMediaResource copy(original);
|
||||
|
||||
// Verify all the parameters of the copied object.
|
||||
QCOMPARE(copy.url(), url);
|
||||
QCOMPARE(copy.mimeType(), mimeType);
|
||||
QCOMPARE(copy.audioCodec(), amrCodec);
|
||||
QCOMPARE(copy.language(), language );
|
||||
QCOMPARE(copy.videoCodec(), h264Codec);
|
||||
QCOMPARE(copy.dataSize(), dataSize);
|
||||
QCOMPARE(copy.audioBitRate(), audioBitRate);
|
||||
QCOMPARE(copy.sampleRate(), sampleRate);
|
||||
QCOMPARE(copy.channelCount(), channelCount);
|
||||
QCOMPARE(copy.videoBitRate(), videoBitRate);
|
||||
QCOMPARE(copy.resolution(), resolution);
|
||||
|
||||
// Compare both the objects are equal.
|
||||
QCOMPARE(original == copy, true);
|
||||
QCOMPARE(original != copy, false);
|
||||
|
||||
// Initialise the request parameter.
|
||||
QNetworkRequest request1(QUrl(QString::fromLatin1("http://test.com/test.mp4")));
|
||||
|
||||
// Constructor with rerquest and mimetype.
|
||||
QMediaResource original1(request1, mimeType);
|
||||
|
||||
// Copy the object and verify if both are eqaul or not.
|
||||
QMediaResource copy1(original1);
|
||||
QCOMPARE(copy1.url(), url);
|
||||
QCOMPARE(copy1.mimeType(), mimeType);
|
||||
QCOMPARE(copy1.request(), request1);
|
||||
QCOMPARE(original1 == copy1, true);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMediaResource)
|
||||
|
||||
Reference in New Issue
Block a user