From 4d913a8aa5dad1327bed5987dada89e9d7c5d292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Thu, 13 Jan 2022 12:51:38 +0100 Subject: qt: Add job to add existing subkeys to other keys * lang/qt/src/addexistingsubkeyjob.h, lang/qt/src/qgpgmeaddexistingsubkeyjob.cpp, lang/qt/src/qgpgmeaddexistingsubkeyjob.h: New. * lang/qt/src/protocol.h (class Protocol): Add pure virtual member function addExistingSubkeyJob. * lang/qt/src/protocol_p.h (Protocol::addExistingSubkeyJob): Implement. * lang/qt/src/job.cpp, lang/qt/src/Makefile.am: Update accordingly. * lang/qt/tests/Makefile.am (the_tests, moc_files, noinst_PROGRAMS): Add new test. (t_addexistingsubkey_SOURCES): New. * lang/qt/tests/t-addexistingsubkey.cpp: New. * lang/qt/tests/t-support.h (VERIFY_OR_RETURN_VALUE, COMPARE_OR_RETURN_VALUE, VERIFY_OR_OBJECT, COMPARE_OR_OBJECT, VERIFY_OR_FALSE, COMPARE_OR_FALSE): New. * lang/qt/tests/t-support.h, lang/qt/tests/t-support.cpp (class QQGpgMETest): New member function importSecretKeys. -- The new job allows adding existing subkeys to other keys as with the "addkey" edit-key command of gpg. The added subkey will have the same expiration date (+/- 1 second) as the original subkey. GnuPG-bug-id: 5770 --- lang/qt/tests/t-support.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lang/qt/tests/t-support.h') diff --git a/lang/qt/tests/t-support.h b/lang/qt/tests/t-support.h index 0d5757c8..ecafe2f4 100644 --- a/lang/qt/tests/t-support.h +++ b/lang/qt/tests/t-support.h @@ -48,6 +48,32 @@ namespace QGpgME class Job; } +/// generic variant of QVERIFY returning \a returnValue on failure +#define VERIFY_OR_RETURN_VALUE(statement, returnValue) \ +do {\ + if (!QTest::qVerify(static_cast(statement), #statement, "", __FILE__, __LINE__))\ + return returnValue;\ +} while (false) + +/// generic variant of QCOMPARE returning \a returnValue on failure +#define COMPARE_OR_RETURN_VALUE(actual, expected, returnValue) \ +do {\ + if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ + return returnValue;\ +} while (false) + +/// variant of QVERIFY returning a default constructed object on failure +#define VERIFY_OR_OBJECT(statement) VERIFY_OR_RETURN_VALUE(statement, {}) + +/// variant of QCOMPARE returning a default constructed object on failure +#define COMPARE_OR_OBJECT(actual, expected) COMPARE_OR_RETURN_VALUE(actual, expected, {}) + +/// variant of QVERIFY returning \c false on failure +#define VERIFY_OR_FALSE(statement) VERIFY_OR_RETURN_VALUE(statement, false) + +/// variant of QCOMPARE returning \c false on failure +#define COMPARE_OR_FALSE(actual, expected) COMPARE_OR_RETURN_VALUE(actual, expected, false) + namespace QTest { template <> @@ -88,6 +114,8 @@ protected: bool copyKeyrings(const QString &from, const QString& to); + bool importSecretKeys(const char *keyData, int expectedKeys = 1); + void hookUpPassphraseProvider(GpgME::Context *context); void hookUpPassphraseProvider(QGpgME::Job *job); -- cgit v1.2.3