[git] GPGME - branch, master, updated. gpgme-1.6.0-286-g391e554
by Andre Heinecke
cvs at cvs.gnupg.org
Fri Aug 12 16:57:38 CEST 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".
The branch, master has been updated
via 391e55411cda11446ca9de4dd0dc2b54d3e6fff5 (commit)
via df7bbf5a66576a5a320b54c8f6ad52bc84f0e833 (commit)
from fe1e8e71aa18b4ac6471292b2894b8859f42f7c8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 391e55411cda11446ca9de4dd0dc2b54d3e6fff5
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Aug 12 16:55:51 2016 +0200
Qt: Add test for progress signal of encryptjob
* lang/qt/tests/t-encrypt.cpp (testProgress): New.
--
This tests that a ByteArray IODevice now gives proper progress
signals.
diff --git a/lang/qt/tests/t-encrypt.cpp b/lang/qt/tests/t-encrypt.cpp
index c6fcaa2..708c205 100644
--- a/lang/qt/tests/t-encrypt.cpp
+++ b/lang/qt/tests/t-encrypt.cpp
@@ -31,6 +31,8 @@
#include <QDebug>
#include <QTest>
#include <QTemporaryDir>
+#include <QSignalSpy>
+#include <QBuffer>
#include "keylistjob.h"
#include "encryptjob.h"
#include "qgpgmeencryptjob.h"
@@ -39,8 +41,11 @@
#include "qgpgmedecryptjob.h"
#include "qgpgmebackend.h"
#include "keylistresult.h"
+#include "engineinfo.h"
#include "t-support.h"
+#define PROGRESS_TEST_SIZE 1 * 1024 * 1024
+
using namespace QGpgME;
using namespace GpgME;
@@ -48,6 +53,9 @@ class EncryptionTest : public QGpgMETest
{
Q_OBJECT
+Q_SIGNALS:
+ void asyncDone();
+
private Q_SLOTS:
void testSimpleEncryptDecrypt()
@@ -82,6 +90,60 @@ private Q_SLOTS:
delete decJob;
}
+ void testProgress()
+ {
+ if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.15") {
+ // We can only test the progress with 2.1.15 as this started to
+ // have total progress for memory callbacks
+ return;
+ }
+ auto listjob = openpgp()->keyListJob(false, false, false);
+ std::vector<Key> keys;
+ auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa at example.net"),
+ false, keys);
+ Q_ASSERT(!keylistresult.error());
+ Q_ASSERT(keys.size() == 1);
+ delete listjob;
+
+ auto job = openpgp()->encryptJob(/*ASCII Armor */false, /* Textmode */ false);
+ Q_ASSERT(job);
+ QByteArray plainBa;
+ plainBa.fill('X', PROGRESS_TEST_SIZE);
+ QByteArray cipherText;
+
+ bool initSeen = false;
+ bool finishSeen = false;
+ connect(job, &Job::progress, this, [this, &initSeen, &finishSeen] (const QString& what, int current, int total) {
+ // We only check for progress 0 and max progress as the other progress
+ // lines depend on the system speed and are as such unreliable to test.
+ Q_ASSERT(total == PROGRESS_TEST_SIZE);
+ if (current == 0) {
+ initSeen = true;
+ }
+ if (current == total) {
+ finishSeen = true;
+ }
+ Q_ASSERT(current >= 0 && current <= total);
+ });
+ connect(job, &EncryptJob::result, this, [this, &initSeen, &finishSeen] (const GpgME::EncryptionResult &result,
+ const QByteArray &cipherText,
+ const QString,
+ const GpgME::Error) {
+ Q_ASSERT(initSeen);
+ Q_ASSERT(finishSeen);
+ Q_EMIT asyncDone();
+ });
+
+ auto inptr = std::shared_ptr<QIODevice>(new QBuffer(&plainBa));
+ inptr->open(QIODevice::ReadOnly);
+ auto outptr = std::shared_ptr<QIODevice>(new QBuffer(&cipherText));
+ outptr->open(QIODevice::WriteOnly);
+
+ job->start(keys, inptr, outptr, Context::AlwaysTrust);
+ QSignalSpy spy (this, SIGNAL(asyncDone()));
+ Q_ASSERT(spy.wait());
+ }
+
void testSymmetricEncryptDecrypt()
{
auto ctx = Context::createForProtocol(OpenPGP);
commit df7bbf5a66576a5a320b54c8f6ad52bc84f0e833
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Aug 12 16:51:13 2016 +0200
Cpp: Provide size-hint for seekable and mem data
* lang/cpp/src/data.cpp (GpgME::Data::Data): Set size-hint for
mem and DataProvider based Data.
--
This fixes the case that QGpgME did not have a total value for
progress as the size was unknown.
diff --git a/lang/cpp/src/data.cpp b/lang/cpp/src/data.cpp
index 64acb47..9527b2f 100644
--- a/lang/cpp/src/data.cpp
+++ b/lang/cpp/src/data.cpp
@@ -62,6 +62,9 @@ GpgME::Data::Data(const char *buffer, size_t size, bool copy)
{
gpgme_data_t data;
const gpgme_error_t e = gpgme_data_new_from_mem(&data, buffer, size, int(copy));
+ std::string sizestr = std::to_string(size);
+ // Ignore errors as this is optional
+ gpgme_data_set_flag(data, "size-hint", sizestr.c_str());
d.reset(new Private(e ? 0 : data));
}
@@ -125,6 +128,13 @@ GpgME::Data::Data(DataProvider *dp)
if (e) {
d->data = 0;
}
+ if (dp->isSupported(DataProvider::Seek)) {
+ off_t size = seek(0, SEEK_END);
+ seek(0, SEEK_SET);
+ std::string sizestr = std::to_string(size);
+ // Ignore errors as this is optional
+ gpgme_data_set_flag(d->data, "size-hint", sizestr.c_str());
+ }
#ifndef NDEBUG
//std::cerr << "GpgME::Data(): DataProvider supports: "
// << ( d->cbs.read ? "read" : "no read" ) << ", "
-----------------------------------------------------------------------
Summary of changes:
lang/cpp/src/data.cpp | 10 ++++++++
lang/qt/tests/t-encrypt.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
hooks/post-receive
--
GnuPG Made Easy
http://git.gnupg.org
More information about the Gnupg-commits
mailing list