aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickimage
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-05-09 16:25:58 +0200
committerGunnar Sletta <gunnar.sletta@jollamobile.com>2014-05-10 11:53:47 +0200
commit66646dd8c37adb488a79ab274b2396a649674e6d (patch)
treeb0f5ac752a52cec3de1d47692e09295197622dcd /tests/auto/quick/qquickimage
parentda15ea0f3b5805db657f13060c21efa78f10cde2 (diff)
parentd82a17b929dd88fe76258b0f801beaa1b2ee343e (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: .qmake.conf src/plugins/accessible/quick/quick.pro src/quick/items/qquickpincharea.cpp src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp src/quick/scenegraph/qsgthreadedrenderloop.cpp Manually adjusted for TestHTTPServer constructor change: tests/auto/quick/qquickimage/tst_qquickimage.cpp Change-Id: I5e58a7c08ea92d6fc5e3bce98571c54f7b2ce08f
Diffstat (limited to 'tests/auto/quick/qquickimage')
-rw-r--r--tests/auto/quick/qquickimage/data/heart-highdpi@2x.pngbin0 -> 12577 bytes
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp50
2 files changed, 49 insertions, 1 deletions
diff --git a/tests/auto/quick/qquickimage/data/heart-highdpi@2x.png b/tests/auto/quick/qquickimage/data/heart-highdpi@2x.png
new file mode 100644
index 0000000000..abe97fee4b
--- /dev/null
+++ b/tests/auto/quick/qquickimage/data/heart-highdpi@2x.png
Binary files differ
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
index b73dcdfcde..7951cb07cf 100644
--- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp
+++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
@@ -105,6 +105,7 @@ private slots:
void progressAndStatusChanges();
void sourceSizeChanges();
void correctStatus();
+ void highdpi();
private:
QQmlEngine engine;
@@ -307,6 +308,10 @@ void tst_qquickimage::mirror()
qreal height = 250;
foreach (QQuickImage::FillMode fillMode, fillModes) {
+#if defined(Q_OS_BLACKBERRY)
+ QWindow dummy; // On BlackBerry first window is always full screen,
+ dummy.showFullScreen(); // so make test window a second window.
+#endif
QQuickView *window = new QQuickView;
window->setSource(testFileUrl("mirror.qml"));
@@ -315,7 +320,7 @@ void tst_qquickimage::mirror()
obj->setFillMode(fillMode);
obj->setProperty("mirror", true);
- window->show();
+ window->showNormal();
QVERIFY(QTest::qWaitForWindowExposed(window));
QImage screenshot = window->grabWindow();
@@ -928,6 +933,49 @@ void tst_qquickimage::correctStatus()
delete obj;
}
+void tst_qquickimage::highdpi()
+{
+ TestHTTPServer server;
+ QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ server.serveDirectory(dataDirectory());
+
+ QString componentStr = "import QtQuick 2.0\nImage { source: srcImage ; }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQmlContext *ctxt = engine.rootContext();
+
+ // Testing "@2x" high-dpi image loading:
+ // The basic case is as follows. Suppose you have foo.png,
+ // which is a 64x64 png that fits in a QML layout. Now,
+ // on a high-dpi system that pixmap would not provide
+ // enough pixels. To fix this the app developer provides
+ // a 128x128 foo@2x.png, which Qt automatically loads.
+ // The image continues to be referred to as "foo.png" in
+ // the QML sources, and reports a size of 64x64.
+ //
+
+ // Load "heart-highdpi@2x.png", which is a 300x300 png. As a 2x scale image it
+ // should render and report a geometry of 150x150.
+ ctxt->setContextProperty("srcImage", testFileUrl("heart-highdpi@2x.png"));
+
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->width(), 150.0);
+ QCOMPARE(obj->height(), 150.0);
+ QCOMPARE(obj->paintedWidth(), 150.0);
+ QCOMPARE(obj->paintedHeight(), 150.0);
+
+ // Load a normal 1x image.
+ ctxt->setContextProperty("srcImage", testFileUrl("heart.png"));
+ QCOMPARE(obj->width(), 300.0);
+ QCOMPARE(obj->height(), 300.0);
+ QCOMPARE(obj->paintedWidth(), 300.0);
+ QCOMPARE(obj->paintedHeight(), 300.0);
+
+ delete obj;
+}
+
QTEST_MAIN(tst_qquickimage)
#include "tst_qquickimage.moc"