From ea6f15ed602eeb9fa87766ba88acc78361a14b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Mon, 13 Feb 2023 10:58:31 +0100 Subject: qt: Add simple and extended progress signals replacing old signal * lang/qt/src/job.h (Job): Add signals jobProgress and rawProgress. Deprecate signal progress. * lang/qt/src/multideletejob.cpp (MultiDeleteJob::slotResult): Emit new progress signals. * lang/qt/src/qgpgmerefreshsmimekeysjob.cpp (QGpgMERefreshSMIMEKeysJob::slotStatus): Ditto. * lang/qt/src/threadedjobmixin.h (ThreadedJobMixin::showProgress): Use modern overload of QMetaObject::invokeMethod to forward the progress signal and add the value of what. Add forwarding of progress to the new signals. * lang/qt/tests/t-encrypt.cpp (EncryptionTest::testProgress): Test the new signals instead of the deprecated one. -- The new signal jobProgress omits the what value which is useless for most consumers. The new signal rawProgress makes all information provided by the backend available to consumers. The latter is not really meant to be used by users of gpgme. It will be used by the archive jobs to provide more user-friendly signals. GnuPG-bug-id: 6342 --- lang/qt/tests/t-encrypt.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lang/qt/tests/t-encrypt.cpp') diff --git a/lang/qt/tests/t-encrypt.cpp b/lang/qt/tests/t-encrypt.cpp index 6a4c68e9..35b9bbf9 100644 --- a/lang/qt/tests/t-encrypt.cpp +++ b/lang/qt/tests/t-encrypt.cpp @@ -120,7 +120,22 @@ private Q_SLOTS: bool initSeen = false; bool finishSeen = false; - connect(job, &Job::progress, this, [this, &initSeen, &finishSeen] (const QString&, int current, int total) { + connect(job, &Job::jobProgress, this, [&initSeen, &finishSeen] (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. + QVERIFY(total == PROGRESS_TEST_SIZE); + if (current == 0) { + initSeen = true; + } + if (current == total) { + finishSeen = true; + } + QVERIFY(current >= 0 && current <= total); + }); + connect(job, &Job::rawProgress, this, [&initSeen, &finishSeen] (const QString &what, int type, int current, int total) { + // `what` is something like "-&12", i.e. a special fd passed to gpg; we only check that it's not empty + QVERIFY(!what.isEmpty()); + QCOMPARE(type, '?'); // 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. QVERIFY(total == PROGRESS_TEST_SIZE); -- cgit v1.2.3