aboutsummaryrefslogtreecommitdiffstats
path: root/lang/qt/tests/t-import.cpp
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2023-01-04 10:36:09 +0000
committerIngo Klöcker <[email protected]>2023-01-05 13:24:31 +0000
commit398375a0ab3b819694435c2e46b759d56b3735e0 (patch)
tree4cbd0e115f222138ae494daa96dedb8e973a2673 /lang/qt/tests/t-import.cpp
parentqt: Support deferred start of jobs (diff)
downloadgpgme-398375a0ab3b819694435c2e46b759d56b3735e0.tar.gz
gpgme-398375a0ab3b819694435c2e46b759d56b3735e0.zip
qt: Allow deferred start of import job
* lang/qt/src/importjob.h (ImportJob::startLater): New pure virtual method. * lang/qt/src/qgpgmeimportjob.cpp, lang/qt/src/qgpgmeimportjob.h (QGpgMEImportJob::startLater): New method. * lang/qt/tests/t-import.cpp (ImportTest::testDeferredStart): New. -- This makes it possible to prepare an import job for a deferred start. GnuPG-bug-id: 6323
Diffstat (limited to 'lang/qt/tests/t-import.cpp')
-rw-r--r--lang/qt/tests/t-import.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/lang/qt/tests/t-import.cpp b/lang/qt/tests/t-import.cpp
index 33e242f0..ad226ba5 100644
--- a/lang/qt/tests/t-import.cpp
+++ b/lang/qt/tests/t-import.cpp
@@ -162,6 +162,43 @@ private Q_SLOTS:
QVERIFY(key.origin() == Key::OriginWKD);
// the origin URL is currently not available in GpgME
}
+
+ void testDeferredStart()
+ {
+ // pub ed25519 2023-01-05 [SC]
+ // 4D1367FE9AF6334D8A55BA635A817A94C7B37E5D
+ static const char keyFpr[] = "4D1367FE9AF6334D8A55BA635A817A94C7B37E5D";
+ static const char keyData[] =
+ "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
+ "\n"
+ "mDMEY7bNSxYJKwYBBAHaRw8BAQdAazIWyd/xEMeObDSUnh2+AXQuo0oM+TDBG49z\n"
+ "KHvTAYG0GmltcG9ydERlZmVycmVkQGV4YW1wbGUubmV0iJMEExYKADsWIQRNE2f+\n"
+ "mvYzTYpVumNagXqUx7N+XQUCY7bNSwIbAwULCQgHAgIiAgYVCgkICwIEFgIDAQIe\n"
+ "BwIXgAAKCRBagXqUx7N+XasrAP4qPzLzPd6tWDZvP29ZYPTSrjrTb0U5MOJeIPKX\n"
+ "73jZswEAwWRvgH+GmhTOigw0UVtinAFvUEFVyvcW/GR19mw5XA0=\n"
+ "=JnpA\n"
+ "-----END PGP PUBLIC KEY BLOCK-----\n";
+
+ auto *job = openpgp()->importJob();
+ job->startLater(QByteArray{keyData});
+ connect(job, &ImportJob::result, this,
+ [this](ImportResult result, QString, Error)
+ {
+ QVERIFY(!result.error());
+ QVERIFY(!result.imports().empty());
+ QVERIFY(result.numImported());
+ Q_EMIT asyncDone();
+ });
+ job->startNow();
+ QSignalSpy spy (this, SIGNAL(asyncDone()));
+ QVERIFY(spy.wait());
+
+ auto ctx = Context::createForProtocol(GpgME::OpenPGP);
+ GpgME::Error err;
+ const auto key = ctx->key(keyFpr, err, false);
+ QVERIFY(!key.isNull());
+ }
};
QTEST_MAIN(ImportTest)