aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2011-05-13 13:35:49 +1000
committerYann Bodson <yann.bodson@nokia.com>2011-05-13 13:35:49 +1000
commit4890cbe42867d5ca22c57b2e4ab201cdd37435f8 (patch)
tree13b5618da24cce7254b6dbedc62241b3c42c8358 /tests
parente1aecce5ef238ca7fb1676fe0583594bd21a62dc (diff)
Fix QSGBorderImage autotest.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qsgborderimage/data/mirror.qml8
-rw-r--r--tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp69
2 files changed, 19 insertions, 58 deletions
diff --git a/tests/auto/declarative/qsgborderimage/data/mirror.qml b/tests/auto/declarative/qsgborderimage/data/mirror.qml
new file mode 100644
index 0000000000..13244d6cc4
--- /dev/null
+++ b/tests/auto/declarative/qsgborderimage/data/mirror.qml
@@ -0,0 +1,8 @@
+import QtQuick 1.0
+
+BorderImage {
+ source: "heart200.png"
+ smooth: true
+ width: 300; height: 300
+ border { top: 50; right: 50; bottom: 50; left: 50 }
+}
diff --git a/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp b/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp
index 17b9305ac8..00141e32cc 100644
--- a/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp
+++ b/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp
@@ -52,6 +52,7 @@
#include <private/qsgimagebase_p.h>
#include <private/qsgscalegrid_p_p.h>
#include <private/qsgloader_p.h>
+#include <QtDeclarative/qsgview.h>
#include <QtDeclarative/qdeclarativecontext.h>
#include "../shared/testhttpserver.h"
@@ -86,8 +87,6 @@ private slots:
void invalidSciFile();
void pendingRemoteRequest();
void pendingRemoteRequest_data();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
private:
QDeclarativeEngine engine;
@@ -225,33 +224,26 @@ void tst_qsgborderimage::smooth()
void tst_qsgborderimage::mirror()
{
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/heart200.png\"; smooth: true; width: 300; height: 300; border { top: 50; right: 50; bottom: 50; left: 50 } }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QSGBorderImage *obj = qobject_cast<QSGBorderImage*>(component.create());
- QVERIFY(obj != 0);
+ QSGView *canvas = new QSGView(0);
+ canvas->show();
- int width = obj->property("width").toInt();
- int height = obj->property("height").toInt();
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mirror.qml"));
+ QSGBorderImage *image = qobject_cast<QSGBorderImage*>(canvas->rootObject());
+ QVERIFY(image != 0);
- QGraphicsScene scene;
- scene.addItem(qobject_cast<QSGItem *>(obj));
- QPixmap screenshot(width, height);
- screenshot.fill();
- QPainter p_screenshot(&screenshot);
- scene.render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height));
+ int width = image->property("width").toInt();
+ QPixmap screenshot = canvas->renderPixmap();
QTransform transform;
transform.translate(width, 0).scale(-1, 1.0);
QPixmap expected = screenshot.transformed(transform);
- obj->setProperty("mirror", true);
- p_screenshot.fillRect(QRect(0, 0, width, height), Qt::white);
- scene.render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height));
+ image->setProperty("mirror", true);
+ screenshot = canvas->renderPixmap();
QCOMPARE(screenshot, expected);
- delete obj;
+ delete canvas;
}
void tst_qsgborderimage::tileModes()
@@ -382,45 +374,6 @@ void tst_qsgborderimage::pendingRemoteRequest_data()
QTest::newRow("sci file") << "http://localhost/none.sci";
}
-void tst_qsgborderimage::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; BorderImage { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; BorderImage { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_qsgborderimage::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("mirror") << "mirror: true"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"BorderImage.mirror\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("cache") << "cache: true"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"BorderImage.cache\" is not available in QtQuick 1.0.\n";
-}
-
QTEST_MAIN(tst_qsgborderimage)
#include "tst_qsgborderimage.moc"