diff options
-rw-r--r-- | tests/auto/declarative/shared/testhttpserver.cpp | 16 | ||||
-rw-r--r-- | tests/auto/declarative/shared/testhttpserver.h | 4 |
2 files changed, 19 insertions, 1 deletions
diff --git a/tests/auto/declarative/shared/testhttpserver.cpp b/tests/auto/declarative/shared/testhttpserver.cpp index 215f3c3..6c9d849 100644 --- a/tests/auto/declarative/shared/testhttpserver.cpp +++ b/tests/auto/declarative/shared/testhttpserver.cpp @@ -106,6 +106,15 @@ bool TestHTTPServer::serveDirectory(const QString &dir, Mode mode) return true; } +/* + Add an alias, so that if filename is requested and does not exist, + alias may be returned. +*/ +void TestHTTPServer::addAlias(const QString &filename, const QString &alias) +{ + aliases.insert(filename, alias); +} + bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &body) { m_hasFailed = false; @@ -226,7 +235,12 @@ bool TestHTTPServer::reply(QTcpSocket *socket, const QByteArray &fileName) Mode mode = dirs.at(ii).second; QString dirFile = dir + QLatin1String("/") + QLatin1String(fileName); - + + if (!QFile::exists(dirFile)) { + if (aliases.contains(fileName)) + dirFile = dir + QLatin1String("/") + aliases.value(fileName); + } + QFile file(dirFile); if (file.open(QIODevice::ReadOnly)) { diff --git a/tests/auto/declarative/shared/testhttpserver.h b/tests/auto/declarative/shared/testhttpserver.h index 62fe7b4..2a8709f 100644 --- a/tests/auto/declarative/shared/testhttpserver.h +++ b/tests/auto/declarative/shared/testhttpserver.h @@ -61,6 +61,8 @@ public: bool wait(const QUrl &expect, const QUrl &reply, const QUrl &body); bool hasFailed() const; + void addAlias(const QString &filename, const QString &aliasName); + private slots: void newConnection(); void disconnected(); @@ -80,6 +82,8 @@ private: QByteArray bodyData; bool m_hasFailed; + QHash<QString,QString> aliases; + QTcpServer server; }; |