summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-01-14 14:06:40 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-01-14 14:06:40 (GMT)
commitcfee61fd74d7fe73f0de13356fe683bc8ae91f92 (patch)
tree08a4d1764e69b97f85d581e42602bb180cb642ba /tests
parent00ffa3cee315e9d99bb6c5d3666ab984b2be2bf7 (diff)
parentf894fb8228e35a43b2baf80666ca5bca6e987064 (diff)
downloadQt-cfee61fd74d7fe73f0de13356fe683bc8ae91f92.zip
Qt-cfee61fd74d7fe73f0de13356fe683bc8ae91f92.tar.gz
Qt-cfee61fd74d7fe73f0de13356fe683bc8ae91f92.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( 8f6992f4e8f027818429d428393b08068eca9ffa ) Better fix for build!=src Makefile generation Make input mask cursor blink Fix QGLWidget::renderPixmap() on Windows. Fix rules for recreating the Makefile in a subdir Disable some tests that require high floating point precision. Replace the truncate function with fuzzierCompare(). Rework how Qt handles GL extensions. More changelog additions for QtWebKit Make compile on symbian/Linux Removed pointless image comparison in raster colorize filter. Improved performance of translating device coordinate graphics effects.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp3
-rw-r--r--tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp44
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp46
3 files changed, 77 insertions, 16 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 8c8ab81..16a621a 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -1669,6 +1669,9 @@ void tst_QGraphicsAnchorLayout::floatConflict()
void tst_QGraphicsAnchorLayout::infiniteMaxSizes()
{
+ if (sizeof(qreal) <= 4) {
+ QSKIP("qreal has too little precision, result will be wrong", SkipAll);
+ }
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0);
diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index e3d1bbe..7880d2d 100644
--- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -1525,7 +1525,11 @@ void tst_QGraphicsAnchorLayout1::testMulti_data()
}
- QTest::newRow("Linear multi") << QSizeF(width, height) << theData << theResult;
+ if (sizeof(qreal) == 4) {
+ qDebug("Linear multi: Skipping! (qreal has too little precision, result will be wrong)");
+ } else {
+ QTest::newRow("Linear multi") << QSizeF(width, height) << theData << theResult;
+ }
}
// Multiple widgets, V shape
@@ -1595,7 +1599,11 @@ void tst_QGraphicsAnchorLayout1::testMulti_data()
}
}
- QTest::newRow("V multi") << QSizeF(width, height) << theData << theResult;
+ if (sizeof(qreal) == 4) {
+ qDebug("V multi: Skipping! (qreal has too little precision, result will be wrong)");
+ } else {
+ QTest::newRow("V multi") << QSizeF(width, height) << theData << theResult;
+ }
}
// Multiple widgets, grid
@@ -1653,7 +1661,11 @@ void tst_QGraphicsAnchorLayout1::testMulti_data()
<< BasicResult(i, QRectF(((i%d)+1)*horizontalStep, ((i/d)+1)*verticalStep, horizontalStep, verticalStep) );
}
- QTest::newRow("Grid multi") << QSizeF(200, 100) << theData << theResult;
+ if (sizeof(qreal) == 4) {
+ qDebug("Grid multi: Skipping! (qreal has too little precision, result will be wrong)");
+ } else {
+ QTest::newRow("Grid multi") << QSizeF(200, 100) << theData << theResult;
+ }
}
}
@@ -1669,16 +1681,16 @@ inline QGraphicsLayoutItem *getItem(
return widgets[index];
}
-static QRectF truncate(QRectF original)
+static bool fuzzierCompare(qreal a, qreal b)
{
- QRectF result;
+ return qAbs(a - b) <= qreal(0.0001);
+}
- result.setX(qRound(original.x() * 1000000) / 1000000.0);
- result.setY(qRound(original.y() * 1000000) / 1000000.0);
- result.setWidth(qRound(original.width() * 1000000) / 1000000.0);
- result.setHeight(qRound(original.height() * 1000000) / 1000000.0);
+static bool fuzzierCompare(const QRectF &r1, const QRectF &r2)
+{
- return result;
+ return fuzzierCompare(r1.x(), r2.x()) && fuzzierCompare(r1.y(), r2.y())
+ && fuzzierCompare(r1.width(), r2.width()) && fuzzierCompare(r1.height(), r2.height());
}
void tst_QGraphicsAnchorLayout1::testBasicLayout()
@@ -1727,10 +1739,10 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
// Validate
for (int i = 0; i < result.count(); ++i) {
const BasicLayoutTestResult item = result[i];
- QRectF expected = truncate(item.rect);
- QRectF actual = truncate(widgets[item.index]->geometry());
+ QRectF expected = item.rect;
+ QRectF actual = widgets[item.index]->geometry();
- QCOMPARE(actual, expected);
+ QVERIFY(fuzzierCompare(actual, expected));
}
// Test mirrored mode
@@ -1744,10 +1756,10 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
if (mirroredRect.isValid()){
mirroredRect.moveLeft(size.width()-item.rect.width()-item.rect.left());
}
- QRectF expected = truncate(mirroredRect);
- QRectF actual = truncate(widgets[item.index]->geometry());
+ QRectF expected = mirroredRect;
+ QRectF actual = widgets[item.index]->geometry();
- QCOMPARE(actual, expected);
+ QVERIFY(fuzzierCompare(actual, expected));
}
qDeleteAll(widgets);
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index 95de70e..51e2a57 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -70,6 +70,7 @@ private slots:
void grayscale();
void colorize();
void drawPixmapItem();
+ void deviceCoordinateTranslateCaching();
};
void tst_QGraphicsEffect::initTestCase()
@@ -514,6 +515,51 @@ void tst_QGraphicsEffect::drawPixmapItem()
QTRY_VERIFY(effect->repaints >= 2);
}
+class DeviceEffect : public QGraphicsEffect
+{
+public:
+ QRectF boundingRectFor(const QRectF &rect) const
+ { return rect; }
+
+ void draw(QPainter *painter)
+ {
+ QPoint offset;
+ QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, QGraphicsEffect::NoPad);
+
+ if (pixmap.isNull())
+ return;
+
+ painter->save();
+ painter->setWorldTransform(QTransform());
+ painter->drawPixmap(offset, pixmap);
+ painter->restore();
+ }
+};
+
+void tst_QGraphicsEffect::deviceCoordinateTranslateCaching()
+{
+ QGraphicsScene scene;
+ CustomItem *item = new CustomItem(0, 0, 10, 10);
+ scene.addItem(item);
+ scene.setSceneRect(0, 0, 50, 0);
+
+ item->setGraphicsEffect(new DeviceEffect);
+ item->setPen(Qt::NoPen);
+ item->setBrush(Qt::red);
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QTRY_VERIFY(item->numRepaints >= 1);
+ int numRepaints = item->numRepaints;
+
+ item->translate(10, 0);
+ QTest::qWait(50);
+
+ QVERIFY(item->numRepaints == numRepaints);
+}
+
QTEST_MAIN(tst_QGraphicsEffect)
#include "tst_qgraphicseffect.moc"