LCOV - code coverage report
Current view: top level - lang/qt/tests - t-ownertrust.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 42 43 97.7 %
Date: 2018-11-15 08:49:49 Functions: 9 13 69.2 %

          Line data    Source code
       1             : /* t-ownertrust.cpp
       2             : 
       3             :     This file is part of qgpgme, the Qt API binding for gpgme
       4             :     Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
       5             :     Software engineering by Intevation GmbH
       6             : 
       7             :     QGpgME is free software; you can redistribute it and/or
       8             :     modify it under the terms of the GNU General Public License as
       9             :     published by the Free Software Foundation; either version 2 of the
      10             :     License, or (at your option) any later version.
      11             : 
      12             :     QGpgME is distributed in the hope that it will be useful,
      13             :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :     General Public License for more details.
      16             : 
      17             :     You should have received a copy of the GNU General Public License
      18             :     along with this program; if not, write to the Free Software
      19             :     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
      20             : 
      21             :     In addition, as a special exception, the copyright holders give
      22             :     permission to link the code of this program with any edition of
      23             :     the Qt library by Trolltech AS, Norway (or with modified versions
      24             :     of Qt that use the same license as Qt), and distribute linked
      25             :     combinations including the two.  You must obey the GNU General
      26             :     Public License in all respects for all of the code used other than
      27             :     Qt.  If you modify this file, you may extend this exception to
      28             :     your version of the file, but you are not obligated to do so.  If
      29             :     you do not wish to do so, delete this exception statement from
      30             :     your version.
      31             : */
      32             : 
      33             : #ifdef HAVE_CONFIG_H
      34             :  #include "config.h"
      35             : #endif
      36             : 
      37             : #include <QDebug>
      38             : #include <QTest>
      39             : #include <QSignalSpy>
      40             : #include "keylistjob.h"
      41             : #include "protocol.h"
      42             : #include "keylistresult.h"
      43             : #include "changeownertrustjob.h"
      44             : 
      45             : #include "t-support.h"
      46             : 
      47             : using namespace QGpgME;
      48             : using namespace GpgME;
      49             : 
      50           2 : class ChangeOwnerTrustTest: public QGpgMETest
      51             : {
      52             :     Q_OBJECT
      53             : 
      54             : Q_SIGNALS:
      55             :     void asyncDone();
      56             : 
      57             : private Q_SLOTS:
      58             : 
      59           1 :     void testChangeOwnerTrust()
      60             :     {
      61           1 :         KeyListJob *job = openpgp()->keyListJob(false, true, true);
      62           2 :         std::vector<GpgME::Key> keys;
      63           3 :         GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
      64           3 :                                                 false, keys);
      65           1 :         delete job;
      66           1 :         QVERIFY (!result.error());
      67           1 :         QVERIFY (keys.size() == 1);
      68           2 :         Key key = keys.front();
      69           1 :         QVERIFY (key.ownerTrust() == Key::Unknown);
      70             : 
      71           1 :         ChangeOwnerTrustJob *job2 = openpgp()->changeOwnerTrustJob();
      72           1 :         connect(job2, &ChangeOwnerTrustJob::result, this, [this](Error e)
      73           1 :         {
      74           1 :             if (e) {
      75           0 :                 qDebug() <<  "Error in result: " << e.asString();
      76             :             }
      77           1 :             QVERIFY(!e);
      78           1 :             Q_EMIT asyncDone();
      79           1 :         });
      80           1 :         job2->start(key, Key::Ultimate);
      81           2 :         QSignalSpy spy (this, SIGNAL(asyncDone()));
      82           1 :         QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
      83             : 
      84           1 :         job = openpgp()->keyListJob(false, true, true);
      85           3 :         result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
      86           2 :                            false, keys);
      87           1 :         delete job;
      88           1 :         key = keys.front();
      89           1 :         QVERIFY (key.ownerTrust() == Key::Ultimate);
      90             : 
      91           1 :         ChangeOwnerTrustJob *job3 = openpgp()->changeOwnerTrustJob();
      92           1 :         connect(job3, &ChangeOwnerTrustJob::result, this, [this](Error e)
      93           1 :         {
      94           1 :             QVERIFY(!e);
      95           1 :             Q_EMIT asyncDone();
      96           1 :         });
      97           1 :         job3->start(key, Key::Unknown);
      98           1 :         QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
      99             : 
     100           1 :         job = openpgp()->keyListJob(false, true, true);
     101           3 :         result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
     102           2 :                            false, keys);
     103           1 :         delete job;
     104             : 
     105           1 :         key = keys.front();
     106           1 :         QVERIFY (key.ownerTrust() == Key::Unknown);
     107             :     }
     108             : };
     109             : 
     110           1 : QTEST_MAIN(ChangeOwnerTrustTest)
     111             : 
     112             : #include "t-ownertrust.moc"

Generated by: LCOV version 1.13