qt: Add test for resetting config value

* lang/qt/tests/t-config.cpp (CryptoConfigTest::testDefault): New.

--
There is a bug around here somewhere. This test does not show
it :-(
This commit is contained in:
Andre Heinecke 2018-04-04 11:21:53 +02:00
parent fed024eff1
commit 5eb261d602
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C

View File

@ -39,6 +39,8 @@
#include "t-support.h"
#include "protocol.h"
#include "cryptoconfig.h"
#include "engineinfo.h"
#include <unistd.h>
using namespace QGpgME;
@ -51,7 +53,7 @@ private Q_SLOTS:
void testKeyserver()
{
// Repeatedly set a config value and clear it
// this war broken at some point so it gets a
// this was broken at some point so it gets a
// unit test.
for (int i = 0; i < 10; i++) {
auto conf = cryptoConfig();
@ -78,6 +80,36 @@ private Q_SLOTS:
}
}
void testDefault()
{
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.2.0") {
// We are using compliance here and other options might also
// be unsupported in older versions.
return;
}
// First set compliance to de-vs
auto conf = cryptoConfig();
QVERIFY(conf);
auto entry = conf->entry(QStringLiteral("gpg"),
QStringLiteral("Configuration"),
QStringLiteral("compliance"));
QVERIFY(entry);
entry->setStringValue("de-vs");
conf->sync(true);
conf->clear();
entry = conf->entry(QStringLiteral("gpg"),
QStringLiteral("Configuration"),
QStringLiteral("compliance"));
QCOMPARE(entry->stringValue(), QStringLiteral("de-vs"));
entry->resetToDefault();
conf->sync(true);
conf->clear();
entry = conf->entry(QStringLiteral("gpg"),
QStringLiteral("Configuration"),
QStringLiteral("compliance"));
QCOMPARE(entry->stringValue(), QStringLiteral("gnupg"));
}
void initTestCase()
{
QGpgMETest::initTestCase();