Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2020-05-29 17:00:07 +0300
committerJonathan White <support@dmapps.us>2020-05-29 17:00:32 +0300
commit90d537281333ddd0f6384ca832ab6ed3d3b7b158 (patch)
tree50eb5b9cda8b883ec2a3851995967e063ae481a0 /tests
parent229a756d84cf4fd45ea3fdbcf93246e11f808d8d (diff)
Replace database icons with SVG's
Original source of icons is the icon8 library (http://icons8.com/c/flat-color-icons) and Paomedia (https://github.com/paomedia/small-n-flat). All icons used are licensed MIT or CC0; annotated in COPYING. * Closes #4071 * Increase default size of database icons to 24px and entry preview panel to 48px * Add shell script to assemble the database icons * Use QIcon to seamlessly support High DPI displays and pixmap caching * Add badge support for KeeShare groups and expired entries. * Guard against use of QPixmap::fromImage without a GUI * Add SVG minify and improve `make icons` Co-authored-by: Wolfram Rösler <wolfram@roesler-ac.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/TestEntryModel.cpp2
-rw-r--r--tests/TestGroup.cpp14
-rw-r--r--tests/TestKeePass1Reader.cpp2
-rw-r--r--tests/TestKeePass2Format.cpp4
-rw-r--r--tests/TestMerge.cpp12
-rw-r--r--tests/gui/TestGuiPixmaps.cpp98
-rw-r--r--tests/gui/TestGuiPixmaps.h3
7 files changed, 35 insertions, 100 deletions
diff --git a/tests/TestEntryModel.cpp b/tests/TestEntryModel.cpp
index 26cb0dfec..5df4b9ed9 100644
--- a/tests/TestEntryModel.cpp
+++ b/tests/TestEntryModel.cpp
@@ -230,7 +230,7 @@ void TestEntryModel::testDefaultIconModel()
DefaultIconModel* model = new DefaultIconModel(this);
ModelTest* modelTest = new ModelTest(model, this);
- QCOMPARE(model->rowCount(), DatabaseIcons::IconCount);
+ QCOMPARE(model->rowCount(), databaseIcons()->count());
delete modelTest;
delete model;
diff --git a/tests/TestGroup.cpp b/tests/TestGroup.cpp
index a9acb3dcc..28a9f7ec4 100644
--- a/tests/TestGroup.cpp
+++ b/tests/TestGroup.cpp
@@ -336,12 +336,12 @@ void TestGroup::testCopyCustomIcon()
QScopedPointer<Database> dbTarget(new Database());
group->setParent(dbTarget->rootGroup());
- QVERIFY(dbTarget->metadata()->containsCustomIcon(groupIconUuid));
+ QVERIFY(dbTarget->metadata()->hasCustomIcon(groupIconUuid));
QCOMPARE(dbTarget->metadata()->customIcon(groupIconUuid), groupIcon);
QCOMPARE(group->icon(), groupIcon);
entry->setGroup(dbTarget->rootGroup());
- QVERIFY(dbTarget->metadata()->containsCustomIcon(entryIconUuid));
+ QVERIFY(dbTarget->metadata()->hasCustomIcon(entryIconUuid));
QCOMPARE(dbTarget->metadata()->customIcon(entryIconUuid), entryIcon);
QCOMPARE(entry->icon(), entryIcon);
}
@@ -462,11 +462,11 @@ void TestGroup::testCopyCustomIcons()
Metadata* metaTarget = dbTarget->metadata();
- QCOMPARE(metaTarget->customIcons().size(), 4);
- QVERIFY(metaTarget->containsCustomIcon(group1Icon));
- QVERIFY(metaTarget->containsCustomIcon(group2Icon));
- QVERIFY(metaTarget->containsCustomIcon(entry1IconOld));
- QVERIFY(metaTarget->containsCustomIcon(entry1IconNew));
+ QCOMPARE(metaTarget->customIconsOrder().size(), 4);
+ QVERIFY(metaTarget->hasCustomIcon(group1Icon));
+ QVERIFY(metaTarget->hasCustomIcon(group2Icon));
+ QVERIFY(metaTarget->hasCustomIcon(entry1IconOld));
+ QVERIFY(metaTarget->hasCustomIcon(entry1IconNew));
QCOMPARE(metaTarget->customIcon(group1Icon).pixel(0, 0), qRgb(1, 2, 3));
QCOMPARE(metaTarget->customIcon(group2Icon).pixel(0, 0), qRgb(4, 5, 6));
diff --git a/tests/TestKeePass1Reader.cpp b/tests/TestKeePass1Reader.cpp
index 30f744e28..cf0aa414e 100644
--- a/tests/TestKeePass1Reader.cpp
+++ b/tests/TestKeePass1Reader.cpp
@@ -112,7 +112,7 @@ void TestKeePass1Reader::testMasterKey()
void TestKeePass1Reader::testCustomIcons()
{
- QCOMPARE(m_db->metadata()->customIcons().size(), 1);
+ QCOMPARE(m_db->metadata()->customIconsOrder().size(), 1);
Entry* entry = m_db->rootGroup()->children().at(1)->entries().at(0);
diff --git a/tests/TestKeePass2Format.cpp b/tests/TestKeePass2Format.cpp
index df414f5c0..f58d0a885 100644
--- a/tests/TestKeePass2Format.cpp
+++ b/tests/TestKeePass2Format.cpp
@@ -110,9 +110,9 @@ void TestKeePass2Format::testXmlMetadata()
void TestKeePass2Format::testXmlCustomIcons()
{
- QCOMPARE(m_xmlDb->metadata()->customIcons().size(), 1);
+ QCOMPARE(m_xmlDb->metadata()->customIconsOrder().size(), 1);
QUuid uuid = QUuid::fromRfc4122(QByteArray::fromBase64("++vyI+daLk6omox4a6kQGA=="));
- QVERIFY(m_xmlDb->metadata()->customIcons().contains(uuid));
+ QVERIFY(m_xmlDb->metadata()->hasCustomIcon(uuid));
QImage icon = m_xmlDb->metadata()->customIcon(uuid);
QCOMPARE(icon.width(), 16);
QCOMPARE(icon.height(), 16);
diff --git a/tests/TestMerge.cpp b/tests/TestMerge.cpp
index 4f96d3e6d..7c9c3cc65 100644
--- a/tests/TestMerge.cpp
+++ b/tests/TestMerge.cpp
@@ -1117,14 +1117,14 @@ void TestMerge::testMergeCustomIcons()
dbSource->metadata()->addCustomIcon(customIconId, customIcon);
// Sanity check.
- QVERIFY(dbSource->metadata()->containsCustomIcon(customIconId));
+ QVERIFY(dbSource->metadata()->hasCustomIcon(customIconId));
m_clock->advanceSecond(1);
Merger merger(dbSource.data(), dbDestination.data());
merger.merge();
- QVERIFY(dbDestination->metadata()->containsCustomIcon(customIconId));
+ QVERIFY(dbDestination->metadata()->hasCustomIcon(customIconId));
}
/**
@@ -1143,16 +1143,16 @@ void TestMerge::testMergeDuplicateCustomIcons()
dbSource->metadata()->addCustomIcon(customIconId, customIcon);
dbDestination->metadata()->addCustomIcon(customIconId, customIcon);
// Sanity check.
- QVERIFY(dbSource->metadata()->containsCustomIcon(customIconId));
- QVERIFY(dbDestination->metadata()->containsCustomIcon(customIconId));
+ QVERIFY(dbSource->metadata()->hasCustomIcon(customIconId));
+ QVERIFY(dbDestination->metadata()->hasCustomIcon(customIconId));
m_clock->advanceSecond(1);
Merger merger(dbSource.data(), dbDestination.data());
merger.merge();
- QVERIFY(dbDestination->metadata()->containsCustomIcon(customIconId));
- QCOMPARE(dbDestination->metadata()->customIcons().count(), 1);
+ QVERIFY(dbDestination->metadata()->hasCustomIcon(customIconId));
+ QCOMPARE(dbDestination->metadata()->customIconsOrder().count(), 1);
}
void TestMerge::testMetadata()
diff --git a/tests/gui/TestGuiPixmaps.cpp b/tests/gui/TestGuiPixmaps.cpp
index c5754ba84..a6644f547 100644
--- a/tests/gui/TestGuiPixmaps.cpp
+++ b/tests/gui/TestGuiPixmaps.cpp
@@ -28,117 +28,55 @@ void TestGuiPixmaps::initTestCase()
void TestGuiPixmaps::testDatabaseIcons()
{
- QImage image;
- QPixmap pixmap;
- QPixmap pixmapCached;
-
- image = databaseIcons()->icon(0);
- pixmap = databaseIcons()->iconPixmap(0);
- compareImages(pixmap, image);
// check if the cache works correctly
- pixmapCached = databaseIcons()->iconPixmap(0);
- compareImages(pixmapCached, image);
- QCOMPARE(pixmapCached.cacheKey(), pixmap.cacheKey());
-
- pixmap = databaseIcons()->iconPixmap(1);
- image = databaseIcons()->icon(1);
- compareImages(pixmap, image);
- pixmapCached = databaseIcons()->iconPixmap(1);
- compareImages(pixmapCached, image);
+ auto pixmap = databaseIcons()->icon(0);
+ auto pixmapCached = databaseIcons()->icon(0);
QCOMPARE(pixmapCached.cacheKey(), pixmap.cacheKey());
}
void TestGuiPixmaps::testEntryIcons()
{
- Database* db = new Database();
+ QScopedPointer<Database> db(new Database());
Entry* entry = new Entry();
entry->setGroup(db->rootGroup());
- QImage icon;
- QImage image;
- QPixmap pixmap;
- QPixmap pixmapCached1;
- QPixmap pixmapCached2;
-
- icon = databaseIcons()->icon(10);
+ // Test setting standard icon
entry->setIcon(10);
- image = entry->icon();
- pixmap = entry->iconPixmap();
- QCOMPARE(image, icon);
- compareImages(pixmap, icon);
- pixmapCached1 = entry->iconPixmap();
- pixmapCached2 = databaseIcons()->iconPixmap(10);
- compareImages(pixmapCached1, icon);
- compareImages(pixmapCached2, icon);
- QCOMPARE(pixmapCached1.cacheKey(), pixmap.cacheKey());
- QCOMPARE(pixmapCached2.cacheKey(), pixmap.cacheKey());
+ auto pixmap = entry->iconPixmap();
+ QCOMPARE(pixmap.cacheKey(), databaseIcons()->icon(10).cacheKey());
+ // Test setting custom icon
QUuid iconUuid = QUuid::createUuid();
- icon = QImage(2, 1, QImage::Format_RGB32);
+ QImage icon(2, 1, QImage::Format_RGB32);
icon.setPixel(0, 0, qRgb(0, 0, 0));
icon.setPixel(1, 0, qRgb(0, 0, 50));
db->metadata()->addCustomIcon(iconUuid, icon);
- entry->setIcon(iconUuid);
- image = entry->icon();
+ entry->setIcon(iconUuid);
pixmap = entry->iconPixmap();
-
- QCOMPARE(image, icon);
- compareImages(pixmap, icon);
- pixmapCached1 = entry->iconPixmap();
- compareImages(pixmapCached1, icon);
- QCOMPARE(pixmapCached1.cacheKey(), pixmap.cacheKey());
-
- delete db;
+ QCOMPARE(pixmap.cacheKey(), db->metadata()->customIconPixmap(iconUuid).cacheKey());
}
void TestGuiPixmaps::testGroupIcons()
{
- Database* db = new Database();
+ QScopedPointer<Database> db(new Database());
Group* group = db->rootGroup();
- QImage icon;
- QImage image;
- QPixmap pixmap;
- QPixmap pixmapCached1;
- QPixmap pixmapCached2;
-
- icon = databaseIcons()->icon(10);
+ // Test setting standard icon
group->setIcon(10);
- image = group->icon();
- pixmap = group->iconPixmap();
- QCOMPARE(image, icon);
- compareImages(pixmap, icon);
- pixmapCached1 = group->iconPixmap();
- pixmapCached2 = databaseIcons()->iconPixmap(10);
- compareImages(pixmapCached1, icon);
- compareImages(pixmapCached2, icon);
- QCOMPARE(pixmapCached1.cacheKey(), pixmap.cacheKey());
- QCOMPARE(pixmapCached2.cacheKey(), pixmap.cacheKey());
+ auto pixmap = group->iconPixmap();
+ QCOMPARE(pixmap.cacheKey(), databaseIcons()->icon(10).cacheKey());
+ // Test setting custom icon
QUuid iconUuid = QUuid::createUuid();
- icon = QImage(2, 1, QImage::Format_RGB32);
+ QImage icon(2, 1, QImage::Format_RGB32);
icon.setPixel(0, 0, qRgb(0, 0, 0));
icon.setPixel(1, 0, qRgb(0, 0, 50));
db->metadata()->addCustomIcon(iconUuid, icon);
- group->setIcon(iconUuid);
- image = group->icon();
+ group->setIcon(iconUuid);
pixmap = group->iconPixmap();
-
- QCOMPARE(image, icon);
- compareImages(pixmap, icon);
- pixmapCached1 = group->iconPixmap();
- compareImages(pixmapCached1, icon);
- QCOMPARE(pixmapCached1.cacheKey(), pixmap.cacheKey());
-
- delete db;
-}
-
-void TestGuiPixmaps::compareImages(const QPixmap& pixmap, const QImage& image)
-{
- QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied),
- image.convertToFormat(QImage::Format_ARGB32_Premultiplied));
+ QCOMPARE(pixmap.cacheKey(), db->metadata()->customIconPixmap(iconUuid).cacheKey());
}
QTEST_MAIN(TestGuiPixmaps)
diff --git a/tests/gui/TestGuiPixmaps.h b/tests/gui/TestGuiPixmaps.h
index 6e649c0f7..da55643a4 100644
--- a/tests/gui/TestGuiPixmaps.h
+++ b/tests/gui/TestGuiPixmaps.h
@@ -31,9 +31,6 @@ private slots:
void testDatabaseIcons();
void testEntryIcons();
void testGroupIcons();
-
-private:
- void compareImages(const QPixmap& pixmap, const QImage& image);
};
#endif // KEEPASSX_TESTGUIPIXMAPS_H