diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-01-20 00:18:20 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-01-20 00:18:20 (GMT) |
commit | 810074e299f7b2826fbfb8b224082f455eab94e5 (patch) | |
tree | ff854d80ca0fa689e9c21fed77fc8565f739d0b6 /tests/auto/declarative/shared/testhttpserver.cpp | |
parent | a731aa9f32aa8f031832cae323cc76a5308d1af4 (diff) | |
download | Qt-810074e299f7b2826fbfb8b224082f455eab94e5.zip Qt-810074e299f7b2826fbfb8b224082f455eab94e5.tar.gz Qt-810074e299f7b2826fbfb8b224082f455eab94e5.tar.bz2 |
Add support for aliases in test http server.
Makes it possible to request many files with unique names, but serve
a single file.
Diffstat (limited to 'tests/auto/declarative/shared/testhttpserver.cpp')
-rw-r--r-- | tests/auto/declarative/shared/testhttpserver.cpp | 16 |
1 files changed, 15 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)) { |