aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickimage
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-27 09:52:51 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-27 14:40:00 +0200
commite2447f9f5fbe6c8c070ce454bb48c5e45b8c35b3 (patch)
tree5ea8ffde57b47a44577ca79b90daafab52eedd1b /tests/auto/quick/qquickimage
parent8018c4b6e7743c576a3548f6e73e588f19f632a9 (diff)
parent7302bc550aa75600c7cdcf5c3d34404e0a09cf67 (diff)
Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts: .qmake.conf tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp Change-Id: I715b8a78b74cbe0dcaf599367fd6e08af4858e11
Diffstat (limited to 'tests/auto/quick/qquickimage')
-rw-r--r--tests/auto/quick/qquickimage/data/qtbug_22125.qml18
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp59
2 files changed, 39 insertions, 38 deletions
diff --git a/tests/auto/quick/qquickimage/data/qtbug_22125.qml b/tests/auto/quick/qquickimage/data/qtbug_22125.qml
index 9b68c0a125..30c0b1d7fb 100644
--- a/tests/auto/quick/qquickimage/data/qtbug_22125.qml
+++ b/tests/auto/quick/qquickimage/data/qtbug_22125.qml
@@ -8,7 +8,7 @@ Item {
GridView {
anchors.fill: parent
delegate: Image {
- source: imagePath;
+ source: serverBaseUrl + imagePath;
asynchronous: true
smooth: true
width: 200
@@ -16,28 +16,28 @@ Item {
}
model: ListModel {
ListElement {
- imagePath: "http://127.0.0.1:14451/big256.png"
+ imagePath: "/big256.png"
}
ListElement {
- imagePath: "http://127.0.0.1:14451/big256.png"
+ imagePath: "/big256.png"
}
ListElement {
- imagePath: "http://127.0.0.1:14451/big256.png"
+ imagePath: "/big256.png"
}
ListElement {
- imagePath: "http://127.0.0.1:14451/colors.png"
+ imagePath: "/colors.png"
}
ListElement {
- imagePath: "http://127.0.0.1:14451/colors1.png"
+ imagePath: "/colors1.png"
}
ListElement {
- imagePath: "http://127.0.0.1:14451/big.jpeg"
+ imagePath: "/big.jpeg"
}
ListElement {
- imagePath: "http://127.0.0.1:14451/heart.png"
+ imagePath: "/heart.png"
}
ListElement {
- imagePath: "http://127.0.0.1:14451/green.png"
+ imagePath: "/green.png"
}
}
}
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
index 69c39b41d2..ce8b52222d 100644
--- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp
+++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
@@ -55,9 +55,6 @@
#include "../../shared/testhttpserver.h"
#include "../shared/visualtestutil.h"
-#define SERVER_PORT 14451
-#define SERVER_ADDR "http://127.0.0.1:14451"
-
using namespace QQuickVisualTestUtil;
@@ -150,14 +147,14 @@ void tst_qquickimage::imageSource_data()
<< false << true << "<Unknown File>:2:1: QML Image: Cannot open: " + testFileUrl("no-such-file.png").toString();
QTest::newRow("local async not found") << testFileUrl("no-such-file-1.png").toString() << 0.0 << 0.0 << false
<< true << true << "<Unknown File>:2:1: QML Image: Cannot open: " + testFileUrl("no-such-file-1.png").toString();
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << "";
- QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << "";
+ QTest::newRow("remote") << "/colors.png" << 120.0 << 120.0 << true << false << true << "";
+ QTest::newRow("remote redirected") << "/oldcolors.png" << 120.0 << 120.0 << true << false << false << "";
if (QImageReader::supportedImageFormats().contains("svg"))
- QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << false << "";
+ QTest::newRow("remote svg") << "/heart.svg" << 550.0 << 500.0 << true << false << false << "";
if (QImageReader::supportedImageFormats().contains("svgz"))
- QTest::newRow("remote svgz") << SERVER_ADDR "/heart.svgz" << 550.0 << 500.0 << true << false << false << "";
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true
- << false << true << "<Unknown File>:2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
+ QTest::newRow("remote svgz") << "/heart.svgz" << 550.0 << 500.0 << true << false << false << "";
+ QTest::newRow("remote not found") << "/no-such-file.png" << 0.0 << 0.0 << true
+ << false << true << "<Unknown File>:2:1: QML Image: Error downloading {{ServerBaseUrl}}/no-such-file.png - server replied: Not found";
}
@@ -173,9 +170,11 @@ void tst_qquickimage::imageSource()
TestHTTPServer server;
if (remote) {
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory());
- server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
+ server.addRedirect("oldcolors.png", server.urlString("/colors.png"));
+ source = server.urlString(source);
+ error.replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString());
}
if (!error.isEmpty())
@@ -523,9 +522,9 @@ void tst_qquickimage::noLoading()
qRegisterMetaType<QQuickImageBase::Status>();
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory());
- server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
+ server.addRedirect("oldcolors.png", server.urlString("/colors.png"));
QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; cache: true }";
QQmlContext *ctxt = engine.rootContext();
@@ -549,7 +548,7 @@ void tst_qquickimage::noLoading()
QTRY_COMPARE(statusSpy.count(), 1);
// Loading remote file
- ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
+ ctxt->setContextProperty("srcImage", server.url("/rect.png"));
QTRY_VERIFY(obj->status() == QQuickImage::Loading);
QTRY_VERIFY(obj->progress() == 0.0);
QTRY_VERIFY(obj->status() == QQuickImage::Ready);
@@ -560,7 +559,7 @@ void tst_qquickimage::noLoading()
// Loading remote file again - should not go through 'Loading' state.
ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
- ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
+ ctxt->setContextProperty("srcImage", server.url("/rect.png"));
QTRY_VERIFY(obj->status() == QQuickImage::Ready);
QTRY_VERIFY(obj->progress() == 1.0);
QTRY_COMPARE(sourceSpy.count(), 4);
@@ -666,9 +665,13 @@ void tst_qquickimage::nullPixmapPaint()
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ TestHTTPServer server;
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
+ server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
+
QQuickImage *image = qobject_cast<QQuickImage*>(window->rootObject());
QTRY_VERIFY(image != 0);
- image->setSource(SERVER_ADDR + QString("/no-such-file.png"));
+ image->setSource(server.url("/no-such-file.png"));
QQmlTestMessageHandler messageHandler;
// used to print "QTransform::translate with NaN called"
@@ -680,11 +683,13 @@ void tst_qquickimage::nullPixmapPaint()
void tst_qquickimage::imageCrash_QTBUG_22125()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
{
- QQuickView view(testFileUrl("qtbug_22125.qml"));
+ QQuickView view;
+ view.rootContext()->setContextProperty(QStringLiteral("serverBaseUrl"), server.baseUrl());
+ view.setSource(testFileUrl("qtbug_22125.qml"));
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
qApp->processEvents();
@@ -749,7 +754,7 @@ void tst_qquickimage::sourceSize()
void tst_qquickimage::sourceSizeChanges()
{
TestHTTPServer server;
- QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory());
QQmlEngine engine;
@@ -789,19 +794,19 @@ void tst_qquickimage::sourceSizeChanges()
QTRY_COMPARE(sourceSizeSpy.count(), 3);
// Remote
- ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart.png"));
+ ctxt->setContextProperty("srcImage", server.url("/heart.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
QTRY_COMPARE(sourceSizeSpy.count(), 4);
- ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart.png"));
+ ctxt->setContextProperty("srcImage", server.url("/heart.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
QTRY_COMPARE(sourceSizeSpy.count(), 4);
- ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart_copy.png"));
+ ctxt->setContextProperty("srcImage", server.url("/heart_copy.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
QTRY_COMPARE(sourceSizeSpy.count(), 4);
- ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/colors.png"));
+ ctxt->setContextProperty("srcImage", server.url("/colors.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
QTRY_COMPARE(sourceSizeSpy.count(), 5);
@@ -815,7 +820,7 @@ void tst_qquickimage::sourceSizeChanges()
void tst_qquickimage::progressAndStatusChanges()
{
TestHTTPServer server;
- QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory());
QQmlEngine engine;
@@ -851,7 +856,7 @@ void tst_qquickimage::progressAndStatusChanges()
QTRY_COMPARE(statusSpy.count(), 1);
// Loading remote file
- ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/heart.png");
+ ctxt->setContextProperty("srcImage", server.url("/heart.png"));
QTRY_VERIFY(obj->status() == QQuickImage::Loading);
QTRY_VERIFY(obj->progress() == 0.0);
QTRY_VERIFY(obj->status() == QQuickImage::Ready);
@@ -922,10 +927,6 @@ void tst_qquickimage::correctStatus()
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(""));