summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/access
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2020-05-06 18:30:43 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2020-08-14 13:17:11 +0200
commitd40f88e8d23f9d5fdb08ff9a394d9697a0d86fc8 (patch)
tree73384e08f6d362bfc7f1da9f5ce2ff0b28641c4e /tests/auto/network/access
parent94b7a4f9b8d0746dae54b0a1870f119e8b17830d (diff)
QDecompressHelper: Introduce zstd support
Also take this opportunity to reshuffle the content-encodings in the intended ordering since the ordering is used to signify priority. Task-number: QTBUG-83269 Change-Id: I022eecf1ba03b54dbd9c98a9d63d05fb05fd2124 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/network/access')
-rw-r--r--tests/auto/network/access/http2/tst_http2.cpp5
-rw-r--r--tests/auto/network/access/qdecompresshelper/CMakeLists.txt1
-rw-r--r--tests/auto/network/access/qdecompresshelper/qdecompresshelper.pro1
-rw-r--r--tests/auto/network/access/qdecompresshelper/tst_qdecompresshelper.cpp21
-rw-r--r--tests/auto/network/access/qdecompresshelper/zstandard.rcc.cpp116
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp8
6 files changed, 152 insertions, 0 deletions
diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp
index bc685e5ca9..0282942225 100644
--- a/tests/auto/network/access/http2/tst_http2.cpp
+++ b/tests/auto/network/access/http2/tst_http2.cpp
@@ -801,6 +801,11 @@ void tst_Http2::contentEncoding_data()
"hello world");
#endif
+#if QT_CONFIG(zstd)
+ contentEncodingData.emplace_back(
+ "zstd", QByteArray::fromBase64("KLUv/QRYWQAAaGVsbG8gd29ybGRoaR6y"), "hello world");
+#endif
+
// Loop through and add the data...
for (const auto &data : contentEncodingData) {
const char *name = data.contentEncoding.data();
diff --git a/tests/auto/network/access/qdecompresshelper/CMakeLists.txt b/tests/auto/network/access/qdecompresshelper/CMakeLists.txt
index 5038f36b94..3b2f1b5e6f 100644
--- a/tests/auto/network/access/qdecompresshelper/CMakeLists.txt
+++ b/tests/auto/network/access/qdecompresshelper/CMakeLists.txt
@@ -9,6 +9,7 @@ qt_add_test(tst_qdecompresshelper
gzip.rcc.cpp
inflate.rcc.cpp
tst_qdecompresshelper.cpp
+ zstandard.rcc.cpp
DEFINES
SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} # special case
PUBLIC_LIBRARIES
diff --git a/tests/auto/network/access/qdecompresshelper/qdecompresshelper.pro b/tests/auto/network/access/qdecompresshelper/qdecompresshelper.pro
index d7bb6bcd62..254f04a707 100644
--- a/tests/auto/network/access/qdecompresshelper/qdecompresshelper.pro
+++ b/tests/auto/network/access/qdecompresshelper/qdecompresshelper.pro
@@ -7,5 +7,6 @@ SOURCES += \
tst_qdecompresshelper.cpp \
gzip.rcc.cpp \
inflate.rcc.cpp \
+ zstandard.rcc.cpp \
DEFINES += SRC_DIR="$$PWD"
diff --git a/tests/auto/network/access/qdecompresshelper/tst_qdecompresshelper.cpp b/tests/auto/network/access/qdecompresshelper/tst_qdecompresshelper.cpp
index 2641c65497..7a3aa37a47 100644
--- a/tests/auto/network/access/qdecompresshelper/tst_qdecompresshelper.cpp
+++ b/tests/auto/network/access/qdecompresshelper/tst_qdecompresshelper.cpp
@@ -73,9 +73,15 @@ void tst_QDecompressHelper::initTestCase()
{
Q_INIT_RESOURCE(gzip);
Q_INIT_RESOURCE(inflate);
+#if QT_CONFIG(zstd)
+ Q_INIT_RESOURCE(zstandard);
+#endif
}
void tst_QDecompressHelper::cleanupTestCase()
{
+#if QT_CONFIG(zstd)
+ Q_CLEANUP_RESOURCE(zstandard);
+#endif
Q_CLEANUP_RESOURCE(inflate);
Q_CLEANUP_RESOURCE(gzip);
}
@@ -98,6 +104,11 @@ void tst_QDecompressHelper::encodingSupported()
++expected;
#endif
+#if QT_CONFIG(zstd)
+ QVERIFY(QDecompressHelper::isSupportedEncoding("zstd"));
+ QVERIFY(accepted.contains("zstd"));
+ ++expected;
+#endif
QCOMPARE(expected, accepted.size());
}
@@ -129,6 +140,12 @@ void tst_QDecompressHelper::sharedDecompress_data()
<< QByteArray("br") << QByteArray::fromBase64("DwWAaGVsbG8gd29ybGQD")
<< QByteArray("hello world");
#endif
+
+#if QT_CONFIG(zstd)
+ QTest::newRow("zstandard-hello-world")
+ << QByteArray("zstd") << QByteArray::fromBase64("KLUv/QRYWQAAaGVsbG8gd29ybGRoaR6y")
+ << QByteArray("hello world");
+#endif
}
void tst_QDecompressHelper::decompress_data()
@@ -340,6 +357,10 @@ void tst_QDecompressHelper::decompressBigData_data()
#if QT_CONFIG(brotli)
QTest::newRow("brotli-4G") << QByteArray("br") << (srcDir + "/4G.br") << fourGiB;
#endif
+
+#if QT_CONFIG(zstd)
+ QTest::newRow("zstandard-4G") << QByteArray("zstd") << (":/4G.zst") << fourGiB;
+#endif
}
void tst_QDecompressHelper::decompressBigData()
diff --git a/tests/auto/network/access/qdecompresshelper/zstandard.rcc.cpp b/tests/auto/network/access/qdecompresshelper/zstandard.rcc.cpp
new file mode 100644
index 0000000000..c8a435192f
--- /dev/null
+++ b/tests/auto/network/access/qdecompresshelper/zstandard.rcc.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+** Resource object code
+**
+** Created by: The Resource Compiler for Qt version 6.0.0
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+static const unsigned char qt_resource_data[] = {
+ // D:/projects/qt/dev/src/qtbase/tests/auto/network/access/decompresshelper/4G.zst
+ 0x0,0x0,0x1,0x75,
+ 0x0,
+ 0x2,0x3,0x93,0x78,0xda,0xed,0xd4,0x21,0xe,0x83,0x40,0x10,0x86,0xd1,0x29,0x98,
+ 0x26,0x98,0x3d,0x46,0x1d,0x1a,0x8f,0xec,0x29,0x50,0xdc,0x84,0x13,0xe1,0x2b,0x90,
+ 0x1c,0x89,0xcd,0x32,0xe9,0x25,0x2a,0xfa,0x26,0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0x40,0x6,0x0,0x19,0x0,0x64,0x0,0x90,0x1,0x40,0x6,
+ 0x0,0x19,0x0,0x64,0x0,0x90,0x1,0x40,0x6,0x0,0x19,0x0,0x64,0x0,0x90,0x1,
+ 0x40,0x6,0x0,0x19,0x0,0x64,0x0,0x90,0x1,0x40,0x6,0x0,0x19,0x0,0x64,0x0,
+ 0x90,0x1,0x40,0x6,0x0,0x19,0x0,0x64,0x0,0x90,0x1,0x40,0x6,0x0,0x19,0x0,
+ 0x64,0x0,0x90,0x1,0x40,0x6,0x0,0x19,0x0,0x64,0x0,0x90,0x1,0x40,0x6,0x0,
+ 0x19,0x0,0x64,0x0,0x90,0x1,0x40,0x6,0x80,0x5f,0xe8,0xd3,0xf2,0x69,0xdb,0xd,
+ 0xcd,0x15,0x90,0xe9,
+
+};
+
+static const unsigned char qt_resource_name[] = {
+ // 4G.zst
+ 0x0,0x6,
+ 0x3,0x8a,0x61,0xa4,
+ 0x0,0x34,
+ 0x0,0x47,0x0,0x2e,0x0,0x7a,0x0,0x73,0x0,0x74,
+
+};
+
+static const unsigned char qt_resource_struct[] = {
+ // :
+ 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
+0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
+ // :/4G.zst
+ 0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
+0x0,0x0,0x1,0x72,0x1c,0x8d,0x7,0xac,
+
+};
+
+#ifdef QT_NAMESPACE
+# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
+# define QT_RCC_MANGLE_NAMESPACE0(x) x
+# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
+# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
+# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
+ QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
+#else
+# define QT_RCC_PREPEND_NAMESPACE(name) name
+# define QT_RCC_MANGLE_NAMESPACE(name) name
+#endif
+
+#ifdef QT_NAMESPACE
+namespace QT_NAMESPACE {
+#endif
+
+bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
+bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
+
+#if defined(__ELF__) || defined(__APPLE__)
+static inline unsigned char qResourceFeatureZlib()
+{
+ extern const unsigned char qt_resourceFeatureZlib;
+ return qt_resourceFeatureZlib;
+}
+#else
+unsigned char qResourceFeatureZlib();
+#endif
+
+#ifdef QT_NAMESPACE
+}
+#endif
+
+int QT_RCC_MANGLE_NAMESPACE(qInitResources_zstandard)();
+int QT_RCC_MANGLE_NAMESPACE(qInitResources_zstandard)()
+{
+ int version = 3;
+ QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
+ (version, qt_resource_struct, qt_resource_name, qt_resource_data);
+ return 1;
+}
+
+int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_zstandard)();
+int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_zstandard)()
+{
+ int version = 3;
+ version += QT_RCC_PREPEND_NAMESPACE(qResourceFeatureZlib());
+ QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
+ (version, qt_resource_struct, qt_resource_name, qt_resource_data);
+ return 1;
+}
+
+namespace {
+ struct initializer {
+ initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources_zstandard)(); }
+ ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources_zstandard)(); }
+ } dummy;
+}
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 6bec0c8ee1..e4dafb58d0 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -9270,6 +9270,14 @@ void tst_QNetworkReply::contentEncoding_data()
<< QByteArray("br") << QByteArray::fromBase64("DwWAaGVsbG8gd29ybGQD")
<< QByteArray("hello world");
#endif
+
+#if defined(QT_BUILD_INTERNAL) && QT_CONFIG(zstd)
+ QTest::newRow("zstandard-hello-world")
+ << QByteArray("zstd") << QByteArray::fromBase64("KLUv/QRYWQAAaGVsbG8gd29ybGRoaR6y")
+ << QByteArray("hello world");
+#else
+ qDebug("Note: ZStandard testdata is only available for developer builds.");
+#endif
}
void tst_QNetworkReply::contentEncoding()