Qt: Fix memleaks in tests

* lang/qt/tests/t-keylist.cpp(cleanupTestCase): Ensure that
posted events are handled for autodeletion.
(testSingleKeylistSync): delete job.
* lang/qt/tests/t-ownertrust.cpp(cleanupTestCase): Ditto
* lang/qt/tests/t-ownertrust.cpp(testChangeOwnerTrust): Delete
keylistjobs.
* lang/qt/tests/t-keylocate.cpp(cleanupTestCase): Ditto
This commit is contained in:
Andre Heinecke 2016-07-11 16:47:30 +02:00
parent b1f42e8f25
commit bfa8ac7e02
3 changed files with 20 additions and 0 deletions

View File

@ -55,6 +55,7 @@ private Q_SLOTS:
std::vector<GpgME::Key> keys; std::vector<GpgME::Key> keys;
GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"), GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
false, keys); false, keys);
delete job;
Q_ASSERT (!result.error()); Q_ASSERT (!result.error());
Q_ASSERT (keys.size() == 1); Q_ASSERT (keys.size() == 1);
const QString kId = QLatin1String(keys.front().keyID()); const QString kId = QLatin1String(keys.front().keyID());
@ -104,6 +105,11 @@ private Q_SLOTS:
const QString gpgHome = qgetenv("GNUPGHOME"); const QString gpgHome = qgetenv("GNUPGHOME");
QVERIFY2(!gpgHome.isEmpty(), "GNUPGHOME environment variable is not set."); QVERIFY2(!gpgHome.isEmpty(), "GNUPGHOME environment variable is not set.");
} }
void cleanupTestCase()
{
QCoreApplication::sendPostedEvents();
}
}; };
QTEST_MAIN(KeyListTest) QTEST_MAIN(KeyListTest)

View File

@ -120,6 +120,11 @@ private Q_SLOTS:
const QString gpgHome = qgetenv("GNUPGHOME"); const QString gpgHome = qgetenv("GNUPGHOME");
QVERIFY2(!gpgHome.isEmpty(), "GNUPGHOME environment variable is not set."); QVERIFY2(!gpgHome.isEmpty(), "GNUPGHOME environment variable is not set.");
} }
void cleanupTestCase()
{
QCoreApplication::sendPostedEvents();
}
private: private:
QString mTestpattern; QString mTestpattern;
}; };

View File

@ -55,6 +55,7 @@ private Q_SLOTS:
std::vector<GpgME::Key> keys; std::vector<GpgME::Key> keys;
GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"), GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
false, keys); false, keys);
delete job;
Q_ASSERT (!result.error()); Q_ASSERT (!result.error());
Q_ASSERT (keys.size() == 1); Q_ASSERT (keys.size() == 1);
Key key = keys.front(); Key key = keys.front();
@ -76,6 +77,7 @@ private Q_SLOTS:
job = openpgp()->keyListJob(false, true, true); job = openpgp()->keyListJob(false, true, true);
result = job->exec(QStringList() << QStringLiteral("alfa@example.net"), result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
false, keys); false, keys);
delete job;
key = keys.front(); key = keys.front();
Q_ASSERT (key.ownerTrust() == Key::Ultimate); Q_ASSERT (key.ownerTrust() == Key::Ultimate);
@ -91,6 +93,8 @@ private Q_SLOTS:
job = openpgp()->keyListJob(false, true, true); job = openpgp()->keyListJob(false, true, true);
result = job->exec(QStringList() << QStringLiteral("alfa@example.net"), result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
false, keys); false, keys);
delete job;
key = keys.front(); key = keys.front();
Q_ASSERT (key.ownerTrust() == Key::Unknown); Q_ASSERT (key.ownerTrust() == Key::Unknown);
} }
@ -100,6 +104,11 @@ private Q_SLOTS:
const QString gpgHome = qgetenv("GNUPGHOME"); const QString gpgHome = qgetenv("GNUPGHOME");
QVERIFY2(!gpgHome.isEmpty(), "GNUPGHOME environment variable is not set."); QVERIFY2(!gpgHome.isEmpty(), "GNUPGHOME environment variable is not set.");
} }
void cleanupTestCase()
{
QCoreApplication::sendPostedEvents();
}
}; };
QTEST_MAIN(ChangeOwnerTrustTest) QTEST_MAIN(ChangeOwnerTrustTest)