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
@@ -59,23 +59,24 @@ public:
|
||||
private slots:
|
||||
void checkNull();
|
||||
void checkFrequency();
|
||||
void checkChannels();
|
||||
void checkSampleSize();
|
||||
void checkCodec();
|
||||
void checkByteOrder();
|
||||
void checkSampleType();
|
||||
void checkEquality();
|
||||
void checkAssignment();
|
||||
void checkSampleRate();
|
||||
void checkChannelCount();
|
||||
};
|
||||
|
||||
void tst_QAudioFormat::checkNull()
|
||||
{
|
||||
// Default constructed QAudioFormat is invalid.
|
||||
QAudioFormat audioFormat0;
|
||||
QAudioFormat audioFormat0;
|
||||
QVERIFY(!audioFormat0.isValid());
|
||||
|
||||
// validity is transferred
|
||||
QAudioFormat audioFormat1(audioFormat0);
|
||||
QAudioFormat audioFormat1(audioFormat0);
|
||||
QVERIFY(!audioFormat1.isValid());
|
||||
|
||||
audioFormat0.setFrequency(44100);
|
||||
@@ -88,50 +89,52 @@ void tst_QAudioFormat::checkNull()
|
||||
|
||||
void tst_QAudioFormat::checkFrequency()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
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;
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setSampleSize(16);
|
||||
QVERIFY(audioFormat.sampleSize() == 16);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkCodec()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setCodec(QString::fromLatin1("audio/pcm"));
|
||||
QVERIFY(audioFormat.codec() == QString::fromLatin1("audio/pcm"));
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkByteOrder()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||
QVERIFY(audioFormat.byteOrder() == QAudioFormat::LittleEndian);
|
||||
|
||||
audioFormat.setByteOrder(QAudioFormat::BigEndian);
|
||||
QVERIFY(audioFormat.byteOrder() == QAudioFormat::BigEndian);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkSampleType()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setSampleType(QAudioFormat::SignedInt);
|
||||
QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt);
|
||||
|
||||
audioFormat.setSampleType(QAudioFormat::Unknown);
|
||||
QVERIFY(audioFormat.sampleType() == QAudioFormat::Unknown);
|
||||
|
||||
audioFormat.setSampleType(QAudioFormat::Float);
|
||||
QVERIFY(audioFormat.sampleType() == QAudioFormat::Float);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkEquality()
|
||||
{
|
||||
QAudioFormat audioFormat0;
|
||||
QAudioFormat audioFormat1;
|
||||
QAudioFormat audioFormat0;
|
||||
QAudioFormat audioFormat1;
|
||||
|
||||
// Null formats are equivalent
|
||||
QVERIFY(audioFormat0 == audioFormat1);
|
||||
@@ -162,8 +165,8 @@ void tst_QAudioFormat::checkEquality()
|
||||
|
||||
void tst_QAudioFormat::checkAssignment()
|
||||
{
|
||||
QAudioFormat audioFormat0;
|
||||
QAudioFormat audioFormat1;
|
||||
QAudioFormat audioFormat0;
|
||||
QAudioFormat audioFormat1;
|
||||
|
||||
audioFormat0.setFrequency(8000);
|
||||
audioFormat0.setChannels(1);
|
||||
@@ -175,10 +178,38 @@ void tst_QAudioFormat::checkAssignment()
|
||||
audioFormat1 = audioFormat0;
|
||||
QVERIFY(audioFormat1 == audioFormat0);
|
||||
|
||||
QAudioFormat audioFormat2(audioFormat0);
|
||||
QAudioFormat audioFormat2(audioFormat0);
|
||||
QVERIFY(audioFormat2 == audioFormat0);
|
||||
}
|
||||
|
||||
/* sampleRate() API property test. */
|
||||
void tst_QAudioFormat::checkSampleRate()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
QVERIFY(audioFormat.sampleRate() == -1);
|
||||
|
||||
audioFormat.setSampleRate(123);
|
||||
QVERIFY(audioFormat.sampleRate() == 123);
|
||||
}
|
||||
|
||||
/* channelCount() API property test. */
|
||||
void tst_QAudioFormat::checkChannelCount()
|
||||
{
|
||||
// channels is the old name for channelCount, so
|
||||
// they should always be equal
|
||||
QAudioFormat audioFormat;
|
||||
QVERIFY(audioFormat.channelCount() == -1);
|
||||
QVERIFY(audioFormat.channels() == -1);
|
||||
|
||||
audioFormat.setChannelCount(123);
|
||||
QVERIFY(audioFormat.channelCount() == 123);
|
||||
QVERIFY(audioFormat.channels() == 123);
|
||||
|
||||
audioFormat.setChannels(5);
|
||||
QVERIFY(audioFormat.channelCount() == 5);
|
||||
QVERIFY(audioFormat.channels() == 5);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAudioFormat)
|
||||
|
||||
#include "tst_qaudioformat.moc"
|
||||
|
||||
Reference in New Issue
Block a user