Convert tst_qabstractnetwork auto-test

to make it work with our new docker-based test server.

Change-Id: I76345a2d3d768b8a571f2c85e69f6a21e9a96d7e
Reviewed-by: Ryan Chu <ryan.chu@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Timur Pocheptsov 2019-02-01 13:37:33 +01:00
parent 8c73ddd8e3
commit e3f16e7a42
11 changed files with 85 additions and 1 deletions

View File

@ -5,3 +5,5 @@ SOURCES += tst_qabstractnetworkcache.cpp
TESTDATA += tests/* TESTDATA += tests/*
QT_TEST_SERVER_LIST = apache2
include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri)

View File

@ -39,7 +39,7 @@
#include <algorithm> #include <algorithm>
#define TESTFILE QLatin1String("http://") + QtNetworkSettings::serverName() + QLatin1String("/qtest/cgi-bin/") #define TESTFILE QLatin1String("http://") + QtNetworkSettings::httpServerName() + QLatin1String("/qtest/cgi-bin/")
class tst_QAbstractNetworkCache : public QObject class tst_QAbstractNetworkCache : public QObject
{ {
@ -127,8 +127,13 @@ Q_DECLARE_METATYPE(QNetworkRequest::CacheLoadControl)
void tst_QAbstractNetworkCache::initTestCase() void tst_QAbstractNetworkCache::initTestCase()
{ {
#if defined(QT_TEST_SERVER)
QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80));
#else
if (!QtNetworkSettings::verifyTestNetworkSettings()) if (!QtNetworkSettings::verifyTestNetworkSettings())
QSKIP("No network test server available"); QSKIP("No network test server available");
#endif
#ifndef QT_NO_BEARERMANAGEMENT #ifndef QT_NO_BEARERMANAGEMENT
netConfMan = new QNetworkConfigurationManager(this); netConfMan = new QNetworkConfigurationManager(this);
networkConfiguration = netConfMan->defaultConfiguration(); networkConfiguration = netConfMan->defaultConfiguration();

View File

@ -0,0 +1,7 @@
#!/bin/bash
# cache control takes precedence over expires
echo "Cache-Control: max-age=-1"
echo "Expires: Mon, 30 Oct 2028 14:19:41 GMT"
echo "Content-type: text/html";
echo ""
echo "Hello World!"

View File

@ -0,0 +1,13 @@
#!/bin/bash
if [ ! -z ${HTTP_IF_MODIFIED_SINCE} ] ; then
echo "Status: 304"
echo ""
exit;
fi
cc=`echo "${QUERY_STRING}" | sed -e s/%20/\ /g`
echo "Cache-Control: $cc"
echo "Last-Modified: Sat, 31 Oct 1981 06:00:00 GMT"
echo "Content-type: text/html";
echo ""
echo "Hello World!"

View File

@ -0,0 +1,9 @@
#!/bin/bash
cc=`echo "${QUERY_STRING}" | sed -e s/%20/\ /g`
echo "Status: 200"
echo "Cache-Control: $cc"
echo "Last-Modified: Sat, 31 Oct 1981 06:00:00 GMT"
echo "Content-type: text/html";
echo "X-Script: $0"
echo ""
echo "Hello World!"

View File

@ -0,0 +1,5 @@
#!/bin/bash
echo "ETag: foo"
echo "Content-type: text/html";
echo ""
echo "Hello World!"

View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ ! -z ${HTTP_IF_NONE_MATCH} ] ; then
echo "Status: 304"
echo ""
exit;
fi
echo "ETag: foo"
echo "Content-type: text/html";
echo ""
echo "Hello World!"

View File

@ -0,0 +1,5 @@
#!/bin/bash
echo "Expires: Sat, 31 Oct 1981 6:00:00 GMT"
echo "Content-type: text/html";
echo ""
echo "Hello World!"

View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ ${HTTP_IF_MODIFIED_SINCE} == "Mon, 30 Oct 2028 14:19:41 GMT" ] ; then
echo "Status: 304"
echo ""
exit;
fi
echo "Expires: Mon, 30 Oct 2028 14:19:41 GMT"
echo "Content-type: text/html";
echo ""
echo "Hello World!"

View File

@ -0,0 +1,5 @@
#!/bin/bash
echo "Last-Modified: Sat, 31 Oct 1981 6:00:00 GMT"
echo "Content-type: text/html";
echo ""
echo "Hello World!"

View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ ${HTTP_IF_MODIFIED_SINCE} == "Sat, 31 Oct 1981 06:00:00 GMT" ] ; then
echo "Status: 304"
echo ""
exit;
fi
echo "Last-Modified: Sat, 31 Oct 1981 06:00:00 GMT"
echo "Content-type: text/html";
echo ""
echo "Hello World!"