From 5a08e4619cf980396553a9417f515374336a8ed1 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Thu, 10 May 2012 13:59:54 +0200 Subject: [PATCH] Add icon model tests. --- tests/TestEntryModel.cpp | 34 ++++++++++++++++++++++++++++++++++ tests/TestEntryModel.h | 2 ++ 2 files changed, 36 insertions(+) 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"); + 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 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) diff --git a/tests/TestEntryModel.h b/tests/TestEntryModel.h index 908cbea2c..5173b9177 100644 --- a/tests/TestEntryModel.h +++ b/tests/TestEntryModel.h @@ -29,6 +29,8 @@ private Q_SLOTS: void test(); void testAttachmentsModel(); void testAttributesModel(); + void testDefaultIconModel(); + void testCustomIconModel(); }; #endif // KEEPASSX_TESTENTRYMODEL_H