Add TestEntryModel::testDatabaseDelete().

It tests that EntryModel in EntryList mode correctly
removes entries from the model when that database of
these entries is deleted.
This commit is contained in:
Felix Geyer 2013-03-22 21:00:06 +01:00
parent c7593a3047
commit 21a80101ba
2 changed files with 32 additions and 0 deletions

View File

@ -311,4 +311,35 @@ void TestEntryModel::testProxyModel()
delete db;
}
void TestEntryModel::testDatabaseDelete()
{
EntryModel* model = new EntryModel(this);
ModelTest* modelTest = new ModelTest(model, this);
Database* db1 = new Database();
Group* group1 = new Group();
group1->setParent(db1->rootGroup());
Entry* entry1 = new Entry();
entry1->setGroup(group1);
Database* db2 = new Database();
Entry* entry2 = new Entry();
entry2->setGroup(db2->rootGroup());
model->setEntryList(QList<Entry*>() << entry1 << entry2);
QCOMPARE(model->rowCount(), 2);
delete db1;
QCOMPARE(model->rowCount(), 1);
delete entry2;
QCOMPARE(model->rowCount(), 0);
delete db2;
delete modelTest;
delete model;
}
QTEST_GUILESS_MAIN(TestEntryModel)

View File

@ -33,6 +33,7 @@ private Q_SLOTS:
void testCustomIconModel();
void testAutoTypeAssociationsModel();
void testProxyModel();
void testDatabaseDelete();
};
#endif // KEEPASSX_TESTENTRYMODEL_H