Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tests, QContactManager: wipe contacts after each test
  • Loading branch information
mardy committed Jun 14, 2019
1 parent 73633d6 commit e41cf81
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 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

0 comments on commit e41cf81

Please sign in to comment.