[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim] messagecomposer/autotests: Verify that all backends are loaded before running MessageCompos
From:       Dan_Vrátil <dvratil () redhat ! com>
Date:       2015-10-15 10:29:01
Message-ID: E1ZmfmP-0006i8-LI () scm ! kde ! org
[Download RAW message or body]

Git commit 91c4ab58cc399bdcdc9fc74bbaab2fbea7414d07 by Dan Vrátil.
Committed on 15/10/2015 at 10:28.
Pushed by dvratil into branch 'master'.

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.

M  +14   -2    messagecomposer/autotests/setupenv.cpp
M  +1    -0    messagecomposer/autotests/setupenv.h

http://commits.kde.org/kdepim/91c4ab58cc399bdcdc9fc74bbaab2fbea7414d07

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();
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic