diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-08-14 12:30:01 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-08-14 12:30:01 (GMT) |
commit | 8d846a525a67f2b0b680ed836601712a5250ce57 (patch) | |
tree | 34fef9650992717f5d4274d8c578419ac0475698 /tests | |
parent | 4c31f59d45130eae8f140e6d0177a4b227454187 (diff) | |
parent | b770651f19741907cd415ea9ad6e087cb32cc948 (diff) | |
download | Qt-8d846a525a67f2b0b680ed836601712a5250ce57.zip Qt-8d846a525a67f2b0b680ed836601712a5250ce57.tar.gz Qt-8d846a525a67f2b0b680ed836601712a5250ce57.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into qtscript-jsc-backend
Diffstat (limited to 'tests')
19 files changed, 1291 insertions, 387 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index d7f27bd..585f461 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/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/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/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/qtouchevent/tst_qtouchevent.cpp b/tests/auto/qtouchevent/tst_qtouchevent.cpp index f30c4db..69b8888 100644 --- a/tests/auto/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/qtouchevent/tst_qtouchevent.cpp @@ -96,6 +96,63 @@ public: } }; +class tst_QTouchEventGraphicsItem : public QGraphicsItem +{ +public: + QList<QTouchEvent::TouchPoint> touchBeginPoints, touchUpdatePoints, touchEndPoints; + bool seenTouchBegin, seenTouchUpdate, seenTouchEnd; + bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd; + + tst_QTouchEventGraphicsItem() + : QGraphicsItem() + { + reset(); + } + + void reset() + { + touchBeginPoints.clear(); + touchUpdatePoints.clear(); + touchEndPoints.clear(); + seenTouchBegin = seenTouchUpdate = seenTouchEnd = false; + acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true; + } + + QRectF boundingRect() const { return QRectF(0, 0, 10, 10); } + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) { } + + bool sceneEvent(QEvent *event) + { + switch (event->type()) { + case QEvent::TouchBegin: + if (seenTouchBegin) qWarning("TouchBegin: already seen a TouchBegin"); + if (seenTouchUpdate) qWarning("TouchBegin: TouchUpdate cannot happen before TouchBegin"); + if (seenTouchEnd) qWarning("TouchBegin: TouchEnd cannot happen before TouchBegin"); + seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd; + touchBeginPoints = static_cast<QTouchEvent *>(event)->touchPoints(); + event->setAccepted(acceptTouchBegin); + break; + case QEvent::TouchUpdate: + if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin"); + if (seenTouchEnd) qWarning("TouchUpdate: TouchEnd cannot happen before TouchUpdate"); + seenTouchUpdate = seenTouchBegin && !seenTouchEnd; + touchUpdatePoints = static_cast<QTouchEvent *>(event)->touchPoints(); + event->setAccepted(acceptTouchUpdate); + break; + case QEvent::TouchEnd: + if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin"); + if (seenTouchEnd) qWarning("TouchEnd: already seen a TouchEnd"); + seenTouchEnd = seenTouchBegin && !seenTouchEnd; + touchEndPoints = static_cast<QTouchEvent *>(event)->touchPoints(); + event->setAccepted(acceptTouchEnd); + break; + default: + return QGraphicsItem::sceneEvent(event); + } + return true; + } +}; + class tst_QTouchEvent : public QObject { Q_OBJECT @@ -115,139 +172,348 @@ private slots: void tst_QTouchEvent::touchDisabledByDefault() { - // the widget attribute is not enabled by default - QWidget widget; - QVERIFY(!widget.testAttribute(Qt::WA_AcceptTouchEvents)); - - // events should not be accepted since they are not enabled - QList<QTouchEvent::TouchPoint> touchPoints; - touchPoints.append(QTouchEvent::TouchPoint(0)); - QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointPressed, - touchPoints); - bool res = QApplication::sendEvent(&widget, &touchEvent); - QVERIFY(!res); - QVERIFY(!touchEvent.isAccepted()); + // QWidget + { + // the widget attribute is not enabled by default + QWidget widget; + QVERIFY(!widget.testAttribute(Qt::WA_AcceptTouchEvents)); + + // events should not be accepted since they are not enabled + QList<QTouchEvent::TouchPoint> touchPoints; + touchPoints.append(QTouchEvent::TouchPoint(0)); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + touchPoints); + bool res = QApplication::sendEvent(&widget, &touchEvent); + QVERIFY(!res); + QVERIFY(!touchEvent.isAccepted()); + } + + // QGraphicsView + { + QGraphicsScene scene; + tst_QTouchEventGraphicsItem item; + QGraphicsView view(&scene); + scene.addItem(&item); + item.setPos(100, 100); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + // touch events are not accepted by default + QVERIFY(!item.acceptTouchEvents()); + + // compose an event to the scene that is over the item + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + (QList<QTouchEvent::TouchPoint>() << touchPoint)); + bool res = QApplication::sendEvent(view.viewport(), &touchEvent); + QVERIFY(!res); + QVERIFY(!touchEvent.isAccepted()); + QVERIFY(!item.seenTouchBegin); + } } void tst_QTouchEvent::touchEventAcceptedByDefault() { - // enabling touch events should automatically accept touch events - QWidget widget; - widget.setAttribute(Qt::WA_AcceptTouchEvents); - - // QWidget handles touch event by converting them into a mouse event, so the event is both - // accepted and handled (res == true) - QList<QTouchEvent::TouchPoint> touchPoints; - touchPoints.append(QTouchEvent::TouchPoint(0)); - QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointPressed, - touchPoints); - bool res = QApplication::sendEvent(&widget, &touchEvent); - QVERIFY(res); - QVERIFY(touchEvent.isAccepted()); - - // tst_QTouchEventWidget does handle, sending succeeds - tst_QTouchEventWidget touchWidget; - touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); - touchEvent.ignore(); - res = QApplication::sendEvent(&touchWidget, &touchEvent); - QVERIFY(res); - QVERIFY(touchEvent.isAccepted()); + // QWidget + { + // enabling touch events should automatically accept touch events + QWidget widget; + widget.setAttribute(Qt::WA_AcceptTouchEvents); + + // QWidget handles touch event by converting them into a mouse event, so the event is both + // accepted and handled (res == true) + QList<QTouchEvent::TouchPoint> touchPoints; + touchPoints.append(QTouchEvent::TouchPoint(0)); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + touchPoints); + bool res = QApplication::sendEvent(&widget, &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + + // tst_QTouchEventWidget does handle, sending succeeds + tst_QTouchEventWidget touchWidget; + touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); + touchEvent.ignore(); + res = QApplication::sendEvent(&touchWidget, &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + } + + // QGraphicsView + { + QGraphicsScene scene; + tst_QTouchEventGraphicsItem item; + QGraphicsView view(&scene); + scene.addItem(&item); + item.setPos(100, 100); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + // enabling touch events on the item also enables events on the viewport + item.setAcceptTouchEvents(true); + QVERIFY(view.viewport()->testAttribute(Qt::WA_AcceptTouchEvents)); + + // compose an event to the scene that is over the item + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + (QList<QTouchEvent::TouchPoint>() << touchPoint)); + bool res = QApplication::sendEvent(view.viewport(), &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + QVERIFY(item.seenTouchBegin); + } } void tst_QTouchEvent::touchBeginPropagatesWhenIgnored() { - tst_QTouchEventWidget window, child, grandchild; - child.setParent(&window); - grandchild.setParent(&child); - - // all widgets accept touch events, grandchild ignores, so child sees the event, but not window - window.setAttribute(Qt::WA_AcceptTouchEvents); - child.setAttribute(Qt::WA_AcceptTouchEvents); - grandchild.setAttribute(Qt::WA_AcceptTouchEvents); - grandchild.acceptTouchBegin = false; - - QList<QTouchEvent::TouchPoint> touchPoints; - touchPoints.append(QTouchEvent::TouchPoint(0)); - QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointPressed, - touchPoints); - bool res = QApplication::sendEvent(&grandchild, &touchEvent); - QVERIFY(res); - QVERIFY(touchEvent.isAccepted()); - QVERIFY(grandchild.seenTouchBegin); - QVERIFY(child.seenTouchBegin); - QVERIFY(!window.seenTouchBegin); - - // disable touch on grandchild. even though it doesn't accept it, child should still get the - // TouchBegin - grandchild.reset(); - child.reset(); - window.reset(); - grandchild.setAttribute(Qt::WA_AcceptTouchEvents, false); - - touchEvent.ignore(); - res = QApplication::sendEvent(&grandchild, &touchEvent); - QVERIFY(res); - QVERIFY(touchEvent.isAccepted()); - QVERIFY(!grandchild.seenTouchBegin); - QVERIFY(child.seenTouchBegin); - QVERIFY(!window.seenTouchBegin); + // QWidget + { + tst_QTouchEventWidget window, child, grandchild; + child.setParent(&window); + grandchild.setParent(&child); + + // all widgets accept touch events, grandchild ignores, so child sees the event, but not window + window.setAttribute(Qt::WA_AcceptTouchEvents); + child.setAttribute(Qt::WA_AcceptTouchEvents); + grandchild.setAttribute(Qt::WA_AcceptTouchEvents); + grandchild.acceptTouchBegin = false; + + QList<QTouchEvent::TouchPoint> touchPoints; + touchPoints.append(QTouchEvent::TouchPoint(0)); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + touchPoints); + bool res = QApplication::sendEvent(&grandchild, &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + QVERIFY(grandchild.seenTouchBegin); + QVERIFY(child.seenTouchBegin); + QVERIFY(!window.seenTouchBegin); + + // disable touch on grandchild. even though it doesn't accept it, child should still get the + // TouchBegin + grandchild.reset(); + child.reset(); + window.reset(); + grandchild.setAttribute(Qt::WA_AcceptTouchEvents, false); + + touchEvent.ignore(); + res = QApplication::sendEvent(&grandchild, &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + QVERIFY(!grandchild.seenTouchBegin); + QVERIFY(child.seenTouchBegin); + QVERIFY(!window.seenTouchBegin); + } + + // QGraphicsView + { + QGraphicsScene scene; + tst_QTouchEventGraphicsItem root, child, grandchild; + QGraphicsView view(&scene); + scene.addItem(&root); + root.setPos(100, 100); + child.setParentItem(&root); + grandchild.setParentItem(&child); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + // all items accept touch events, grandchild ignores, so child sees the event, but not root + root.setAcceptTouchEvents(true); + child.setAcceptTouchEvents(true); + grandchild.setAcceptTouchEvents(true); + grandchild.acceptTouchBegin = false; + + // compose an event to the scene that is over the grandchild + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + (QList<QTouchEvent::TouchPoint>() << touchPoint)); + bool res = QApplication::sendEvent(view.viewport(), &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + QVERIFY(grandchild.seenTouchBegin); + QVERIFY(child.seenTouchBegin); + QVERIFY(!root.seenTouchBegin); + } + + // QGraphicsView + { + QGraphicsScene scene; + tst_QTouchEventGraphicsItem root, child, grandchild; + QGraphicsView view(&scene); + scene.addItem(&root); + root.setPos(100, 100); + child.setParentItem(&root); + grandchild.setParentItem(&child); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + // leave touch disabled on grandchild. even though it doesn't accept it, child should + // still get the TouchBegin + root.setAcceptTouchEvents(true); + child.setAcceptTouchEvents(true); + + // compose an event to the scene that is over the grandchild + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + (QList<QTouchEvent::TouchPoint>() << touchPoint)); + bool res = QApplication::sendEvent(view.viewport(), &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + QVERIFY(!grandchild.seenTouchBegin); + QVERIFY(child.seenTouchBegin); + QVERIFY(!root.seenTouchBegin); + } } void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() { - tst_QTouchEventWidget window, child; - child.setParent(&window); - - window.setAttribute(Qt::WA_AcceptTouchEvents); - child.setAttribute(Qt::WA_AcceptTouchEvents); - child.acceptTouchUpdate = false; - child.acceptTouchEnd = false; - - QList<QTouchEvent::TouchPoint> touchPoints; - touchPoints.append(QTouchEvent::TouchPoint(0)); - QTouchEvent touchBeginEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointPressed, - touchPoints); - bool res = QApplication::sendEvent(&child, &touchBeginEvent); - QVERIFY(res); - QVERIFY(touchBeginEvent.isAccepted()); - QVERIFY(child.seenTouchBegin); - QVERIFY(!window.seenTouchBegin); - - // send the touch update to the child, but ignore it, it doesn't propagate - QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointMoved, - touchPoints); - res = QApplication::sendEvent(&child, &touchUpdateEvent); - QVERIFY(res); - QVERIFY(!touchUpdateEvent.isAccepted()); - QVERIFY(child.seenTouchUpdate); - QVERIFY(!window.seenTouchUpdate); - - // send the touch end, same thing should happen as with touch update - QTouchEvent touchEndEvent(QEvent::TouchEnd, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointReleased, - touchPoints); - res = QApplication::sendEvent(&child, &touchEndEvent); - QVERIFY(res); - QVERIFY(!touchEndEvent.isAccepted()); - QVERIFY(child.seenTouchEnd); - QVERIFY(!window.seenTouchEnd); + // QWidget + { + tst_QTouchEventWidget window, child; + child.setParent(&window); + + window.setAttribute(Qt::WA_AcceptTouchEvents); + child.setAttribute(Qt::WA_AcceptTouchEvents); + child.acceptTouchUpdate = false; + child.acceptTouchEnd = false; + + QList<QTouchEvent::TouchPoint> touchPoints; + touchPoints.append(QTouchEvent::TouchPoint(0)); + QTouchEvent touchBeginEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + touchPoints); + bool res = QApplication::sendEvent(&child, &touchBeginEvent); + QVERIFY(res); + QVERIFY(touchBeginEvent.isAccepted()); + QVERIFY(child.seenTouchBegin); + QVERIFY(!window.seenTouchBegin); + + // send the touch update to the child, but ignore it, it doesn't propagate + QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointMoved, + touchPoints); + res = QApplication::sendEvent(&child, &touchUpdateEvent); + QVERIFY(res); + QVERIFY(!touchUpdateEvent.isAccepted()); + QVERIFY(child.seenTouchUpdate); + QVERIFY(!window.seenTouchUpdate); + + // send the touch end, same thing should happen as with touch update + QTouchEvent touchEndEvent(QEvent::TouchEnd, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointReleased, + touchPoints); + res = QApplication::sendEvent(&child, &touchEndEvent); + QVERIFY(res); + QVERIFY(!touchEndEvent.isAccepted()); + QVERIFY(child.seenTouchEnd); + QVERIFY(!window.seenTouchEnd); + } + + // QGraphicsView + { + QGraphicsScene scene; + tst_QTouchEventGraphicsItem root, child, grandchild; + QGraphicsView view(&scene); + scene.addItem(&root); + root.setPos(100, 100); + child.setParentItem(&root); + grandchild.setParentItem(&child); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + root.setAcceptTouchEvents(true); + child.setAcceptTouchEvents(true); + child.acceptTouchUpdate = false; + child.acceptTouchEnd = false; + + // compose an event to the scene that is over the child + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QTouchEvent touchBeginEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + (QList<QTouchEvent::TouchPoint>() << touchPoint)); + bool res = QApplication::sendEvent(view.viewport(), &touchBeginEvent); + QVERIFY(res); + QVERIFY(touchBeginEvent.isAccepted()); + QVERIFY(child.seenTouchBegin); + QVERIFY(!root.seenTouchBegin); + + // send the touch update to the child, but ignore it, it doesn't propagate + touchPoint.setState(Qt::TouchPointMoved); + QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointMoved, + (QList<QTouchEvent::TouchPoint>() << touchPoint)); + res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); + QVERIFY(res); + // the scene accepts the event, since it found an item to send the event to + QVERIFY(touchUpdateEvent.isAccepted()); + QVERIFY(child.seenTouchUpdate); + QVERIFY(!root.seenTouchUpdate); + + // send the touch end, same thing should happen as with touch update + touchPoint.setState(Qt::TouchPointReleased); + QTouchEvent touchEndEvent(QEvent::TouchEnd, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointReleased, + (QList<QTouchEvent::TouchPoint>() << touchPoint)); + res = QApplication::sendEvent(view.viewport(), &touchEndEvent); + QVERIFY(res); + // the scene accepts the event, since it found an item to send the event to + QVERIFY(touchEndEvent.isAccepted()); + QVERIFY(child.seenTouchEnd); + QVERIFY(!root.seenTouchEnd); + } } QPointF normalized(const QPointF &pos, const QRectF &rect) diff --git a/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui b/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui new file mode 100644 index 0000000..8c5f57c --- /dev/null +++ b/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui @@ -0,0 +1,458 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>698</width> + <height>589</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <property name="styleSheet"> + <string notr="true">* { + background: yellow; + padding: 2px; + border-radius: 4px; +} + +QGroupBox { + border: 1px solid gray; +} + +QAbstractButton { + background: cyan; +} + +QFrame, QMenuBar { + background: magenta; +} + +QLineEdit, QSpinBox { + background: white; +} + +#gb1 * { +} + +#gb2 * { + border: 1px solid blue; +} + +#gb3 * { + border: 0px solid blue; +} + +#gb4 * { + border-image: url("images/pushbutton.png") 6 6 6 6; + border-width:6px; +} +</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="0" column="0"> + <widget class="QGroupBox" name="gb1"> + <property name="title"> + <string>No border</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QFrame" name="frame"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QPushButton" name="pushButton_4"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_2"/> + </item> + <item> + <widget class="QRadioButton" name="radioButton_6"> + <property name="text"> + <string>RadioButton</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_4"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"> + <property name="text"> + <string>LineEdit</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox"> + <item> + <property name="text"> + <string>ComboBox</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidget_2"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="gb3"> + <property name="title"> + <string>0px border</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QFrame" name="frame_2"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QPushButton" name="pushButton_5"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_3"/> + </item> + <item> + <widget class="QRadioButton" name="radioButton_7"> + <property name="text"> + <string>RadioButton</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_5"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_2"> + <property name="text"> + <string>LineEdit</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_2"> + <item> + <property name="text"> + <string>ComboBox</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidget_3"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <widget class="QGroupBox" name="gb4"> + <property name="title"> + <string>border-image</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QFrame" name="frame_4"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <item> + <widget class="QPushButton" name="pushButton_7"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_5"/> + </item> + <item> + <widget class="QRadioButton" name="radioButton_9"> + <property name="text"> + <string>RadioButton</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_7"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_4"> + <property name="text"> + <string>LineEdit</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_4"> + <item> + <property name="text"> + <string>ComboBox</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidget_5"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QGroupBox" name="gb2"> + <property name="title"> + <string>1px border</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QFrame" name="frame_3"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QPushButton" name="pushButton_6"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_4"/> + </item> + <item> + <widget class="QRadioButton" name="radioButton_8"> + <property name="text"> + <string>RadioButton</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_6"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_3"> + <property name="text"> + <string>LineEdit</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_3"> + <item> + <property name="text"> + <string>ComboBox</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidget_4"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>698</width> + <height>24</height> + </rect> + </property> + <widget class="QMenu" name="menuFile"> + <property name="title"> + <string>File</string> + </property> + <addaction name="actionOpen"/> + <addaction name="actionClose"/> + </widget> + <widget class="QMenu" name="menuEdit"> + <property name="title"> + <string>Edit</string> + </property> + </widget> + <addaction name="menuFile"/> + <addaction name="menuEdit"/> + </widget> + <widget class="QStatusBar" name="statusbar"/> + <action name="actionOpen"> + <property name="text"> + <string>Open</string> + </property> + </action> + <action name="actionClose"> + <property name="text"> + <string>Close</string> + </property> + </action> + </widget> + <resources/> + <connections/> +</ui> |