Add icon model tests.

This commit is contained in:
Felix Geyer 2012-05-10 13:59:54 +02:00
parent 8204f2007a
commit 5a08e4619c
2 changed files with 36 additions and 0 deletions

View File

@ -22,15 +22,19 @@
#include "modeltest.h"
#include "tests.h"
#include "core/DatabaseIcons.h"
#include "core/Entry.h"
#include "core/Group.h"
#include "crypto/Crypto.h"
#include "gui/EntryModel.h"
#include "gui/EntryAttachmentsModel.h"
#include "gui/EntryAttributesModel.h"
#include "gui/IconModels.h"
void TestEntryModel::initTestCase()
{
qRegisterMetaType<QModelIndex>("QModelIndex");
Crypto::init();
}
void TestEntryModel::test()
@ -184,4 +188,34 @@ void TestEntryModel::testAttributesModel()
delete model;
}
void TestEntryModel::testDefaultIconModel()
{
DefaultIconModel* model = new DefaultIconModel(this);
ModelTest* modelTest = new ModelTest(model, this);
QCOMPARE(model->rowCount(), databaseIcons()->iconCount());
delete modelTest;
delete model;
}
void TestEntryModel::testCustomIconModel()
{
CustomIconModel* model = new CustomIconModel(this);
ModelTest* modelTest = new ModelTest(model, this);
QCOMPARE(model->rowCount(), 0);
QHash<Uuid, QImage> icons;
Uuid iconUuid = Uuid::random();
QImage icon;
icons.insert(iconUuid, icon);
model->setIcons(icons);
QCOMPARE(model->uuidFromIndex(model->index(0, 0)), iconUuid);
delete modelTest;
delete model;
}
KEEPASSX_QTEST_CORE_MAIN(TestEntryModel)

View File

@ -29,6 +29,8 @@ private Q_SLOTS:
void test();
void testAttachmentsModel();
void testAttributesModel();
void testDefaultIconModel();
void testCustomIconModel();
};
#endif // KEEPASSX_TESTENTRYMODEL_H