diff options
author | Felix Geyer <debfx@fobos.de> | 2012-05-10 15:59:54 +0400 |
---|---|---|
committer | Felix Geyer <debfx@fobos.de> | 2012-05-10 15:59:54 +0400 |
commit | 5a08e4619cf980396553a9417f515374336a8ed1 (patch) | |
tree | 4c7574691ed3ea4746928209a7826ad06b930f3f /tests/TestEntryModel.cpp | |
parent | 8204f2007aa7092994405b75f31c6efcd65c3f04 (diff) |
Add icon model tests.
Diffstat (limited to 'tests/TestEntryModel.cpp')
-rw-r--r-- | tests/TestEntryModel.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/TestEntryModel.cpp b/tests/TestEntryModel.cpp index f9ebf1155..e04b0445d 100644 --- a/tests/TestEntryModel.cpp +++ b/tests/TestEntryModel.cpp @@ -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) |