mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-22 15:39:57 -05:00
Clean up objects in the tests.
This commit is contained in:
parent
5cb906c235
commit
a104e859cf
@ -45,7 +45,7 @@ void TestEntryModel::test()
|
|||||||
|
|
||||||
EntryModel* model = new EntryModel(this);
|
EntryModel* model = new EntryModel(this);
|
||||||
|
|
||||||
new ModelTest(model, this);
|
ModelTest* modelTest = new ModelTest(model, this);
|
||||||
|
|
||||||
model->setGroup(group1);
|
model->setGroup(group1);
|
||||||
|
|
||||||
@ -87,6 +87,9 @@ void TestEntryModel::test()
|
|||||||
|
|
||||||
delete group1;
|
delete group1;
|
||||||
delete group2;
|
delete group2;
|
||||||
|
|
||||||
|
delete modelTest;
|
||||||
|
delete model;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestEntryModel);
|
QTEST_MAIN(TestEntryModel);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "TestGroup.h"
|
#include "TestGroup.h"
|
||||||
|
|
||||||
|
#include <QtCore/QPointer>
|
||||||
#include <QtTest/QSignalSpy>
|
#include <QtTest/QSignalSpy>
|
||||||
#include <QtTest/QTest>
|
#include <QtTest/QTest>
|
||||||
|
|
||||||
@ -32,10 +33,11 @@ void TestGroup::testParenting()
|
|||||||
Database* db = new Database();
|
Database* db = new Database();
|
||||||
Group* tmpRoot = new Group();
|
Group* tmpRoot = new Group();
|
||||||
|
|
||||||
Group* g1 = new Group();
|
QPointer<Group> g1 = new Group();
|
||||||
Group* g2 = new Group();
|
QPointer<Group> g2 = new Group();
|
||||||
Group* g3 = new Group();
|
QPointer<Group> g3 = new Group();
|
||||||
Group* g4 = new Group();
|
QPointer<Group> g4 = new Group();
|
||||||
|
|
||||||
g1->setParent(tmpRoot);
|
g1->setParent(tmpRoot);
|
||||||
g2->setParent(tmpRoot);
|
g2->setParent(tmpRoot);
|
||||||
g3->setParent(tmpRoot);
|
g3->setParent(tmpRoot);
|
||||||
@ -74,12 +76,21 @@ void TestGroup::testParenting()
|
|||||||
g3->setIcon(Uuid::random());
|
g3->setIcon(Uuid::random());
|
||||||
g1->setIcon(2);
|
g1->setIcon(2);
|
||||||
QCOMPARE(spy.count(), 6);
|
QCOMPARE(spy.count(), 6);
|
||||||
|
|
||||||
|
delete db;
|
||||||
|
|
||||||
|
QVERIFY(g1.isNull());
|
||||||
|
QVERIFY(g2.isNull());
|
||||||
|
QVERIFY(g3.isNull());
|
||||||
|
QVERIFY(g4.isNull());
|
||||||
|
|
||||||
|
delete tmpRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestGroup::testSignals()
|
void TestGroup::testSignals()
|
||||||
{
|
{
|
||||||
Database* db = new Database();
|
Database* db = new Database();
|
||||||
Group* root = new Group();
|
QPointer<Group> root = new Group();
|
||||||
root->setParent(db);
|
root->setParent(db);
|
||||||
|
|
||||||
Group* g1 = new Group();
|
Group* g1 = new Group();
|
||||||
@ -100,16 +111,18 @@ void TestGroup::testSignals()
|
|||||||
QCOMPARE(spyRemoved.count(), 1);
|
QCOMPARE(spyRemoved.count(), 1);
|
||||||
|
|
||||||
delete db;
|
delete db;
|
||||||
|
|
||||||
|
QVERIFY(root.isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestGroup::testEntries()
|
void TestGroup::testEntries()
|
||||||
{
|
{
|
||||||
Group* group = new Group();
|
Group* group = new Group();
|
||||||
|
|
||||||
Entry* entry1 = new Entry();
|
QPointer<Entry> entry1 = new Entry();
|
||||||
entry1->setGroup(group);
|
entry1->setGroup(group);
|
||||||
|
|
||||||
Entry* entry2 = new Entry();
|
QPointer<Entry> entry2 = new Entry();
|
||||||
entry2->setGroup(group);
|
entry2->setGroup(group);
|
||||||
|
|
||||||
QCOMPARE(group->entries().size(), 2);
|
QCOMPARE(group->entries().size(), 2);
|
||||||
@ -117,6 +130,9 @@ void TestGroup::testEntries()
|
|||||||
QVERIFY(group->entries().at(1) == entry2);
|
QVERIFY(group->entries().at(1) == entry2);
|
||||||
|
|
||||||
delete group;
|
delete group;
|
||||||
|
|
||||||
|
QVERIFY(entry1.isNull());
|
||||||
|
QVERIFY(entry2.isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestGroup);
|
QTEST_MAIN(TestGroup);
|
||||||
|
@ -60,7 +60,7 @@ void TestGroupModel::test()
|
|||||||
|
|
||||||
GroupModel* model = new GroupModel(db, this);
|
GroupModel* model = new GroupModel(db, this);
|
||||||
|
|
||||||
new ModelTest(model, this);
|
ModelTest* modelTest = new ModelTest(model, this);
|
||||||
|
|
||||||
QModelIndex indexRoot = model->index(0, 0);
|
QModelIndex indexRoot = model->index(0, 0);
|
||||||
QModelIndex index1 = model->index(0, 0, indexRoot);
|
QModelIndex index1 = model->index(0, 0, indexRoot);
|
||||||
@ -95,6 +95,9 @@ void TestGroupModel::test()
|
|||||||
|
|
||||||
delete groupRoot;
|
delete groupRoot;
|
||||||
delete db;
|
delete db;
|
||||||
|
|
||||||
|
delete modelTest;
|
||||||
|
delete model;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestGroupModel);
|
QTEST_MAIN(TestGroupModel);
|
||||||
|
@ -41,6 +41,9 @@ void TestKeePass2Reader::testNonAscii()
|
|||||||
QVERIFY(db);
|
QVERIFY(db);
|
||||||
QVERIFY(!reader->error());
|
QVERIFY(!reader->error());
|
||||||
QCOMPARE(db->metadata()->name(), QString("NonAsciiTest"));
|
QCOMPARE(db->metadata()->name(), QString("NonAsciiTest"));
|
||||||
|
|
||||||
|
delete db;
|
||||||
|
delete reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestKeePass2Reader::testCompressed()
|
void TestKeePass2Reader::testCompressed()
|
||||||
@ -53,6 +56,9 @@ void TestKeePass2Reader::testCompressed()
|
|||||||
QVERIFY(db);
|
QVERIFY(db);
|
||||||
QVERIFY(!reader->error());
|
QVERIFY(!reader->error());
|
||||||
QCOMPARE(db->metadata()->name(), QString("Compressed"));
|
QCOMPARE(db->metadata()->name(), QString("Compressed"));
|
||||||
|
|
||||||
|
delete db;
|
||||||
|
delete reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestKeePass2Reader);
|
QTEST_MAIN(TestKeePass2Reader);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user