summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Vrátil <[email protected]>2015-10-15 11:20:13 +0200
committerDan Vrátil <[email protected]>2015-10-15 12:28:25 +0200
commit91c4ab58cc399bdcdc9fc74bbaab2fbea7414d07 (patch)
tree82a8846a5a1d3e68bbc8b76589f265ffdc2f164f
parentf186e367200a763f05135bcd02a01492f72d99f8 (diff)
Verify that all backends are loaded before running MessageComposer crypto tests
The crypto test is crashing on CI due to smime() returning a null pointer. Looking into Kleo the only reasons seems to be that the support is missing in Kleo or GpgMe, but we don't know exactly what's wrong. This adds a check to setupEnv() to verify all backends and protocols are initialized correctly or print the reasons why not.
-rw-r--r--messagecomposer/autotests/setupenv.cpp16
-rw-r--r--messagecomposer/autotests/setupenv.h1
2 files changed, 15 insertions, 2 deletions
diff --git a/messagecomposer/autotests/setupenv.cpp b/messagecomposer/autotests/setupenv.cpp
index 1a9eba4..ccb91c9 100644
--- a/messagecomposer/autotests/setupenv.cpp
+++ b/messagecomposer/autotests/setupenv.cpp
@@ -26,11 +26,21 @@
#include <QFile>
#include <QDir>
+#include <QTest>
void MessageComposer::Test::setupEnv()
{
setenv("LC_ALL", "C", 1);
setenv("KDEHOME", QFile::encodeName(QDir::homePath() + QString::fromLatin1("/.kde-unit-test")), 1);
+
+ QStringList reasons;
+ Kleo::CryptoBackendFactory::instance()->scanForBackends(&reasons);
+ if (!reasons.isEmpty()) {
+ Q_FOREACH (const QString &reason, reasons) {
+ qWarning() << reason;
+ }
+ }
+ QVERIFY(reasons.isEmpty());
}
std::vector< GpgME::Key, std::allocator< GpgME::Key > > MessageComposer::Test::getKeys(bool smime)
@@ -38,10 +48,12 @@ std::vector< GpgME::Key, std::allocator< GpgME::Key > > MessageComposer::Test::g
Kleo::KeyListJob *job = 0;
if (smime) {
- const Kleo::CryptoBackend::Protocol *const backend = Kleo::CryptoBackendFactory::instance()->protocol("smime");
+ const Kleo::CryptoBackend::Protocol *const backend = Kleo::CryptoBackendFactory::instance()->smime();
+ Q_ASSERT(backend);
job = backend->keyListJob(false);
} else {
- const Kleo::CryptoBackend::Protocol *const backend = Kleo::CryptoBackendFactory::instance()->protocol("openpgp");
+ const Kleo::CryptoBackend::Protocol *const backend = Kleo::CryptoBackendFactory::instance()->openpgp();
+ Q_ASSERT(backend);
job = backend->keyListJob(false);
}
Q_ASSERT(job);
diff --git a/messagecomposer/autotests/setupenv.h b/messagecomposer/autotests/setupenv.h
index 763d096..6ba9a6e 100644
--- a/messagecomposer/autotests/setupenv.h
+++ b/messagecomposer/autotests/setupenv.h
@@ -34,6 +34,7 @@ namespace Test
* setup a environment variables for tests:
* * set LC_ALL to C
* * set KDEHOME
+* * verify that Kleo has correctly loaded all backends
*/
void setupEnv();