diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-08-17 02:58:26 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-08-17 02:58:26 (GMT) |
commit | 65d6e2c443ea31886de14736b21953fb8695eaf7 (patch) | |
tree | 45be09de909749ff10350fdc2377c4dbf3e815d8 /tests | |
parent | 6eab5d70003fe18ada199009d4b636765c609786 (diff) | |
parent | 72c1cb2ffdfb2742985e12025d4578aa2fe80ce7 (diff) | |
download | Qt-65d6e2c443ea31886de14736b21953fb8695eaf7.zip Qt-65d6e2c443ea31886de14736b21953fb8695eaf7.tar.gz Qt-65d6e2c443ea31886de14736b21953fb8695eaf7.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Diffstat (limited to 'tests')
21 files changed, 602 insertions, 285 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 5d0a1d4..fdcfd3d 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -316,6 +316,7 @@ SUBDIRS += \ qstatusbar \ qstl \ qstring \ + qstringbuilder \ qstringmatcher \ qstringlist \ qstringlistmodel \ @@ -444,6 +445,7 @@ SUBDIRS += checkxmlfiles \ xmlpatternsdiagnosticsts.depends = xmlpatternsxqts xmlpatternsview.depends = xmlpatternsxqts xmlpatternsxslts.depends = xmlpatternsxqts +xmlpatternsschemats.depends = xmlpatternsxqts } unix:!embedded:contains(QT_CONFIG, dbus):SUBDIRS += \ diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index 51e3a55..f5a11f4 100644 --- a/tests/auto/headers/tst_headers.cpp +++ b/tests/auto/headers/tst_headers.cpp @@ -50,7 +50,7 @@ public: private slots: void initTestCase(); - void licenseCheck_data() { allHeadersData(); } + void licenseCheck_data() { allSourceFilesData(); } void licenseCheck(); void privateSlots_data() { allHeadersData(); } @@ -60,11 +60,19 @@ private slots: void macros(); private: + static QStringList getFiles(const QString &path, + const QStringList dirFilters, + const QRegExp &exclude); + static QStringList getHeaders(const QString &path); + static QStringList getSourceFiles(const QString &path); + + void allSourceFilesData(); void allHeadersData(); QStringList headers; const QRegExp copyrightPattern; const QRegExp licensePattern; const QRegExp moduleTest; + QString qtSrcDir; }; tst_Headers::tst_Headers() : @@ -74,29 +82,41 @@ tst_Headers::tst_Headers() : { } -QStringList getHeaders(const QString &path) +QStringList tst_Headers::getFiles(const QString &path, + const QStringList dirFilters, + const QRegExp &excludeReg) { - QStringList headers; - - QDir dir(path); - QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + const QDir dir(path); + const QStringList dirs(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)); + QStringList result; foreach (QString subdir, dirs) - headers += getHeaders(path + "/" + subdir); + result += getFiles(path + "/" + subdir, dirFilters, excludeReg); - QStringList entries = dir.entryList(QStringList("*.h"), QDir::Files); - QRegExp reg("^(?!ui_)"); - entries = entries.filter(reg); + QStringList entries = dir.entryList(dirFilters, QDir::Files); + entries = entries.filter(excludeReg); foreach (QString entry, entries) - headers += path + "/" + entry; + result += path + "/" + entry; - return headers; + return result; +} + +QStringList tst_Headers::getHeaders(const QString &path) +{ + return getFiles(path, QStringList("*.h"), QRegExp("^(?!ui_)")); +} + +QStringList tst_Headers::getSourceFiles(const QString &path) +{ + return getFiles(path, QStringList("*.cpp"), QRegExp("^(?!(moc_|qrc_))")); } void tst_Headers::initTestCase() { - QString qtSrcDir = QString::fromLocal8Bit(qgetenv("QTSRCDIR").isEmpty() - ? qgetenv("QTDIR") : qgetenv("QTSRCDIR")); + qtSrcDir = QString::fromLocal8Bit(qgetenv("QTSRCDIR").isEmpty() + ? qgetenv("QTDIR") + : qgetenv("QTSRCDIR")); + headers = getHeaders(qtSrcDir + "/src"); #ifndef Q_OS_WINCE @@ -108,6 +128,30 @@ void tst_Headers::initTestCase() QVERIFY(licensePattern.isValid()); } +void tst_Headers::allSourceFilesData() +{ + QTest::addColumn<QString>("sourceFile"); + + const QStringList sourceFiles(getSourceFiles(qtSrcDir)); + + foreach (QString sourceFile, sourceFiles) { + if (sourceFile.contains("/3rdparty/") + || sourceFile.contains("/config.tests/") + || sourceFile.contains("/snippets/") + || sourceFile.contains("linguist/lupdate/testdata") + || sourceFile.contains("/fulltextsearch/")) + continue; + + // This test is crude, but if a file contains this string, we skip it. + QFile file(sourceFile); + QVERIFY(file.open(QIODevice::ReadOnly)); + if (file.readAll().contains("This file was generated by")) + continue; + + QTest::newRow(qPrintable(sourceFile)) << sourceFile; + } +} + void tst_Headers::allHeadersData() { QTest::addColumn<QString>("header"); @@ -125,12 +169,14 @@ void tst_Headers::allHeadersData() void tst_Headers::licenseCheck() { - QFETCH(QString, header); + QFETCH(QString, sourceFile); - if (header.endsWith("/qgifhandler.h") || header.endsWith("/qconfig.h")) + if (sourceFile.endsWith("/qgifhandler.h") + || sourceFile.endsWith("/qconfig.h") + || sourceFile.endsWith("/qconfig.cpp")) return; - QFile f(header); + QFile f(sourceFile); QVERIFY(f.open(QIODevice::ReadOnly)); QByteArray data = f.readAll(); QStringList content = QString::fromLocal8Bit(data.replace('\r',"")).split("\n"); @@ -138,8 +184,8 @@ void tst_Headers::licenseCheck() if (content.first().contains("generated")) content.takeFirst(); - QVERIFY(licensePattern.exactMatch(content.at(7)) || - licensePattern.exactMatch(content.at(4))); + QVERIFY(licensePattern.exactMatch(content.value(7)) || + licensePattern.exactMatch(content.value(4))); QString licenseType = licensePattern.cap(1); int i = 0; diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index 5e20d06..5541162 100644 --- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -43,12 +43,12 @@ #include <QtCore/qmath.h> #include "math3dincludes.h" -class tst_QMatrix : public QObject +class tst_QMatrixNxN : public QObject { Q_OBJECT public: - tst_QMatrix() {} - ~tst_QMatrix() {} + tst_QMatrixNxN() {} + ~tst_QMatrixNxN() {} private slots: void create2x2(); @@ -298,25 +298,25 @@ static qreal const transposedValues3x4[12] = // Set a matrix to a specified array of values, which are assumed // to be in row-major order. This sets the values using floating-point. -void tst_QMatrix::setMatrix(QMatrix2x2& m, const qreal *values) +void tst_QMatrixNxN::setMatrix(QMatrix2x2& m, const qreal *values) { for (int row = 0; row < 2; ++row) for (int col = 0; col < 2; ++col) m(row, col) = values[row * 2 + col]; } -void tst_QMatrix::setMatrix(QMatrix3x3& m, const qreal *values) +void tst_QMatrixNxN::setMatrix(QMatrix3x3& m, const qreal *values) { for (int row = 0; row < 3; ++row) for (int col = 0; col < 3; ++col) m(row, col) = values[row * 3 + col]; } -void tst_QMatrix::setMatrix(QMatrix4x4& m, const qreal *values) +void tst_QMatrixNxN::setMatrix(QMatrix4x4& m, const qreal *values) { for (int row = 0; row < 4; ++row) for (int col = 0; col < 4; ++col) m(row, col) = values[row * 4 + col]; } -void tst_QMatrix::setMatrix(QMatrix4x3& m, const qreal *values) +void tst_QMatrixNxN::setMatrix(QMatrix4x3& m, const qreal *values) { for (int row = 0; row < 3; ++row) for (int col = 0; col < 4; ++col) @@ -326,7 +326,7 @@ void tst_QMatrix::setMatrix(QMatrix4x3& m, const qreal *values) // Set a matrix to a specified array of values, which are assumed // to be in row-major order. This sets the values directly into // the internal data() array. -void tst_QMatrix::setMatrixDirect(QMatrix2x2& m, const qreal *values) +void tst_QMatrixNxN::setMatrixDirect(QMatrix2x2& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 2; ++row) { @@ -335,7 +335,7 @@ void tst_QMatrix::setMatrixDirect(QMatrix2x2& m, const qreal *values) } } } -void tst_QMatrix::setMatrixDirect(QMatrix3x3& m, const qreal *values) +void tst_QMatrixNxN::setMatrixDirect(QMatrix3x3& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 3; ++row) { @@ -344,7 +344,7 @@ void tst_QMatrix::setMatrixDirect(QMatrix3x3& m, const qreal *values) } } } -void tst_QMatrix::setMatrixDirect(QMatrix4x4& m, const qreal *values) +void tst_QMatrixNxN::setMatrixDirect(QMatrix4x4& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 4; ++row) { @@ -353,7 +353,7 @@ void tst_QMatrix::setMatrixDirect(QMatrix4x4& m, const qreal *values) } } } -void tst_QMatrix::setMatrixDirect(QMatrix4x3& m, const qreal *values) +void tst_QMatrixNxN::setMatrixDirect(QMatrix4x3& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 3; ++row) { @@ -398,7 +398,7 @@ static bool matrixFuzzyCompare(const QMatrix4x4 &m1, const QMatrix4x4 &m2) // Determine if a matrix is the same as a specified array of values. // The values are assumed to be specified in row-major order. -bool tst_QMatrix::isSame(const QMatrix2x2& m, const qreal *values) +bool tst_QMatrixNxN::isSame(const QMatrix2x2& m, const qreal *values) { const float *mv = m.constData(); for (int row = 0; row < 2; ++row) { @@ -419,7 +419,7 @@ bool tst_QMatrix::isSame(const QMatrix2x2& m, const qreal *values) } return true; } -bool tst_QMatrix::isSame(const QMatrix3x3& m, const qreal *values) +bool tst_QMatrixNxN::isSame(const QMatrix3x3& m, const qreal *values) { const float *mv = m.constData(); for (int row = 0; row < 3; ++row) { @@ -440,7 +440,7 @@ bool tst_QMatrix::isSame(const QMatrix3x3& m, const qreal *values) } return true; } -bool tst_QMatrix::isSame(const QMatrix4x4& m, const qreal *values) +bool tst_QMatrixNxN::isSame(const QMatrix4x4& m, const qreal *values) { const float *mv = m.constData(); for (int row = 0; row < 4; ++row) { @@ -461,7 +461,7 @@ bool tst_QMatrix::isSame(const QMatrix4x4& m, const qreal *values) } return true; } -bool tst_QMatrix::isSame(const QMatrix4x3& m, const qreal *values) +bool tst_QMatrixNxN::isSame(const QMatrix4x3& m, const qreal *values) { const float *mv = m.constData(); for (int row = 0; row < 3; ++row) { @@ -484,26 +484,26 @@ bool tst_QMatrix::isSame(const QMatrix4x3& m, const qreal *values) } // Determine if a matrix is the identity. -bool tst_QMatrix::isIdentity(const QMatrix2x2& m) +bool tst_QMatrixNxN::isIdentity(const QMatrix2x2& m) { return isSame(m, identityValues2); } -bool tst_QMatrix::isIdentity(const QMatrix3x3& m) +bool tst_QMatrixNxN::isIdentity(const QMatrix3x3& m) { return isSame(m, identityValues3); } -bool tst_QMatrix::isIdentity(const QMatrix4x4& m) +bool tst_QMatrixNxN::isIdentity(const QMatrix4x4& m) { return isSame(m, identityValues4); } -bool tst_QMatrix::isIdentity(const QMatrix4x3& m) +bool tst_QMatrixNxN::isIdentity(const QMatrix4x3& m) { return isSame(m, identityValues4x3); } // Test the creation of QMatrix2x2 objects in various ways: // construct, copy, and modify. -void tst_QMatrix::create2x2() +void tst_QMatrixNxN::create2x2() { QMatrix2x2 m1; QVERIFY(isIdentity(m1)); @@ -538,7 +538,7 @@ void tst_QMatrix::create2x2() // Test the creation of QMatrix3x3 objects in various ways: // construct, copy, and modify. -void tst_QMatrix::create3x3() +void tst_QMatrixNxN::create3x3() { QMatrix3x3 m1; QVERIFY(isIdentity(m1)); @@ -573,7 +573,7 @@ void tst_QMatrix::create3x3() // Test the creation of QMatrix4x4 objects in various ways: // construct, copy, and modify. -void tst_QMatrix::create4x4() +void tst_QMatrixNxN::create4x4() { QMatrix4x4 m1; QVERIFY(isIdentity(m1)); @@ -615,7 +615,7 @@ void tst_QMatrix::create4x4() // Test the creation of QMatrix4x3 objects in various ways: // construct, copy, and modify. -void tst_QMatrix::create4x3() +void tst_QMatrixNxN::create4x3() { QMatrix4x3 m1; QVERIFY(isIdentity(m1)); @@ -649,7 +649,7 @@ void tst_QMatrix::create4x3() } // Test isIdentity() for 2x2 matrices. -void tst_QMatrix::isIdentity2x2() +void tst_QMatrixNxN::isIdentity2x2() { for (int i = 0; i < 2 * 2; ++i) { QMatrix2x2 m; @@ -660,7 +660,7 @@ void tst_QMatrix::isIdentity2x2() } // Test isIdentity() for 3x3 matrices. -void tst_QMatrix::isIdentity3x3() +void tst_QMatrixNxN::isIdentity3x3() { for (int i = 0; i < 3 * 3; ++i) { QMatrix3x3 m; @@ -671,7 +671,7 @@ void tst_QMatrix::isIdentity3x3() } // Test isIdentity() for 4x4 matrices. -void tst_QMatrix::isIdentity4x4() +void tst_QMatrixNxN::isIdentity4x4() { for (int i = 0; i < 4 * 4; ++i) { QMatrix4x4 m; @@ -687,7 +687,7 @@ void tst_QMatrix::isIdentity4x4() } // Test isIdentity() for 4x3 matrices. -void tst_QMatrix::isIdentity4x3() +void tst_QMatrixNxN::isIdentity4x3() { for (int i = 0; i < 4 * 3; ++i) { QMatrix4x3 m; @@ -698,7 +698,7 @@ void tst_QMatrix::isIdentity4x3() } // Test 2x2 matrix comparisons. -void tst_QMatrix::compare2x2() +void tst_QMatrixNxN::compare2x2() { QMatrix2x2 m1(uniqueValues2); QMatrix2x2 m2(uniqueValues2); @@ -711,7 +711,7 @@ void tst_QMatrix::compare2x2() } // Test 3x3 matrix comparisons. -void tst_QMatrix::compare3x3() +void tst_QMatrixNxN::compare3x3() { QMatrix3x3 m1(uniqueValues3); QMatrix3x3 m2(uniqueValues3); @@ -724,7 +724,7 @@ void tst_QMatrix::compare3x3() } // Test 4x4 matrix comparisons. -void tst_QMatrix::compare4x4() +void tst_QMatrixNxN::compare4x4() { QMatrix4x4 m1(uniqueValues4); QMatrix4x4 m2(uniqueValues4); @@ -737,7 +737,7 @@ void tst_QMatrix::compare4x4() } // Test 4x3 matrix comparisons. -void tst_QMatrix::compare4x3() +void tst_QMatrixNxN::compare4x3() { QMatrix4x3 m1(uniqueValues4x3); QMatrix4x3 m2(uniqueValues4x3); @@ -750,7 +750,7 @@ void tst_QMatrix::compare4x3() } // Test matrix 2x2 transpose operations. -void tst_QMatrix::transposed2x2() +void tst_QMatrixNxN::transposed2x2() { // Transposing the identity should result in the identity. QMatrix2x2 m1; @@ -769,7 +769,7 @@ void tst_QMatrix::transposed2x2() } // Test matrix 3x3 transpose operations. -void tst_QMatrix::transposed3x3() +void tst_QMatrixNxN::transposed3x3() { // Transposing the identity should result in the identity. QMatrix3x3 m1; @@ -788,7 +788,7 @@ void tst_QMatrix::transposed3x3() } // Test matrix 4x4 transpose operations. -void tst_QMatrix::transposed4x4() +void tst_QMatrixNxN::transposed4x4() { // Transposing the identity should result in the identity. QMatrix4x4 m1; @@ -807,7 +807,7 @@ void tst_QMatrix::transposed4x4() } // Test matrix 4x3 transpose operations. -void tst_QMatrix::transposed4x3() +void tst_QMatrixNxN::transposed4x3() { QMatrix4x3 m3(uniqueValues4x3); QMatrix3x4 m4 = m3.transposed(); @@ -818,7 +818,7 @@ void tst_QMatrix::transposed4x3() } // Test matrix addition for 2x2 matrices. -void tst_QMatrix::add2x2_data() +void tst_QMatrixNxN::add2x2_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<void *>("m2Values"); @@ -839,7 +839,7 @@ void tst_QMatrix::add2x2_data() QTest::newRow("unique") << (void *)uniqueValues2 << (void *)transposedValues2 << (void *)sumValues; } -void tst_QMatrix::add2x2() +void tst_QMatrixNxN::add2x2() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -858,7 +858,7 @@ void tst_QMatrix::add2x2() } // Test matrix addition for 3x3 matrices. -void tst_QMatrix::add3x3_data() +void tst_QMatrixNxN::add3x3_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<void *>("m2Values"); @@ -880,7 +880,7 @@ void tst_QMatrix::add3x3_data() QTest::newRow("unique") << (void *)uniqueValues3 << (void *)transposedValues3 << (void *)sumValues; } -void tst_QMatrix::add3x3() +void tst_QMatrixNxN::add3x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -899,7 +899,7 @@ void tst_QMatrix::add3x3() } // Test matrix addition for 4x4 matrices. -void tst_QMatrix::add4x4_data() +void tst_QMatrixNxN::add4x4_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<void *>("m2Values"); @@ -922,7 +922,7 @@ void tst_QMatrix::add4x4_data() QTest::newRow("unique") << (void *)uniqueValues4 << (void *)transposedValues4 << (void *)sumValues; } -void tst_QMatrix::add4x4() +void tst_QMatrixNxN::add4x4() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -941,7 +941,7 @@ void tst_QMatrix::add4x4() } // Test matrix addition for 4x3 matrices. -void tst_QMatrix::add4x3_data() +void tst_QMatrixNxN::add4x3_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<void *>("m2Values"); @@ -963,7 +963,7 @@ void tst_QMatrix::add4x3_data() QTest::newRow("unique") << (void *)uniqueValues4x3 << (void *)transposedValues3x4 << (void *)sumValues; } -void tst_QMatrix::add4x3() +void tst_QMatrixNxN::add4x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -982,12 +982,12 @@ void tst_QMatrix::add4x3() } // Test matrix subtraction for 2x2 matrices. -void tst_QMatrix::subtract2x2_data() +void tst_QMatrixNxN::subtract2x2_data() { // Use the same test cases as the add test. add2x2_data(); } -void tst_QMatrix::subtract2x2() +void tst_QMatrixNxN::subtract2x2() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1015,12 +1015,12 @@ void tst_QMatrix::subtract2x2() } // Test matrix subtraction for 3x3 matrices. -void tst_QMatrix::subtract3x3_data() +void tst_QMatrixNxN::subtract3x3_data() { // Use the same test cases as the add test. add3x3_data(); } -void tst_QMatrix::subtract3x3() +void tst_QMatrixNxN::subtract3x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1048,12 +1048,12 @@ void tst_QMatrix::subtract3x3() } // Test matrix subtraction for 4x4 matrices. -void tst_QMatrix::subtract4x4_data() +void tst_QMatrixNxN::subtract4x4_data() { // Use the same test cases as the add test. add4x4_data(); } -void tst_QMatrix::subtract4x4() +void tst_QMatrixNxN::subtract4x4() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1081,12 +1081,12 @@ void tst_QMatrix::subtract4x4() } // Test matrix subtraction for 4x3 matrices. -void tst_QMatrix::subtract4x3_data() +void tst_QMatrixNxN::subtract4x3_data() { // Use the same test cases as the add test. add4x3_data(); } -void tst_QMatrix::subtract4x3() +void tst_QMatrixNxN::subtract4x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1114,7 +1114,7 @@ void tst_QMatrix::subtract4x3() } // Test matrix multiplication for 2x2 matrices. -void tst_QMatrix::multiply2x2_data() +void tst_QMatrixNxN::multiply2x2_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<void *>("m2Values"); @@ -1148,7 +1148,7 @@ void tst_QMatrix::multiply2x2_data() QTest::newRow("unique/transposed") << (void *)uniqueValues2 << (void *)transposedValues2 << (void *)uniqueResult; } -void tst_QMatrix::multiply2x2() +void tst_QMatrixNxN::multiply2x2() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1163,7 +1163,7 @@ void tst_QMatrix::multiply2x2() } // Test matrix multiplication for 3x3 matrices. -void tst_QMatrix::multiply3x3_data() +void tst_QMatrixNxN::multiply3x3_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<void *>("m2Values"); @@ -1197,7 +1197,7 @@ void tst_QMatrix::multiply3x3_data() QTest::newRow("unique/transposed") << (void *)uniqueValues3 << (void *)transposedValues3 << (void *)uniqueResult; } -void tst_QMatrix::multiply3x3() +void tst_QMatrixNxN::multiply3x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1212,7 +1212,7 @@ void tst_QMatrix::multiply3x3() } // Test matrix multiplication for 4x4 matrices. -void tst_QMatrix::multiply4x4_data() +void tst_QMatrixNxN::multiply4x4_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<void *>("m2Values"); @@ -1246,7 +1246,7 @@ void tst_QMatrix::multiply4x4_data() QTest::newRow("unique/transposed") << (void *)uniqueValues4 << (void *)transposedValues4 << (void *)uniqueResult; } -void tst_QMatrix::multiply4x4() +void tst_QMatrixNxN::multiply4x4() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1266,7 +1266,7 @@ void tst_QMatrix::multiply4x4() } // Test matrix multiplication for 4x3 matrices. -void tst_QMatrix::multiply4x3_data() +void tst_QMatrixNxN::multiply4x3_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<void *>("m2Values"); @@ -1294,7 +1294,7 @@ void tst_QMatrix::multiply4x3_data() QTest::newRow("unique/transposed") << (void *)uniqueValues4x3 << (void *)transposedValues3x4 << (void *)uniqueResult; } -void tst_QMatrix::multiply4x3() +void tst_QMatrixNxN::multiply4x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1312,7 +1312,7 @@ void tst_QMatrix::multiply4x3() } // Test matrix multiplication by a factor for 2x2 matrices. -void tst_QMatrix::multiplyFactor2x2_data() +void tst_QMatrixNxN::multiplyFactor2x2_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<qreal>("factor"); @@ -1343,7 +1343,7 @@ void tst_QMatrix::multiplyFactor2x2_data() QTest::newRow("zero") << (void *)values << (qreal)0.0f << (void *)nullValues4; } -void tst_QMatrix::multiplyFactor2x2() +void tst_QMatrixNxN::multiplyFactor2x2() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1366,7 +1366,7 @@ void tst_QMatrix::multiplyFactor2x2() } // Test matrix multiplication by a factor for 3x3 matrices. -void tst_QMatrix::multiplyFactor3x3_data() +void tst_QMatrixNxN::multiplyFactor3x3_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<qreal>("factor"); @@ -1400,7 +1400,7 @@ void tst_QMatrix::multiplyFactor3x3_data() QTest::newRow("zero") << (void *)values << (qreal)0.0f << (void *)nullValues4; } -void tst_QMatrix::multiplyFactor3x3() +void tst_QMatrixNxN::multiplyFactor3x3() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1423,7 +1423,7 @@ void tst_QMatrix::multiplyFactor3x3() } // Test matrix multiplication by a factor for 4x4 matrices. -void tst_QMatrix::multiplyFactor4x4_data() +void tst_QMatrixNxN::multiplyFactor4x4_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<qreal>("factor"); @@ -1460,7 +1460,7 @@ void tst_QMatrix::multiplyFactor4x4_data() QTest::newRow("zero") << (void *)values << (qreal)0.0f << (void *)nullValues4; } -void tst_QMatrix::multiplyFactor4x4() +void tst_QMatrixNxN::multiplyFactor4x4() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1483,7 +1483,7 @@ void tst_QMatrix::multiplyFactor4x4() } // Test matrix multiplication by a factor for 4x3 matrices. -void tst_QMatrix::multiplyFactor4x3_data() +void tst_QMatrixNxN::multiplyFactor4x3_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<qreal>("factor"); @@ -1517,7 +1517,7 @@ void tst_QMatrix::multiplyFactor4x3_data() QTest::newRow("zero") << (void *)values << (qreal)0.0f << (void *)nullValues4x3; } -void tst_QMatrix::multiplyFactor4x3() +void tst_QMatrixNxN::multiplyFactor4x3() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1540,12 +1540,12 @@ void tst_QMatrix::multiplyFactor4x3() } // Test matrix division by a factor for 2x2 matrices. -void tst_QMatrix::divideFactor2x2_data() +void tst_QMatrixNxN::divideFactor2x2_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor2x2_data(); } -void tst_QMatrix::divideFactor2x2() +void tst_QMatrixNxN::divideFactor2x2() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1567,12 +1567,12 @@ void tst_QMatrix::divideFactor2x2() } // Test matrix division by a factor for 3x3 matrices. -void tst_QMatrix::divideFactor3x3_data() +void tst_QMatrixNxN::divideFactor3x3_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor3x3_data(); } -void tst_QMatrix::divideFactor3x3() +void tst_QMatrixNxN::divideFactor3x3() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1594,12 +1594,12 @@ void tst_QMatrix::divideFactor3x3() } // Test matrix division by a factor for 4x4 matrices. -void tst_QMatrix::divideFactor4x4_data() +void tst_QMatrixNxN::divideFactor4x4_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor4x4_data(); } -void tst_QMatrix::divideFactor4x4() +void tst_QMatrixNxN::divideFactor4x4() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1621,12 +1621,12 @@ void tst_QMatrix::divideFactor4x4() } // Test matrix division by a factor for 4x3 matrices. -void tst_QMatrix::divideFactor4x3_data() +void tst_QMatrixNxN::divideFactor4x3_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor4x3_data(); } -void tst_QMatrix::divideFactor4x3() +void tst_QMatrixNxN::divideFactor4x3() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1648,12 +1648,12 @@ void tst_QMatrix::divideFactor4x3() } // Test matrix negation for 2x2 matrices. -void tst_QMatrix::negate2x2_data() +void tst_QMatrixNxN::negate2x2_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor2x2_data(); } -void tst_QMatrix::negate2x2() +void tst_QMatrixNxN::negate2x2() { QFETCH(void *, m1Values); @@ -1671,12 +1671,12 @@ void tst_QMatrix::negate2x2() } // Test matrix negation for 3x3 matrices. -void tst_QMatrix::negate3x3_data() +void tst_QMatrixNxN::negate3x3_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor3x3_data(); } -void tst_QMatrix::negate3x3() +void tst_QMatrixNxN::negate3x3() { QFETCH(void *, m1Values); @@ -1694,12 +1694,12 @@ void tst_QMatrix::negate3x3() } // Test matrix negation for 4x4 matrices. -void tst_QMatrix::negate4x4_data() +void tst_QMatrixNxN::negate4x4_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor4x4_data(); } -void tst_QMatrix::negate4x4() +void tst_QMatrixNxN::negate4x4() { QFETCH(void *, m1Values); @@ -1717,12 +1717,12 @@ void tst_QMatrix::negate4x4() } // Test matrix negation for 4x3 matrices. -void tst_QMatrix::negate4x3_data() +void tst_QMatrixNxN::negate4x3_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor4x3_data(); } -void tst_QMatrix::negate4x3() +void tst_QMatrixNxN::negate4x3() { QFETCH(void *, m1Values); @@ -1823,7 +1823,7 @@ static void m4Inverse(const Matrix4& min, Matrix4& mout) } // Test matrix inverted for 4x4 matrices. -void tst_QMatrix::inverted4x4_data() +void tst_QMatrixNxN::inverted4x4_data() { QTest::addColumn<void *>("m1Values"); QTest::addColumn<void *>("m2Values"); @@ -1866,7 +1866,7 @@ void tst_QMatrix::inverted4x4_data() QTest::newRow("translate") << (void *)translate.v << (void *)inverseTranslate.v << true; } -void tst_QMatrix::inverted4x4() +void tst_QMatrixNxN::inverted4x4() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1914,7 +1914,7 @@ void tst_QMatrix::inverted4x4() QCOMPARE(inv, invertible); } -void tst_QMatrix::orthonormalInverse4x4() +void tst_QMatrixNxN::orthonormalInverse4x4() { QMatrix4x4 m1; QVERIFY(matrixFuzzyCompare(m1.inverted(), m1)); @@ -1949,7 +1949,7 @@ void tst_QMatrix::orthonormalInverse4x4() } // Test the generation and use of 4x4 scale matrices. -void tst_QMatrix::scale4x4_data() +void tst_QMatrixNxN::scale4x4_data() { QTest::addColumn<qreal>("x"); QTest::addColumn<qreal>("y"); @@ -1991,7 +1991,7 @@ void tst_QMatrix::scale4x4_data() QTest::newRow("complex2D") << (qreal)2.0f << (qreal)-11.0f << (qreal)1.0f << (void *)complexScale2D; } -void tst_QMatrix::scale4x4() +void tst_QMatrixNxN::scale4x4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -2103,7 +2103,7 @@ void tst_QMatrix::scale4x4() } // Test the generation and use of 4x4 translation matrices. -void tst_QMatrix::translate4x4_data() +void tst_QMatrixNxN::translate4x4_data() { QTest::addColumn<qreal>("x"); QTest::addColumn<qreal>("y"); @@ -2137,7 +2137,7 @@ void tst_QMatrix::translate4x4_data() QTest::newRow("complex2D") << (qreal)2.0f << (qreal)-11.0f << (qreal)0.0f << (void *)complexTranslate2D; } -void tst_QMatrix::translate4x4() +void tst_QMatrixNxN::translate4x4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -2203,7 +2203,7 @@ void tst_QMatrix::translate4x4() } // Test the generation and use of 4x4 rotation matrices. -void tst_QMatrix::rotate4x4_data() +void tst_QMatrixNxN::rotate4x4_data() { QTest::addColumn<qreal>("angle"); QTest::addColumn<qreal>("x"); @@ -2326,7 +2326,7 @@ void tst_QMatrix::rotate4x4_data() << (qreal)x << (qreal)y << (qreal)z << (void *)complexRotate; } -void tst_QMatrix::rotate4x4() +void tst_QMatrixNxN::rotate4x4() { QFETCH(qreal, angle); QFETCH(qreal, x); @@ -2441,7 +2441,7 @@ static bool isSame(const QMatrix3x3& m1, const Matrix3& m2) } // Test the computation of normal matrices from 4x4 transformation matrices. -void tst_QMatrix::normalMatrix_data() +void tst_QMatrixNxN::normalMatrix_data() { QTest::addColumn<void *>("mValues"); @@ -2488,7 +2488,7 @@ void tst_QMatrix::normalMatrix_data() QTest::newRow("null scale 2") << (void *)nullScaleValues2; QTest::newRow("null scale 3") << (void *)nullScaleValues3; } -void tst_QMatrix::normalMatrix() +void tst_QMatrixNxN::normalMatrix() { QFETCH(void *, mValues); const qreal *values = (const qreal *)mValues; @@ -2529,7 +2529,7 @@ void tst_QMatrix::normalMatrix() } // Test optimized transformations on 4x4 matrices. -void tst_QMatrix::optimizedTransforms() +void tst_QMatrixNxN::optimizedTransforms() { static qreal const translateValues[16] = {1.0f, 0.0f, 0.0f, 4.0f, @@ -2640,7 +2640,7 @@ void tst_QMatrix::optimizedTransforms() } // Test orthographic projections. -void tst_QMatrix::ortho() +void tst_QMatrixNxN::ortho() { QMatrix4x4 m1; m1.ortho(QRect(0, 0, 300, 150)); @@ -2729,7 +2729,7 @@ void tst_QMatrix::ortho() } // Test perspective frustum projections. -void tst_QMatrix::frustum() +void tst_QMatrixNxN::frustum() { QMatrix4x4 m1; m1.frustum(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); @@ -2765,7 +2765,7 @@ void tst_QMatrix::frustum() } // Test perspective field-of-view projections. -void tst_QMatrix::perspective() +void tst_QMatrixNxN::perspective() { QMatrix4x4 m1; m1.perspective(45.0f, 1.0f, -1.0f, 1.0f); @@ -2801,7 +2801,7 @@ void tst_QMatrix::perspective() } // Test left-handed vs right-handed coordinate flipping. -void tst_QMatrix::flipCoordinates() +void tst_QMatrixNxN::flipCoordinates() { QMatrix4x4 m1; m1.flipCoordinates(); @@ -2828,7 +2828,7 @@ void tst_QMatrix::flipCoordinates() } // Test conversion of generic matrices to and from the non-generic types. -void tst_QMatrix::convertGeneric() +void tst_QMatrixNxN::convertGeneric() { QMatrix4x3 m1(uniqueValues4x3); @@ -2860,7 +2860,7 @@ void tst_QMatrix::convertGeneric() QVERIFY(isSame(m11, conv4x4)); } -void tst_QMatrix::extractAxisRotation_data() +void tst_QMatrixNxN::extractAxisRotation_data() { QTest::addColumn<float>("x"); QTest::addColumn<float>("y"); @@ -2893,7 +2893,7 @@ void tst_QMatrix::extractAxisRotation_data() QTest::newRow("1, 1, 1, 300 deg") << 1.0f << 1.0f << 1.0f << 300.0f; } -void tst_QMatrix::extractAxisRotation() +void tst_QMatrixNxN::extractAxisRotation() { QFETCH(float, x); QFETCH(float, y); @@ -2922,7 +2922,7 @@ void tst_QMatrix::extractAxisRotation() } } -void tst_QMatrix::extractTranslation_data() +void tst_QMatrixNxN::extractTranslation_data() { QTest::addColumn<QMatrix4x4>("rotation"); QTest::addColumn<float>("x"); @@ -2948,7 +2948,7 @@ void tst_QMatrix::extractTranslation_data() QTest::newRow("rotZ 75, rotX 25, rotY 45, 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f; } -void tst_QMatrix::extractTranslation() +void tst_QMatrixNxN::extractTranslation() { QFETCH(QMatrix4x4, rotation); QFETCH(float, x); @@ -2995,7 +2995,7 @@ struct Matrix4x4 }; // Test the inferring of special matrix types. -void tst_QMatrix::inferSpecialType_data() +void tst_QMatrixNxN::inferSpecialType_data() { QTest::addColumn<void *>("mValues"); QTest::addColumn<int>("flagBits"); @@ -3043,7 +3043,7 @@ void tst_QMatrix::inferSpecialType_data() QTest::newRow("below") << (void *)belowValues << (int)General; } -void tst_QMatrix::inferSpecialType() +void tst_QMatrixNxN::inferSpecialType() { QFETCH(void *, mValues); QFETCH(int, flagBits); @@ -3054,7 +3054,7 @@ void tst_QMatrix::inferSpecialType() QCOMPARE(reinterpret_cast<Matrix4x4 *>(&m)->flagBits, flagBits); } -void tst_QMatrix::columnsAndRows() +void tst_QMatrixNxN::columnsAndRows() { QMatrix4x4 m1(uniqueValues4); @@ -3102,7 +3102,7 @@ void tst_QMatrix::columnsAndRows() // Test converting QMatrix objects into QMatrix4x4 and then // checking that transformations in the original perform the // equivalent transformations in the new matrix. -void tst_QMatrix::convertQMatrix() +void tst_QMatrixNxN::convertQMatrix() { QMatrix m1; m1.translate(-3.5, 2.0); @@ -3149,7 +3149,7 @@ void tst_QMatrix::convertQMatrix() // Test converting QTransform objects into QMatrix4x4 and then // checking that transformations in the original perform the // equivalent transformations in the new matrix. -void tst_QMatrix::convertQTransform() +void tst_QMatrixNxN::convertQTransform() { QTransform m1; m1.translate(-3.5, 2.0); @@ -3197,7 +3197,7 @@ void tst_QMatrix::convertQTransform() } // Test filling matrices with specific values. -void tst_QMatrix::fill() +void tst_QMatrixNxN::fill() { QMatrix4x4 m1; m1.fill(0.0f); @@ -3224,7 +3224,7 @@ void tst_QMatrix::fill() } // Test the mapRect() function for QRect and QRectF. -void tst_QMatrix::mapRect_data() +void tst_QMatrixNxN::mapRect_data() { QTest::addColumn<qreal>("x"); QTest::addColumn<qreal>("y"); @@ -3236,7 +3236,7 @@ void tst_QMatrix::mapRect_data() QTest::newRow("rect") << (qreal)1.0f << (qreal)-20.5f << (qreal)100.0f << (qreal)63.75f; } -void tst_QMatrix::mapRect() +void tst_QMatrixNxN::mapRect() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -3334,12 +3334,12 @@ void tst_QMatrix::mapRect() QVERIFY(mri == tri); } -class tst_QMatrix4x4Properties : public QObject +class tst_QMatrixNxN4x4Properties : public QObject { Q_OBJECT Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix) public: - tst_QMatrix4x4Properties(QObject *parent = 0) : QObject(parent) {} + tst_QMatrixNxN4x4Properties(QObject *parent = 0) : QObject(parent) {} QMatrix4x4 matrix() const { return m; } void setMatrix(const QMatrix4x4& value) { m = value; } @@ -3349,9 +3349,9 @@ private: }; // Test getting and setting matrix properties via the metaobject system. -void tst_QMatrix::properties() +void tst_QMatrixNxN::properties() { - tst_QMatrix4x4Properties obj; + tst_QMatrixNxN4x4Properties obj; QMatrix4x4 m1(uniqueValues4); obj.setMatrix(m1); @@ -3366,7 +3366,7 @@ void tst_QMatrix::properties() QVERIFY(isSame(m2, transposedValues4)); } -void tst_QMatrix::metaTypes() +void tst_QMatrixNxN::metaTypes() { QVERIFY(QMetaType::type("QMatrix4x4") == QMetaType::QMatrix4x4); @@ -3378,6 +3378,6 @@ void tst_QMatrix::metaTypes() QVERIFY(qMetaTypeId<QMatrix4x4>() == QMetaType::QMatrix4x4); } -QTEST_APPLESS_MAIN(tst_QMatrix) +QTEST_APPLESS_MAIN(tst_QMatrixNxN) #include "tst_qmatrixnxn.moc" 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/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index e0548a7..686f62f 100644 --- a/tests/auto/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp @@ -598,7 +598,7 @@ void tst_QDockWidget::visibilityChanged() QCOMPARE(spy.count(), 0); mw.addDockWidget(Qt::RightDockWidgetArea, &dw2); - qApp->processEvents(); + QTest::qWait(200); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); } diff --git a/tests/auto/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp b/tests/auto/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp index 4cdeb5c..97e57f1 100644 --- a/tests/auto/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp +++ b/tests/auto/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp @@ -61,6 +61,7 @@ private Q_SLOTS: void clone() const; void data() const; void reset() const; + void swap() const; }; class MyClass : public QSharedData @@ -233,6 +234,25 @@ void tst_QExplicitlySharedDataPointer::reset() const } } +void tst_QExplicitlySharedDataPointer::swap() const +{ + QExplicitlySharedDataPointer<MyClass> p1(0), p2(new MyClass()); + QVERIFY(!p1.data()); + QVERIFY(p2.data()); + + p1.swap(p2); + QVERIFY(p1.data()); + QVERIFY(!p2.data()); + + p1.swap(p2); + QVERIFY(!p1.data()); + QVERIFY(p2.data()); + + qSwap(p1, p2); + QVERIFY(p1.data()); + QVERIFY(!p2.data()); +} + QTEST_MAIN(tst_QExplicitlySharedDataPointer) #include "tst_qexplicitlyshareddatapointer.moc" 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/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index eadf8b7..a623b50 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -280,6 +280,7 @@ private slots: void autoDetectFocusProxy(); void subFocus(); void reverseCreateAutoFocusProxy(); + void focusProxyDeletion(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -7516,5 +7517,46 @@ void tst_QGraphicsItem::reverseCreateAutoFocusProxy() QVERIFY(text2->hasFocus()); } +void tst_QGraphicsItem::focusProxyDeletion() +{ + QGraphicsRectItem *rect = new QGraphicsRectItem; + QGraphicsRectItem *rect2 = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2); + + delete rect2; + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0); + + rect2 = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + delete rect; // don't crash + + rect = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + QGraphicsScene *scene = new QGraphicsScene; + scene->addItem(rect); + scene->addItem(rect2); + delete rect2; + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0); + + rect2 = new QGraphicsRectItem; + QTest::ignoreMessage(QtWarningMsg, "QGraphicsItem::setFocusProxy: focus proxy must be in same scene"); + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0); + scene->addItem(rect2); + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2); + delete rect; // don't crash + + rect = new QGraphicsRectItem; + rect2 = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2); + scene->addItem(rect); + scene->addItem(rect2); + rect->setFocusProxy(rect2); + delete scene; // don't crash +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" diff --git a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro index 7cd8d51..889aac9 100644 --- a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro +++ b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro @@ -3,6 +3,20 @@ SOURCES += tst_qhelpcontentmodel.cpp CONFIG += help -DEFINES += SRCDIR=\\\"$$PWD\\\" DEFINES += QT_USE_USING_NAMESPACE !contains(QT_BUILD_PARTS, tools): DEFINES += QT_NO_BUILD_TOOLS + +wince*: { + DEFINES += SRCDIR=\\\"./\\\" + QT += network + addFiles.sources = $$PWD/data/*.* + addFiles.path = data + clucene.sources = $$QT_BUILD_TREE/lib/QtCLucene*.dll + + DEPLOYMENT += addFiles + DEPLOYMENT += clucene + + DEPLOYMENT_PLUGIN += qsqlite +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +}
\ No newline at end of file diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp index 499c367..d765c25 100644 --- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp +++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp @@ -98,6 +98,8 @@ void tst_QHelpEngineCore::init() // defined in profile m_path = QLatin1String(SRCDIR); + m_path = QFileInfo(m_path).absoluteFilePath(); + m_colFile = m_path + QLatin1String("/data/col.qhc"); if (QFile::exists(m_colFile)) QDir::current().remove(m_colFile); diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro b/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro index 11fca8e..27ebd0f 100644 --- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro +++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro @@ -3,6 +3,21 @@ SOURCES += tst_qhelpenginecore.cpp CONFIG += help QT += sql -DEFINES += SRCDIR=\\\"$$PWD\\\" + DEFINES += QT_USE_USING_NAMESPACE !contains(QT_BUILD_PARTS, tools): DEFINES += QT_NO_BUILD_TOOLS + +wince*: { + DEFINES += SRCDIR=\\\"./\\\" + QT += network + addFiles.sources = $$PWD/data/*.* + addFiles.path = data + clucene.sources = $$QT_BUILD_TREE/lib/QtCLucene*.dll + + DEPLOYMENT += addFiles + DEPLOYMENT += clucene + + DEPLOYMENT_PLUGIN += qsqlite +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} 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*: { diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 58e5401..ab75c91 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -62,6 +62,7 @@ class tst_QSharedPointer: public QObject private slots: void basics_data(); void basics(); + void swap(); void forwardDeclaration1(); void forwardDeclaration2(); void memoryManagement(); @@ -263,6 +264,37 @@ void tst_QSharedPointer::basics() // aData is deleted here } +void tst_QSharedPointer::swap() +{ + QSharedPointer<int> p1, p2(new int(42)), control = p2; + QVERIFY(p1 != control); + QVERIFY(p1.isNull()); + QVERIFY(p2 == control); + QVERIFY(!p2.isNull()); + QVERIFY(*p2 == 42); + + p1.swap(p2); + QVERIFY(p1 == control); + QVERIFY(!p1.isNull()); + QVERIFY(p2 != control); + QVERIFY(p2.isNull()); + QVERIFY(*p1 == 42); + + p1.swap(p2); + QVERIFY(p1 != control); + QVERIFY(p1.isNull()); + QVERIFY(p2 == control); + QVERIFY(!p2.isNull()); + QVERIFY(*p2 == 42); + + qSwap(p1, p2); + QVERIFY(p1 == control); + QVERIFY(!p1.isNull()); + QVERIFY(p2 != control); + QVERIFY(p2.isNull()); + QVERIFY(*p1 == 42); +} + class ForwardDeclared; ForwardDeclared *forwardPointer(); void externalForwardDeclaration(); diff --git a/tests/auto/qtextcodec/test/test.pro b/tests/auto/qtextcodec/test/test.pro index 9c07e76..99f94d4 100644 --- a/tests/auto/qtextcodec/test/test.pro +++ b/tests/auto/qtextcodec/test/test.pro @@ -1,6 +1,21 @@ load(qttest_p4) -TARGET = ../tst_qtextcodec + SOURCES += ../tst_qtextcodec.cpp + +!wince*: { +TARGET = ../tst_qtextcodec + +win32: { + CONFIG(debug, debug|release) { + TARGET = ../../debug/tst_qtextcodec +} else { + TARGET = ../../release/tst_qtextcodec + } +} +} else { + TARGET = tst_qtextcodec +} + wince*: { addFiles.sources = ../*.txt addFiles.path = . diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 72f3ea8..4643df0 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -55,8 +55,13 @@ #include <qtextlist.h> #include <qtextcodec.h> #include <qurl.h> +#include <qpainter.h> +#include <qfontmetrics.h> +#include <qimage.h> +#include <qtextlayout.h> #include "common.h" + QT_FORWARD_DECLARE_CLASS(QTextDocument) //TESTED_CLASS= @@ -93,6 +98,8 @@ private slots: void noundo_isModified3(); void mightBeRichText(); + void task240325(); + void toHtml_data(); void toHtml(); void toHtml2(); @@ -532,6 +539,38 @@ void tst_QTextDocument::noundo_basicIsModifiedChecks() QCOMPARE(spy.count(), 0); } +void tst_QTextDocument::task240325() +{ + doc->setHtml("<html><img width=\"100\" height=\"100\" align=\"right\"/>Foobar Foobar Foobar Foobar</html>"); + + QImage img(1000, 7000, QImage::Format_ARGB32_Premultiplied); + QPainter p(&img); + QFontMetrics fm(p.font()); + + // Set page size to contain image and one "Foobar" + doc->setPageSize(QSize(100 + fm.width("Foobar")*2, 1000)); + + // Force layout + doc->drawContents(&p); + + QCOMPARE(doc->blockCount(), 1); + for (QTextBlock block = doc->begin() ; block!=doc->end() ; block = block.next()) { + QTextLayout *layout = block.layout(); + QCOMPARE(layout->lineCount(), 4); + for (int lineIdx=0;lineIdx<layout->lineCount();++lineIdx) { + QTextLine line = layout->lineAt(lineIdx); + + QString text = block.text().mid(line.textStart(), line.textLength()).trimmed(); + + // Remove start token + if (lineIdx == 0) + text = text.mid(1); + + QCOMPARE(text, QString::fromLatin1("Foobar")); + } + } +} + void tst_QTextDocument::noundo_moreIsModified() { doc->setUndoRedoEnabled(false); |