summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-06-02 10:53:55 +0200
committerAlexis Menard <alexis.menard@nokia.com>2009-06-02 10:53:55 +0200
commit0e139242e5dd465c9ffa0e2cbeb17b7009b821d1 (patch)
treef8f3ee0b059c4de74fe58d340cb1d55594e6fdbc /tests/auto
parent53187fabdbfb8a513e735fdd034e1a9fbbccc9cd (diff)
parentd52fb58f34199e9a6e008929425cd21b92a2674a (diff)
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into qt-main/qgraphicssceneindex
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp154
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp24
-rwxr-xr-xtests/auto/test.pl2
3 files changed, 179 insertions, 1 deletions
diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
index bb510fc5f1..4d51e894e8 100644
--- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -167,6 +167,9 @@ private slots:
void fill();
+ void mapRect_data();
+ void mapRect();
+
private:
static void setMatrix(QMatrix2x2& m, const qreal *values);
static void setMatrixFixed(QMatrix2x2& m, const qreal *values);
@@ -1975,6 +1978,14 @@ void tst_QMatrix::scale4x4_data()
0.0f, 0.0f, 0.0f, 1.0f};
QTest::newRow("complex")
<< (qreal)2.0f << (qreal)11.0f << (qreal)-6.5f << (void *)complexScale;
+
+ static const qreal complexScale2D[] =
+ {2.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, -11.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f};
+ QTest::newRow("complex2D")
+ << (qreal)2.0f << (qreal)-11.0f << (qreal)1.0f << (void *)complexScale2D;
}
void tst_QMatrix::scale4x4()
{
@@ -1993,6 +2004,12 @@ void tst_QMatrix::scale4x4()
m2.scale(x, y, z);
QVERIFY(isSame(m2, (const qreal *)resultValues));
+ if (z == 1.0f) {
+ QMatrix4x4 m2b;
+ m2b.scale(x, y);
+ QVERIFY(m2b == m2);
+ }
+
QVector3D v1(2.0f, 3.0f, -4.0f);
QVector3D v2 = m1 * v1;
QCOMPARE(v2.x(), (qreal)(2.0f * x));
@@ -2046,6 +2063,12 @@ void tst_QMatrix::scale4x4()
QVERIFY(isSame(m5, (const qreal *)resultValues));
}
+ if (z == 1.0f) {
+ QMatrix4x4 m4b(m3);
+ m4b.scale(x, y);
+ QVERIFY(m4b == m4);
+ }
+
// Test coverage when the special matrix type is unknown.
QMatrix4x4 m6;
@@ -2101,6 +2124,14 @@ void tst_QMatrix::translate4x4_data()
0.0f, 0.0f, 0.0f, 1.0f};
QTest::newRow("complex")
<< (qreal)2.0f << (qreal)11.0f << (qreal)-6.5f << (void *)complexTranslate;
+
+ static const qreal complexTranslate2D[] =
+ {1.0f, 0.0f, 0.0f, 2.0f,
+ 0.0f, 1.0f, 0.0f, -11.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f};
+ QTest::newRow("complex2D")
+ << (qreal)2.0f << (qreal)-11.0f << (qreal)0.0f << (void *)complexTranslate2D;
}
void tst_QMatrix::translate4x4()
{
@@ -2119,6 +2150,12 @@ void tst_QMatrix::translate4x4()
m2.translate(x, y, z);
QVERIFY(isSame(m2, (const qreal *)resultValues));
+ if (z == 0.0f) {
+ QMatrix4x4 m2b;
+ m2b.translate(x, y);
+ QVERIFY(m2b == m2);
+ }
+
QVector3D v1(2.0f, 3.0f, -4.0f);
QVector3D v2 = m1 * v1;
QCOMPARE(v2.x(), (qreal)(2.0f + x));
@@ -2153,6 +2190,12 @@ void tst_QMatrix::translate4x4()
QMatrix4x4 m4(m3);
m4.translate(x, y, z);
QVERIFY(m4 == m3 * m1);
+
+ if (z == 0.0f) {
+ QMatrix4x4 m4b(m3);
+ m4b.translate(x, y);
+ QVERIFY(m4b == m4);
+ }
}
// Test the generation and use of 4x4 rotation matrices.
@@ -3180,6 +3223,117 @@ void tst_QMatrix::fill()
QVERIFY(isSame(m2, fillValues4x3));
}
+// Test the mapRect() function for QRect and QRectF.
+void tst_QMatrix::mapRect_data()
+{
+ QTest::addColumn<qreal>("x");
+ QTest::addColumn<qreal>("y");
+ QTest::addColumn<qreal>("width");
+ QTest::addColumn<qreal>("height");
+
+ QTest::newRow("null")
+ << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f;
+ QTest::newRow("rect")
+ << (qreal)1.0f << (qreal)-20.5f << (qreal)100.0f << (qreal)63.75f;
+}
+void tst_QMatrix::mapRect()
+{
+ QFETCH(qreal, x);
+ QFETCH(qreal, y);
+ QFETCH(qreal, width);
+ QFETCH(qreal, height);
+
+ QRectF rect(x, y, width, height);
+ QRect recti(qRound(x), qRound(y), qRound(width), qRound(height));
+
+ QMatrix4x4 m1;
+ QVERIFY(m1.mapRect(rect) == rect);
+ QVERIFY(m1.mapRect(recti) == recti);
+
+ QMatrix4x4 m2;
+ m2.translate(-100.5f, 64.0f);
+ QRectF translated = rect.translated(-100.5f, 64.0f);
+ QRect translatedi = QRect(qRound(recti.x() - 100.5f), recti.y() + 64,
+ recti.width(), recti.height());
+ QVERIFY(m2.mapRect(rect) == translated);
+ QVERIFY(m2.mapRect(recti) == translatedi);
+
+ QMatrix4x4 m3;
+ m3.scale(-100.5f, 64.0f);
+ qreal scalex = x * -100.5f;
+ qreal scaley = y * 64.0f;
+ qreal scalewid = width * -100.5f;
+ qreal scaleht = height * 64.0f;
+ if (scalewid < 0.0f) {
+ scalewid = -scalewid;
+ scalex -= scalewid;
+ }
+ if (scaleht < 0.0f) {
+ scaleht = -scaleht;
+ scaley -= scaleht;
+ }
+ QRectF scaled(scalex, scaley, scalewid, scaleht);
+ QVERIFY(m3.mapRect(rect) == scaled);
+ scalex = recti.x() * -100.5f;
+ scaley = recti.y() * 64.0f;
+ scalewid = recti.width() * -100.5f;
+ scaleht = recti.height() * 64.0f;
+ if (scalewid < 0.0f) {
+ scalewid = -scalewid;
+ scalex -= scalewid;
+ }
+ if (scaleht < 0.0f) {
+ scaleht = -scaleht;
+ scaley -= scaleht;
+ }
+ QRect scaledi(qRound(scalex), qRound(scaley),
+ qRound(scalewid), qRound(scaleht));
+ QVERIFY(m3.mapRect(recti) == scaledi);
+
+ QMatrix4x4 m4;
+ m4.translate(-100.5f, 64.0f);
+ m4.scale(-2.5f, 4.0f);
+ qreal transx1 = x * -2.5f - 100.5f;
+ qreal transy1 = y * 4.0f + 64.0f;
+ qreal transx2 = (x + width) * -2.5f - 100.5f;
+ qreal transy2 = (y + height) * 4.0f + 64.0f;
+ if (transx1 > transx2)
+ qSwap(transx1, transx2);
+ if (transy1 > transy2)
+ qSwap(transy1, transy2);
+ QRectF trans(transx1, transy1, transx2 - transx1, transy2 - transy1);
+ QVERIFY(m4.mapRect(rect) == trans);
+ transx1 = recti.x() * -2.5f - 100.5f;
+ transy1 = recti.y() * 4.0f + 64.0f;
+ transx2 = (recti.x() + recti.width()) * -2.5f - 100.5f;
+ transy2 = (recti.y() + recti.height()) * 4.0f + 64.0f;
+ if (transx1 > transx2)
+ qSwap(transx1, transx2);
+ if (transy1 > transy2)
+ qSwap(transy1, transy2);
+ QRect transi(qRound(transx1), qRound(transy1),
+ qRound(transx2) - qRound(transx1),
+ qRound(transy2) - qRound(transy1));
+ QVERIFY(m4.mapRect(recti) == transi);
+
+ m4.rotate(45.0f, 0.0f, 0.0f, 1.0f);
+
+ QTransform t4;
+ t4.translate(-100.5f, 64.0f);
+ t4.scale(-2.5f, 4.0f);
+ t4.rotate(45.0f);
+ QRectF mr = m4.mapRect(rect);
+ QRectF tr = t4.mapRect(rect);
+ QVERIFY(fuzzyCompare(mr.x(), tr.x()));
+ QVERIFY(fuzzyCompare(mr.y(), tr.y()));
+ QVERIFY(fuzzyCompare(mr.width(), tr.width()));
+ QVERIFY(fuzzyCompare(mr.height(), tr.height()));
+
+ QRect mri = m4.mapRect(recti);
+ QRect tri = t4.mapRect(recti);
+ QVERIFY(mri == tri);
+}
+
QTEST_APPLESS_MAIN(tst_QMatrix)
#include "tst_qmatrixnxn.moc"
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 87f9c13f6f..af0f6cfc07 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -226,6 +226,7 @@ private slots:
void extendedBlendModes();
void zeroOpacity();
+ void clippingBug();
private:
void fillData();
@@ -4168,5 +4169,28 @@ void tst_QPainter::zeroOpacity()
QCOMPARE(target.pixel(0, 0), 0xff000000);
}
+void tst_QPainter::clippingBug()
+{
+ QImage img(32, 32, QImage::Format_ARGB32_Premultiplied);
+ img.fill(0);
+
+ QImage expected = img;
+ QPainter p(&expected);
+ p.fillRect(1, 1, 30, 30, Qt::red);
+ p.end();
+
+ QPainterPath path;
+ path.addRect(1, 1, 30, 30);
+ path.addRect(1, 1, 30, 30);
+ path.addRect(1, 1, 30, 30);
+
+ p.begin(&img);
+ p.setClipPath(path);
+ p.fillRect(0, 0, 32, 32, Qt::red);
+ p.end();
+
+ QCOMPARE(img, expected);
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/test.pl b/tests/auto/test.pl
index f2a1fe43d2..9fd5c9dbd3 100755
--- a/tests/auto/test.pl
+++ b/tests/auto/test.pl
@@ -179,7 +179,7 @@ print " Tests started: $totalStarted \n";
print " Tests executed: $totalExecuted \n";
print " Tests timed out: $totalTimedOut \n";
-# This procedure takes care of handling death children on due time
+# This procedure takes care of handling dead children on due time
sub handleDeath {
$buryChildren = 1;
}