diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-11-20 17:39:12 +0100 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-11-23 18:38:53 +0100 |
commit | 1157167a5c69e253fdeb6c8ad532c5d52e150769 (patch) | |
tree | 097b4f6089980313b5da25bed79bed9f08e12b1c /tests/auto/network/ssl/qdtls | |
parent | 1ff25785ff93d0bd3d597e3a65a261bdbfa13c3b (diff) |
QSslConfiguration - improve code coverage
By adding auto-tests that were missing/not triggering the paths found
by LCOV.
Pick-to: 5.15
Pick-to: 6.0
Change-Id: I472f59e8e7292786c80d7c8dcebde53a2982e1ec
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/network/ssl/qdtls')
-rw-r--r-- | tests/auto/network/ssl/qdtls/tst_qdtls.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/network/ssl/qdtls/tst_qdtls.cpp b/tests/auto/network/ssl/qdtls/tst_qdtls.cpp index fd51c091a8..3742645390 100644 --- a/tests/auto/network/ssl/qdtls/tst_qdtls.cpp +++ b/tests/auto/network/ssl/qdtls/tst_qdtls.cpp @@ -39,11 +39,12 @@ #include <QtNetwork/qdtls.h> #include <QtNetwork/qssl.h> -#include <QtCore/qbytearray.h> #include <QtCore/qcryptographichash.h> -#include <QtCore/qlist.h> +#include <QtCore/qscopeguard.h> +#include <QtCore/qbytearray.h> #include <QtCore/qobject.h> #include <QtCore/qstring.h> +#include <QtCore/qlist.h> #include <algorithm> @@ -311,6 +312,19 @@ void tst_QDtls::configuration() QCOMPARE(dtls.dtlsError(), QDtlsError::InvalidOperation); QCOMPARE(dtls.dtlsConfiguration(), config); } + + static bool doneAlready = false; + if (!doneAlready) { + doneAlready = true; + QSslConfiguration nullConfig; + const auto defaultDtlsConfig = QSslConfiguration::defaultDtlsConfiguration(); + const auto restoreDefault = qScopeGuard([&defaultDtlsConfig] { + QSslConfiguration::setDefaultDtlsConfiguration(defaultDtlsConfig); + }); + QSslConfiguration::setDefaultDtlsConfiguration(nullConfig); + QCOMPARE(QSslConfiguration::defaultDtlsConfiguration(), nullConfig); + QVERIFY(QSslConfiguration::defaultDtlsConfiguration() != defaultDtlsConfig); + } } void tst_QDtls::invalidConfiguration() |