Commit c8627460 authored by David Faure's avatar David Faure
Browse files

autotests: fix leak of FakeServerData and FakeSession

Test Plan: corresponding tests

Reviewers: dvratil

Reviewed By: dvratil

Subscribers: kde-pim

Differential Revision: https://phabricator.kde.org/D21140
parent 3cfff0ce
......@@ -76,6 +76,7 @@ class EntityTreeModelTest : public QObject
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
void testInitialFetch();
void testCollectionMove_data();
......@@ -110,7 +111,7 @@ private:
m_modelSpy = new ModelSpy{model, this};
const auto serverData = new FakeServerData(model, m_fakeSession, fakeMonitor);
const auto serverData = new FakeServerData(model, m_fakeSession, fakeMonitor, this);
serverData->setCommands(FakeJobResponse::interpret(serverData, serverContent));
// Give the model a chance to populate
......@@ -144,6 +145,11 @@ void EntityTreeModelTest::initTestCase()
qRegisterMetaType<QModelIndex>("QModelIndex");
}
void EntityTreeModelTest::cleanupTestCase()
{
delete m_fakeSession;
}
void EntityTreeModelTest::testInitialFetch()
{
const auto fakeMonitor = new FakeMonitor(this);
......@@ -152,7 +158,7 @@ void EntityTreeModelTest::testInitialFetch()
fakeMonitor->setCollectionMonitored(Collection::root());
const auto model = new EntityTreeModel(fakeMonitor, this);
const auto serverData = new FakeServerData(model, m_fakeSession, fakeMonitor);
const auto serverData = new FakeServerData(model, m_fakeSession, fakeMonitor, this);
serverData->setCommands(FakeJobResponse::interpret(serverData, serverContent1));
m_modelSpy = new ModelSpy(model, this);
......
......@@ -43,6 +43,7 @@ class TagModelTest : public QObject
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
void testInitialFetch();
......@@ -71,7 +72,7 @@ private:
m_modelSpy = new ModelSpy{model, this};
const auto serverData = new FakeServerData(model, m_fakeSession, fakeMonitor);
const auto serverData = new FakeServerData(model, m_fakeSession, fakeMonitor, this);
serverData->setCommands(FakeJobResponse::interpret(serverData, serverContent));
// Give the model a chance to populate
......@@ -104,6 +105,11 @@ void TagModelTest::initTestCase()
qRegisterMetaType<QModelIndex>("QModelIndex");
}
void TagModelTest::cleanupTestCase()
{
delete m_fakeSession;
}
void TagModelTest::testInitialFetch()
{
const auto fakeMonitor = new FakeMonitor(this);
......@@ -112,7 +118,7 @@ void TagModelTest::testInitialFetch()
fakeMonitor->setCollectionMonitored(Collection::root());
const auto model = new TagModel(fakeMonitor, this);
const auto serverData = new FakeServerData(model, m_fakeSession, fakeMonitor);
const auto serverData = new FakeServerData(model, m_fakeSession, fakeMonitor, this);
const auto initialFetchResponse = FakeJobResponse::interpret(serverData, serverContent1);
serverData->setCommands(initialFetchResponse);
......
......@@ -37,7 +37,7 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
monitor->setSession(session);
m_model = new EntityTreeModel(monitor, this);
m_serverData = new FakeServerData(m_model, session, monitor);
m_serverData = new FakeServerData(m_model, session, monitor, this);
QList<FakeAkonadiServerCommand *> initialFetchResponse = FakeJobResponse::interpret(m_serverData, QStringLiteral(
"- C (inode/directory) 'Col 1' 4"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment