aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2011-07-06 13:39:23 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-07 00:31:08 +0200
commit6b3f959cb3170561276e86b3abbf8ed69ec38c71 (patch)
tree6d7f452ff51ef78a19dbe6b18417ee763d71d4fd /tests
parent12b173b225c9c4960af62074c102a00f18b0fca4 (diff)
Fix QSGImage autotests
Change-Id: I05b7bd4ad98c952ef4d536b987e6afd589a729fb Reviewed-on: http://codereview.qt.nokia.com/1194 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qsgimage/data/mirror.qml2
-rw-r--r--tests/auto/declarative/qsgimage/data/pattern.pngbin0 -> 1371 bytes
-rw-r--r--tests/auto/declarative/qsgimage/tst_qsgimage.cpp73
3 files changed, 33 insertions, 42 deletions
diff --git a/tests/auto/declarative/qsgimage/data/mirror.qml b/tests/auto/declarative/qsgimage/data/mirror.qml
index 101a3a28ce..98fddf083e 100644
--- a/tests/auto/declarative/qsgimage/data/mirror.qml
+++ b/tests/auto/declarative/qsgimage/data/mirror.qml
@@ -6,6 +6,6 @@ Rectangle {
Image {
objectName: "image"
anchors.fill: parent
- source: "heart200.png"
+ source: "pattern.png"
}
}
diff --git a/tests/auto/declarative/qsgimage/data/pattern.png b/tests/auto/declarative/qsgimage/data/pattern.png
new file mode 100644
index 0000000000..d3d5e1e007
--- /dev/null
+++ b/tests/auto/declarative/qsgimage/data/pattern.png
Binary files differ
diff --git a/tests/auto/declarative/qsgimage/tst_qsgimage.cpp b/tests/auto/declarative/qsgimage/tst_qsgimage.cpp
index 3f5f6a1a97..63c58eb286 100644
--- a/tests/auto/declarative/qsgimage/tst_qsgimage.cpp
+++ b/tests/auto/declarative/qsgimage/tst_qsgimage.cpp
@@ -80,7 +80,6 @@ private slots:
void preserveAspectRatio();
void smooth();
void mirror();
- void mirror_data();
void svg();
void geometry();
void geometry_data();
@@ -278,40 +277,47 @@ void tst_qsgimage::smooth()
void tst_qsgimage::mirror()
{
- QFETCH(int, fillMode);
+ QMap<QSGImage::FillMode, QImage> screenshots;
+ QList<QSGImage::FillMode> fillModes;
+ fillModes << QSGImage::Stretch << QSGImage::PreserveAspectFit << QSGImage::PreserveAspectCrop
+ << QSGImage::Tile << QSGImage::TileVertically << QSGImage::TileHorizontally;
qreal width = 300;
qreal height = 250;
- QSGView *canvas = new QSGView;
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mirror.qml"));
+ foreach (QSGImage::FillMode fillMode, fillModes) {
+ QSGView *canvas = new QSGView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mirror.qml"));
- QSGImage *obj = canvas->rootObject()->findChild<QSGImage*>("image");
- QVERIFY(obj != 0);
-
- obj->setFillMode((QSGImage::FillMode)fillMode);
- obj->setProperty("mirror", true);
+ QSGImage *obj = canvas->rootObject()->findChild<QSGImage*>("image");
+ QVERIFY(obj != 0);
- canvas->show();
+ obj->setFillMode(fillMode);
+ obj->setProperty("mirror", true);
+ canvas->show();
- QPixmap screenshot = canvas->renderPixmap();
+ QImage screenshot = canvas->grabFrameBuffer();
+ screenshots[fillMode] = screenshot;
+ delete canvas;
+ }
- QPixmap srcPixmap;
- QVERIFY(srcPixmap.load(SRCDIR "/data/heart200.png"));
+ foreach (QSGImage::FillMode fillMode, fillModes) {
+ QPixmap srcPixmap;
+ QVERIFY(srcPixmap.load(SRCDIR "/data/pattern.png"));
- QPixmap expected(width, height);
- expected.fill();
- QPainter p_e(&expected);
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- p_e.setTransform(transform);
+ QPixmap expected(width, height);
+ expected.fill();
+ QPainter p_e(&expected);
+ QTransform transform;
+ transform.translate(width, 0).scale(-1, 1.0);
+ p_e.setTransform(transform);
- switch (fillMode) {
+ switch (fillMode) {
case QSGImage::Stretch:
p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
break;
case QSGImage::PreserveAspectFit:
- p_e.drawPixmap(QRect(25, 0, width / (width/height), height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
+ p_e.drawPixmap(QRect(25, 0, height, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
break;
case QSGImage::PreserveAspectCrop:
{
@@ -334,24 +340,11 @@ void tst_qsgimage::mirror()
p_e.setTransform(transform);
p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
break;
- }
-
- QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved", SkipSingle);
- QCOMPARE(screenshot, expected);
-
- delete canvas;
-}
+ }
-void tst_qsgimage::mirror_data()
-{
- QTest::addColumn<int>("fillMode");
-
- QTest::newRow("Stretch") << int(QSGImage::Stretch);
- QTest::newRow("PreserveAspectFit") << int(QSGImage::PreserveAspectFit);
- QTest::newRow("PreserveAspectCrop") << int(QSGImage::PreserveAspectCrop);
- QTest::newRow("Tile") << int(QSGImage::Tile);
- QTest::newRow("TileVertically") << int(QSGImage::TileVertically);
- QTest::newRow("TileHorizontally") << int(QSGImage::TileHorizontally);
+ QImage img = expected.toImage();
+ QCOMPARE(screenshots[fillMode], img);
+ }
}
void tst_qsgimage::svg()
@@ -473,11 +466,9 @@ void tst_qsgimage::tiling_QTBUG_6716()
QSGImage *tiling = findItem<QSGImage>(canvas->rootObject(), "tiling");
QVERIFY(tiling != 0);
- QPixmap pm = canvas->renderPixmap();
- QImage img = pm.toImage();
+ QImage img = canvas->grabFrameBuffer();
for (int x = 0; x < tiling->width(); ++x) {
for (int y = 0; y < tiling->height(); ++y) {
- QEXPECT_FAIL("", "QTBUG-19351", Abort);
QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0));
}
}