[pim/libkleo/gpg4win/gpd-5.2] src/utils: Add "hidden" function to enable usage of compliance for tests
Ingo Klöcker <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 0967c62793cdeeba8a517b3d41627d67f09c3256 by Ingo Klöcker, on behalf of Ingo Klöcker.
Committed on 30/07/2026 at 09:37.
Pushed by kloecker into branch 'gpg4win/gpd-5.2'.
Add "hidden" function to enable usage of compliance for tests
...and add "for tests only" marker to compliance text if enabled for
tests.
GnuPG-bug-id: 7786
(cherry picked from commit 5cb93f4c72cd0c24635aea9dcc730f7abfddeb16)
M +20 -5 src/utils/compliance.cpp
https://invent.kde.org/pim/libkleo/-/commit/0967c62793cdeeba8a517b3d41627d67f09c3256
diff --git a/src/utils/compliance.cpp b/src/utils/compliance.cpp
index 38ab001c..f21983e5 100644
--- a/src/utils/compliance.cpp
+++ b/src/utils/compliance.cpp
@@ -30,6 +30,17 @@
#include <gpgme++/key.h>
using namespace Kleo;
+using namespace Qt::StringLiterals;
+
+Q_GLOBAL_STATIC(bool, useComplianceForTests)
+
+namespace Kleo::Tests::DeVSCompliance
+{
+KLEO_EXPORT void forceUsageOfCompliance(bool active)
+{
+ *useComplianceForTests() = active;
+}
+}
// May include algorithms that are not available, i.e. you must match the list
// against the list of available algorithms.
@@ -52,7 +63,7 @@ bool Kleo::DeVSCompliance::isActive()
#if LIBKLEO_FEATURE_DEVS_COMPLIANCE
return getCryptoConfigStringValue("gpg", "compliance") == QLatin1StringView{"de-vs"};
#else
- return false;
+ return useComplianceForTests() && (getCryptoConfigStringValue("gpg", "compliance") == QLatin1StringView{"de-vs"});
#endif
}
@@ -222,8 +233,12 @@ QString Kleo::DeVSCompliance::name(bool compliant)
if (!isActive()) {
return {};
}
- if (compliant && isBetaCompliance()) {
- return i18nc("@info append beta-marker to compliance", "%1 (beta)", complianceName(compliant));
- }
- return complianceName(compliant);
+ const QString result = (compliant && isBetaCompliance()) //
+ ? i18nc("@info append beta-marker to compliance", "%1 (beta)", complianceName(compliant))
+ : complianceName(compliant);
+#if LIBKLEO_FEATURE_DEVS_COMPLIANCE
+ return result;
+#else
+ return result + " (for tests only)"_L1;
+#endif
}