summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2009-08-14 15:18:48 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2009-08-14 15:18:48 (GMT)
commit9db9c1f2215e32047c7329ab769d54dd3c1ddeb7 (patch)
tree98acb9a60cf237138f939b5dadb0d9ae7722ddeb /tests
parente9d32707afeddfdd2906af7bed60c375b1035dd6 (diff)
parent3c8f4512df30dee4a867a498fff6d2b27b881e4b (diff)
downloadQt-9db9c1f2215e32047c7329ab769d54dd3c1ddeb7.zip
Qt-9db9c1f2215e32047c7329ab769d54dd3c1ddeb7.tar.gz
Qt-9db9c1f2215e32047c7329ab769d54dd3c1ddeb7.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp60
-rw-r--r--tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp114
-rw-r--r--tests/auto/qaudioinput/tst_qaudioinput.cpp61
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp123
-rw-r--r--tests/auto/qcolumnview/qcolumnview.pro4
-rw-r--r--tests/auto/qdesktopservices/qdesktopservices.pro4
-rw-r--r--tests/auto/qfilesystemmodel/qfilesystemmodel.pro3
-rw-r--r--tests/auto/qfontmetrics/tst_qfontmetrics.cpp7
-rw-r--r--tests/auto/qobject/tst_qobject.pro2
10 files changed, 235 insertions, 144 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index dd188cd..585f461 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -316,6 +316,7 @@ SUBDIRS += \
qstatusbar \
qstl \
qstring \
+ qstringbuilder \
qstringmatcher \
qstringlist \
qstringlistmodel \
diff --git a/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp b/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
index 8f8d6a6..f87500c 100644
--- a/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
+++ b/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
@@ -56,41 +56,61 @@ public:
tst_QAudioDeviceId(QObject* parent=0) : QObject(parent) {}
private slots:
+ void initTestCase();
void checkNull();
void checkEquality();
+
+private:
+ bool available;
};
-void tst_QAudioDeviceId::checkNull()
+void tst_QAudioDeviceId::initTestCase()
{
- // Default constructed is null.
- QAudioDeviceId deviceId0;
- QVERIFY(deviceId0.isNull());
+ // Only perform tests if audio output device exists!
+ QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput);
+ if(devices.size() > 0)
+ available = true;
+ else {
+ qWarning()<<"NOTE: no audio output device found, no test will be performed";
+ available = false;
+ }
+}
- // Null is transferred
- QAudioDeviceId deviceId1(deviceId0);
- QVERIFY(deviceId1.isNull());
+void tst_QAudioDeviceId::checkNull()
+{
+ if(available) {
+ // Default constructed is null.
+ QAudioDeviceId deviceId0;
+ QVERIFY(deviceId0.isNull());
+
+ // Null is transferred
+ QAudioDeviceId deviceId1(deviceId0);
+ QVERIFY(deviceId1.isNull());
+ }
}
void tst_QAudioDeviceId::checkEquality()
{
- QAudioDeviceId deviceId0;
- QAudioDeviceId deviceId1;
+ if(available) {
+ QAudioDeviceId deviceId0;
+ QAudioDeviceId deviceId1;
- // Null ids are equivalent
- QVERIFY(deviceId0 == deviceId1);
- QVERIFY(!(deviceId0 != deviceId1));
+ // Null ids are equivalent
+ QVERIFY(deviceId0 == deviceId1);
+ QVERIFY(!(deviceId0 != deviceId1));
- deviceId1 = QAudioDeviceInfo::defaultOutputDevice();
+ deviceId1 = QAudioDeviceInfo::defaultOutputDevice();
- // Different
- QVERIFY(deviceId0 != deviceId1);
- QVERIFY(!(deviceId0 == deviceId1));
+ // Different
+ QVERIFY(deviceId0 != deviceId1);
+ QVERIFY(!(deviceId0 == deviceId1));
- // Same
- deviceId0 = deviceId1;
+ // Same
+ deviceId0 = deviceId1;
- QVERIFY(deviceId0 == deviceId1);
- QVERIFY(!(deviceId0 != deviceId1));
+ QVERIFY(deviceId0 == deviceId1);
+ QVERIFY(!(deviceId0 != deviceId1));
+ }
}
QTEST_MAIN(tst_QAudioDeviceId)
diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
index 72121a7..47f3d00 100644
--- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
+++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
@@ -55,6 +55,7 @@ public:
tst_QAudioDeviceInfo(QObject* parent=0) : QObject(parent) {}
private slots:
+ void initTestCase();
void checkAvailableDefaultInput();
void checkAvailableDefaultOutput();
void outputList();
@@ -69,89 +70,134 @@ private slots:
void nearest();
private:
+ bool available;
QAudioDeviceInfo* device;
};
+void tst_QAudioDeviceInfo::initTestCase()
+{
+ // Only perform tests if audio output device exists!
+ QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(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()
{
- QVERIFY(!QAudioDeviceInfo::defaultInputDevice().isNull());
+ // Only perform tests if audio input device exists!
+ bool storeAvailable = available;
+ QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(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()
{
- QVERIFY(!QAudioDeviceInfo::defaultOutputDevice().isNull());
+ if(available)
+ QVERIFY(!QAudioDeviceInfo::defaultOutputDevice().isNull());
}
void tst_QAudioDeviceInfo::outputList()
{
- QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput);
- QVERIFY(devices.size() > 0);
- device = new QAudioDeviceInfo(devices.at(0), this);
+ if(available) {
+ QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput);
+ QVERIFY(devices.size() > 0);
+ device = new QAudioDeviceInfo(devices.at(0), this);
+ }
}
void tst_QAudioDeviceInfo::codecs()
{
- QStringList avail = device->supportedCodecs();
- QVERIFY(avail.size() > 0);
+ if(available) {
+ QStringList avail = device->supportedCodecs();
+ QVERIFY(avail.size() > 0);
+ }
}
void tst_QAudioDeviceInfo::channels()
{
- QList<int> avail = device->supportedChannels();
- QVERIFY(avail.size() > 0);
+ if(available) {
+ QList<int> avail = device->supportedChannels();
+ QVERIFY(avail.size() > 0);
+ }
}
void tst_QAudioDeviceInfo::sampleSizes()
{
- QList<int> avail = device->supportedSampleSizes();
- QVERIFY(avail.size() > 0);
+ if(available) {
+ QList<int> avail = device->supportedSampleSizes();
+ QVERIFY(avail.size() > 0);
+ }
}
void tst_QAudioDeviceInfo::byteOrders()
{
- QList<QAudioFormat::Endian> avail = device->supportedByteOrders();
- QVERIFY(avail.size() > 0);
+ if(available) {
+ QList<QAudioFormat::Endian> avail = device->supportedByteOrders();
+ QVERIFY(avail.size() > 0);
+ }
}
void tst_QAudioDeviceInfo::sampleTypes()
{
- QList<QAudioFormat::SampleType> avail = device->supportedSampleTypes();
- QVERIFY(avail.size() > 0);
+ if(available) {
+ QList<QAudioFormat::SampleType> avail = device->supportedSampleTypes();
+ QVERIFY(avail.size() > 0);
+ }
}
void tst_QAudioDeviceInfo::frequencies()
{
- QList<int> avail = device->supportedFrequencies();
- QVERIFY(avail.size() > 0);
+ if(available) {
+ QList<int> avail = device->supportedFrequencies();
+ QVERIFY(avail.size() > 0);
+ }
}
void tst_QAudioDeviceInfo::isformat()
{
- 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));
+ 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()
{
- QAudioFormat format = device->preferredFormat();
- QVERIFY(format.frequency() == 44100);
- QVERIFY(format.channels() == 2);
+ if(available) {
+ QAudioFormat format = device->preferredFormat();
+ QVERIFY(format.frequency() == 44100);
+ QVERIFY(format.channels() == 2);
+ }
}
void tst_QAudioDeviceInfo::nearest()
{
- QAudioFormat format1, format2;
- format1.setFrequency(8000);
- format2 = device->nearestFormat(format1);
- QVERIFY(format2.frequency() == 44100);
+ if(available) {
+ QAudioFormat format1, format2;
+ format1.setFrequency(8000);
+ format2 = device->nearestFormat(format1);
+ QVERIFY(format2.frequency() == 44100);
+ }
}
QTEST_MAIN(tst_QAudioDeviceInfo)
diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp
index 891d1c4..6f1d568 100644
--- a/tests/auto/qaudioinput/tst_qaudioinput.cpp
+++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp
@@ -60,6 +60,7 @@ private slots:
void pullFile();
private:
+ bool available;
QAudioFormat format;
QAudioInput* audio;
};
@@ -73,46 +74,62 @@ void tst_QAudioInput::initTestCase()
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::UnSignedInt);
- audio = new QAudioInput(format, this);
+ // Only perform tests if audio input device exists!
+ QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(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::settings()
{
- 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());
+ if(available) {
+ 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::notifyInterval()
{
- QVERIFY(audio->notifyInterval() == 1000); // Default
+ if(available) {
+ QVERIFY(audio->notifyInterval() == 1000); // Default
- audio->setNotifyInterval(500);
- QVERIFY(audio->notifyInterval() == 500); // Custom
+ audio->setNotifyInterval(500);
+ QVERIFY(audio->notifyInterval() == 500); // Custom
- audio->setNotifyInterval(1000); // reset
+ audio->setNotifyInterval(1000); // reset
+ }
}
void tst_QAudioInput::pullFile()
{
- QFile filename(SRCDIR "test.raw");
- filename.open( QIODevice::WriteOnly | QIODevice::Truncate );
+ if(available) {
+ QFile filename(SRCDIR "test.raw");
+ filename.open( QIODevice::WriteOnly | QIODevice::Truncate );
- QSignalSpy readSignal(audio, SIGNAL(notify()));
- audio->start(&filename);
+ QSignalSpy readSignal(audio, SIGNAL(notify()));
+ audio->start(&filename);
- QTest::qWait(5000);
+ QTest::qWait(5000);
- QVERIFY(readSignal.count() > 0);
- QVERIFY(audio->totalTime() > 0);
+ QVERIFY(readSignal.count() > 0);
+ QVERIFY(audio->totalTime() > 0);
- audio->stop();
- filename.close();
+ audio->stop();
+ filename.close();
+ }
}
QTEST_MAIN(tst_QAudioInput)
diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
index 2c3f662..0552aa4 100644
--- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
+++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
@@ -63,6 +63,7 @@ private slots:
void pushFile();
private:
+ bool available;
QAudioFormat format;
QAudioOutput* audio;
};
@@ -76,79 +77,95 @@ void tst_QAudioOutput::initTestCase()
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::UnSignedInt);
+ // Only perform tests if audio output device exists!
+ QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(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::settings()
{
- 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());
+ if(available) {
+ 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::notifyInterval()
{
- QVERIFY(audio->notifyInterval() == 1000); // Default
+ if(available) {
+ QVERIFY(audio->notifyInterval() == 1000); // Default
- audio->setNotifyInterval(500);
- QVERIFY(audio->notifyInterval() == 500); // Custom
+ audio->setNotifyInterval(500);
+ QVERIFY(audio->notifyInterval() == 500); // Custom
- audio->setNotifyInterval(1000); // reset
+ audio->setNotifyInterval(1000); // reset
+ }
}
void tst_QAudioOutput::pullFile()
{
- QFile filename(SRCDIR "4.wav");
- QVERIFY(filename.exists());
- filename.open(QIODevice::ReadOnly);
-
- QSignalSpy readSignal(audio, SIGNAL(notify()));
- audio->setNotifyInterval(100);
- audio->start(&filename);
-
- QTestEventLoop::instance().enterLoop(1);
- // 4.wav is a little less than 700ms, so notify should fire 6 times!
- QVERIFY(readSignal.count() >= 6);
- QVERIFY(audio->totalTime() == 692250);
-
- audio->stop();
- filename.close();
+ if(available) {
+ QFile filename(SRCDIR "4.wav");
+ QVERIFY(filename.exists());
+ filename.open(QIODevice::ReadOnly);
+
+ QSignalSpy readSignal(audio, SIGNAL(notify()));
+ audio->setNotifyInterval(100);
+ audio->start(&filename);
+
+ QTestEventLoop::instance().enterLoop(1);
+ // 4.wav is a little less than 700ms, so notify should fire 6 times!
+ QVERIFY(readSignal.count() >= 6);
+ QVERIFY(audio->totalTime() == 692250);
+
+ audio->stop();
+ filename.close();
+ }
}
void tst_QAudioOutput::pushFile()
{
- QFile filename(SRCDIR "4.wav");
- QVERIFY(filename.exists());
- filename.open(QIODevice::ReadOnly);
-
- const qint64 fileSize = filename.size();
-
- QIODevice* feed = audio->start(0);
-
- char* buffer = new char[fileSize];
- filename.read(buffer, fileSize);
-
- qint64 counter=0;
- qint64 written=0;
- while(written < fileSize) {
- written+=feed->write(buffer+written,fileSize-written);
- QTest::qWait(20);
- counter++;
+ if(available) {
+ QFile filename(SRCDIR "4.wav");
+ QVERIFY(filename.exists());
+ filename.open(QIODevice::ReadOnly);
+
+ const qint64 fileSize = filename.size();
+
+ QIODevice* feed = audio->start(0);
+
+ char* buffer = new char[fileSize];
+ filename.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->totalTime() == 692250);
+
+ audio->stop();
+ filename.close();
+ delete [] buffer;
+ delete audio;
}
- QTestEventLoop::instance().enterLoop(1);
-
- QVERIFY(written == fileSize);
- QVERIFY(audio->totalTime() == 692250);
-
- audio->stop();
- filename.close();
- delete [] buffer;
- delete audio;
}
QTEST_MAIN(tst_QAudioOutput)
diff --git a/tests/auto/qcolumnview/qcolumnview.pro b/tests/auto/qcolumnview/qcolumnview.pro
index 00e3880..754f06f 100644
--- a/tests/auto/qcolumnview/qcolumnview.pro
+++ b/tests/auto/qcolumnview/qcolumnview.pro
@@ -1,8 +1,4 @@
CONFIG += qttest_p4
-include(../src/qcolumnview.pri)
-
SOURCES += tst_qcolumnview.cpp
TARGET = tst_qcolumnview
-
-
diff --git a/tests/auto/qdesktopservices/qdesktopservices.pro b/tests/auto/qdesktopservices/qdesktopservices.pro
index 537b105..05110bb 100644
--- a/tests/auto/qdesktopservices/qdesktopservices.pro
+++ b/tests/auto/qdesktopservices/qdesktopservices.pro
@@ -2,7 +2,3 @@ CONFIG += qttest_p4
SOURCES += tst_qdesktopservices.cpp
TARGET = tst_qdesktopservices
-
-include(../src/qdesktopservices.pri)
-
-
diff --git a/tests/auto/qfilesystemmodel/qfilesystemmodel.pro b/tests/auto/qfilesystemmodel/qfilesystemmodel.pro
index 55f3b5c..1daae04 100644
--- a/tests/auto/qfilesystemmodel/qfilesystemmodel.pro
+++ b/tests/auto/qfilesystemmodel/qfilesystemmodel.pro
@@ -1,8 +1,5 @@
CONFIG += qttest_p4
-include(../../src/qfiledialog.pri)
-include(../../../../modeltest/modeltest.pri)
-
QT = core gui
SOURCES += tst_qfilesystemmodel.cpp
diff --git a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
index f827bfc..9ffbc05 100644
--- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
@@ -71,7 +71,7 @@ private slots:
void elidedText();
void veryNarrowElidedText();
void averageCharWidth();
- void elidedMultiLenght();
+ void elidedMultiLength();
};
tst_QFontMetrics::tst_QFontMetrics()
@@ -203,7 +203,7 @@ void tst_QFontMetrics::averageCharWidth()
QVERIFY(fmf.averageCharWidth() != 0);
}
-void tst_QFontMetrics::elidedMultiLenght()
+void tst_QFontMetrics::elidedMultiLength()
{
QString text1 = "Long Text 1\x9cShorter\x9csmall";
QString text1_long = "Long Text 1";
@@ -218,8 +218,9 @@ void tst_QFontMetrics::elidedMultiLenght()
QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short), text1_short);
QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short - 1), text1_small);
+ // Not even wide enough for "small" - should use ellipsis
QChar ellipsisChar(0x2026);
- QString text1_el = QString::fromLatin1("sm") + ellipsisChar;
+ QString text1_el = QString::fromLatin1("s") + ellipsisChar;
int width_small = fm.width(text1_el);
QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_small + 1), text1_el);
diff --git a/tests/auto/qobject/tst_qobject.pro b/tests/auto/qobject/tst_qobject.pro
index 9b2fec1..0500ea2 100644
--- a/tests/auto/qobject/tst_qobject.pro
+++ b/tests/auto/qobject/tst_qobject.pro
@@ -1,7 +1,7 @@
load(qttest_p4)
SOURCES += tst_qobject.cpp
-QT = core network
+QT = core network gui
contains(QT_CONFIG, qt3support):DEFINES+=QT_HAS_QT3SUPPORT
wince*: {