Skip to content

Commit

Permalink
Merge branch 'test_wipe_mer' into 'master'
Browse files Browse the repository at this point in the history
Tests, QContactManager: wipe contacts after each test

See merge request mer-core/qtcontacts-sqlite!25
  • Loading branch information
chriadam committed Jun 14, 2019
2 parents 0ae95a4 + 831f1da commit 7247050
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/auto/qcontactmanager/tst_qcontactmanager.cpp
Expand Up @@ -170,6 +170,7 @@ Q_OBJECT

public slots:
void initTestCase();
void cleanup();
void cleanupTestCase();
private slots:

Expand Down Expand Up @@ -339,6 +340,28 @@ void tst_QContactManager::initTestCase()
//QVERIFY(!QContactManager::availableManagers().contains("maliciousplugin"));
}

void tst_QContactManager::cleanup()
{
QMap<QString, QString> params;
params.insert("autoTest", "true");
params.insert("mergePresenceChanges", "false");

QString mgrUri = QContactManager::buildUri(QLatin1String(SQLITE_MANAGER), params);
QScopedPointer<QContactManager> cm(QContactManager::fromUri(mgrUri));
if (cm) {
QList<QContact> contacts = cm->contacts();
QList<QContactId> ids;
for (const QContact &contact: contacts) {
ids.append(retrievalId(contact));
}
if (!ids.isEmpty()) {
QSignalSpy removedSpy(cm.data(), contactsRemovedSignal);
cm->removeContacts(ids, 0);
removedSpy.wait();
}
}
}

void tst_QContactManager::cleanupTestCase()
{
managerDataHolder.reset(0);
Expand Down Expand Up @@ -4669,6 +4692,9 @@ void tst_QContactManager::constituentOfSelf()
// Verify that the new contact was not aggregated into the self contact
newContact = m->contact(retrievalId(newContact));
QVERIFY(!relatedContactIds(newContact.relatedContacts()).contains(m->selfContactId()));

// Cleanup
QVERIFY(m->removeContact(constituent.id()));
}

void tst_QContactManager::searchSensitivity()
Expand Down

0 comments on commit 7247050

Please sign in to comment.