qt: Add test for resetting config value
authorAndre Heinecke <aheinecke@intevation.de>
Wed, 4 Apr 2018 09:21:53 +0000 (11:21 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Wed, 4 Apr 2018 09:21:53 +0000 (11:21 +0200)
* lang/qt/tests/t-config.cpp (CryptoConfigTest::testDefault): New.

--
There is a bug around here somewhere. This test does not show
it :-(

lang/qt/tests/t-config.cpp

index e04a6bb..afbb4d1 100644 (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();