summaryrefslogtreecommitdiff
path: root/tests/auto/quick/qquickborderimage
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-25 17:40:39 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-25 17:41:02 +0200
commit7302bc550aa75600c7cdcf5c3d34404e0a09cf67 (patch)
tree08fe995117e6ec6728514cd39501ba495f6ff725 /tests/auto/quick/qquickborderimage
parent6a45294b50726bc2426d81023df68435ebc59f77 (diff)
parent79d56651edc05133ebae13bb93733373b10380f9 (diff)
downloadqtdeclarative-7302bc550aa75600c7cdcf5c3d34404e0a09cf67.tar.gz
Merge remote-tracking branch 'origin/5.4.2' into 5.4
Change-Id: Ie0987bcaeae5ee06e01f06ac27f0d161272720b0
Diffstat (limited to 'tests/auto/quick/qquickborderimage')
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors-round-remote.sci2
-rw-r--r--tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp54
2 files changed, 29 insertions, 27 deletions
diff --git a/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci b/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci
index c673bed598..ce28333dfa 100644
--- a/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci
+++ b/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci
@@ -4,4 +4,4 @@ border.right:30
border.bottom:40
horizontalTileRule:Round
verticalTileRule:Repeat
-source:http://127.0.0.1:14446/colors.png
+source:{{ServerBaseUrl}}/colors.png
diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
index ed01dad272..aabc6cf7ed 100644
--- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
+++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
@@ -50,9 +50,6 @@
#include "../../shared/testhttpserver.h"
#include "../../shared/util.h"
-#define SERVER_PORT 14446
-#define SERVER_ADDR "http://127.0.0.1:14446"
-
Q_DECLARE_METATYPE(QQuickImageBase::Status)
class tst_qquickborderimage : public QQmlDataTest
@@ -124,9 +121,9 @@ void tst_qquickborderimage::imageSource_data()
QTest::newRow("local") << testFileUrl("colors.png").toString() << false << "";
QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << false
<< "<Unknown File>:2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString();
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
- << "<Unknown File>:2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
+ QTest::newRow("remote") << "/colors.png" << true << "";
+ QTest::newRow("remote not found") << "/no-such-file.png" << true
+ << "<Unknown File>:2:1: QML BorderImage: Error downloading {{ServerBaseUrl}}/no-such-file.png - server replied: Not found";
}
void tst_qquickborderimage::imageSource()
@@ -137,8 +134,10 @@ void tst_qquickborderimage::imageSource()
TestHTTPServer server;
if (remote) {
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory());
+ source = server.urlString(source);
+ error.replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString());
}
if (!error.isEmpty())
@@ -280,13 +279,14 @@ void tst_qquickborderimage::sciSource()
{
QFETCH(QString, source);
QFETCH(bool, valid);
-
- bool remote = source.startsWith("http");
+ QFETCH(bool, remote);
TestHTTPServer server;
if (remote) {
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory());
+ source = server.urlString(source);
+ server.registerFileNameForContentSubstitution(QUrl(source).path());
}
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
@@ -321,14 +321,15 @@ void tst_qquickborderimage::sciSource_data()
{
QTest::addColumn<QString>("source");
QTest::addColumn<bool>("valid");
+ QTest::addColumn<bool>("remote");
- QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true;
- QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true;
- QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false;
- QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
- QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true;
- QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
+ QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true << /*remote*/false;
+ QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true << /*remote*/false;
+ QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false << /*remote*/false;
+ QTest::newRow("remote") << "/colors-round.sci" << true << /*remote*/true;
+ QTest::newRow("remote filename quoted") << "/colors-round-quotes.sci" << true << /*remote*/true;
+ QTest::newRow("remote image") << "/colors-round-remote.sci" << true << /*remote*/true;
+ QTest::newRow("remote not found") << "/no-such-file.sci" << false << /*remote*/true;
}
void tst_qquickborderimage::invalidSciFile()
@@ -414,7 +415,7 @@ void tst_qquickborderimage::statusChanges_data()
QTest::newRow("nofile") << "" << 0 << false << QQuickImageBase::Null;
QTest::newRow("nonexistent") << testFileUrl("thisfiledoesnotexist.png").toString() << 1 << false << QQuickImageBase::Error;
QTest::newRow("noprotocol") << QString("thisfiledoesnotexisteither.png") << 2 << false << QQuickImageBase::Error;
- QTest::newRow("remote") << "http://localhost:14446/colors.png" << 2 << true << QQuickImageBase::Ready;
+ QTest::newRow("remote") << "/colors.png" << 2 << true << QQuickImageBase::Ready;
}
void tst_qquickborderimage::statusChanges()
@@ -426,8 +427,9 @@ void tst_qquickborderimage::statusChanges()
TestHTTPServer server;
if (remote) {
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory());
+ source = server.urlString(source);
}
QString componentStr = "import QtQuick 2.0\nBorderImage { width: 300; height: 300 }";
@@ -450,7 +452,7 @@ void tst_qquickborderimage::statusChanges()
void tst_qquickborderimage::sourceSizeChanges()
{
TestHTTPServer server;
- QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory());
QQmlEngine engine;
@@ -490,19 +492,19 @@ void tst_qquickborderimage::sourceSizeChanges()
QTRY_COMPARE(sourceSizeSpy.count(), 3);
// Remote
- ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart200.png"));
+ ctxt->setContextProperty("srcImage", server.url("/heart200.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
QTRY_COMPARE(sourceSizeSpy.count(), 4);
- ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart200.png"));
+ ctxt->setContextProperty("srcImage", server.url("/heart200.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
QTRY_COMPARE(sourceSizeSpy.count(), 4);
- ctxt->setContextProperty("srcImage", QUrl("http://127.0.0.1:14449/heart200_copy.png"));
+ ctxt->setContextProperty("srcImage", server.url("/heart200_copy.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::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(obj->status(), QQuickBorderImage::Ready);
QTRY_COMPARE(sourceSizeSpy.count(), 5);
@@ -516,7 +518,7 @@ void tst_qquickborderimage::sourceSizeChanges()
void tst_qquickborderimage::progressAndStatusChanges()
{
TestHTTPServer server;
- QVERIFY2(server.listen(14449), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory());
QQmlEngine engine;
@@ -552,7 +554,7 @@ void tst_qquickborderimage::progressAndStatusChanges()
QTRY_COMPARE(statusSpy.count(), 1);
// Loading remote file
- ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/heart200.png");
+ ctxt->setContextProperty("srcImage", server.url("/heart200.png"));
QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
QTRY_VERIFY(obj->progress() == 0.0);
QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);