mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-02 22:54:59 -04:00
Add Group::exportToDb().
This commit is contained in:
parent
a992c76d6a
commit
98c821df05
8 changed files with 197 additions and 105 deletions
|
@ -537,4 +537,48 @@ void TestGroup::testCopyCustomIcons()
|
|||
QCOMPARE(metaTarget->customIcon(group2Icon).pixel(0, 0), qRgb(4, 5, 6));
|
||||
}
|
||||
|
||||
void TestGroup::testExportToDb()
|
||||
{
|
||||
QImage iconImage(1, 1, QImage::Format_RGB32);
|
||||
iconImage.setPixel(0, 0, qRgb(1, 2, 3));
|
||||
Uuid iconUuid = Uuid::random();
|
||||
|
||||
QImage iconUnusedImage(1, 1, QImage::Format_RGB32);
|
||||
iconUnusedImage.setPixel(0, 0, qRgb(1, 2, 3));
|
||||
Uuid iconUnusedUuid = Uuid::random();
|
||||
|
||||
Database* dbOrg = new Database();
|
||||
Group* groupOrg = new Group();
|
||||
groupOrg->setParent(dbOrg->rootGroup());
|
||||
groupOrg->setName("GTEST");
|
||||
Entry* entryOrg = new Entry();
|
||||
entryOrg->setGroup(groupOrg);
|
||||
entryOrg->setTitle("ETEST");
|
||||
dbOrg->metadata()->addCustomIcon(iconUuid, iconImage);
|
||||
dbOrg->metadata()->addCustomIcon(iconUnusedUuid, iconUnusedImage);
|
||||
entryOrg->setIcon(iconUuid);
|
||||
entryOrg->beginUpdate();
|
||||
entryOrg->setIcon(Entry::DefaultIconNumber);
|
||||
entryOrg->endUpdate();
|
||||
|
||||
Database* dbExp = groupOrg->exportToDb();
|
||||
QCOMPARE(dbExp->rootGroup()->children().size(), 1);
|
||||
Group* groupExp = dbExp->rootGroup()->children().first();
|
||||
QVERIFY(groupExp != groupOrg);
|
||||
QCOMPARE(groupExp->name(), groupOrg->name());
|
||||
QCOMPARE(groupExp->entries().size(), 1);
|
||||
|
||||
Entry* entryExp = groupExp->entries().first();
|
||||
QCOMPARE(entryExp->title(), entryOrg->title());
|
||||
QCOMPARE(dbExp->metadata()->customIcons().size(), 1);
|
||||
QVERIFY(dbExp->metadata()->containsCustomIcon(iconUuid));
|
||||
QCOMPARE(entryExp->iconNumber(), entryOrg->iconNumber());
|
||||
|
||||
QCOMPARE(entryExp->historyItems().size(), 1);
|
||||
QCOMPARE(entryExp->historyItems().first()->iconUuid(), iconUuid);
|
||||
|
||||
delete dbOrg;
|
||||
delete dbExp;
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(TestGroup)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue