mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-23 07:59:54 -05:00
Add CustomData regression tests
This commit is contained in:
parent
0b54710734
commit
114f00e1e8
@ -47,26 +47,26 @@ void TestModified::testSignals()
|
|||||||
db->setKey(compositeKey);
|
db->setKey(compositeKey);
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
|
||||||
Group* g1 = new Group();
|
Group* group1 = new Group();
|
||||||
g1->setParent(root);
|
group1->setParent(root);
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
|
||||||
Group* g2 = new Group();
|
Group* group2 = new Group();
|
||||||
g2->setParent(root);
|
group2->setParent(root);
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
|
||||||
g2->setParent(root, 0);
|
group2->setParent(root, 0);
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
|
||||||
Entry* entry1 = new Entry();
|
Entry* entry1 = new Entry();
|
||||||
entry1->setGroup(g1);
|
entry1->setGroup(group1);
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
|
||||||
Database* db2 = new Database();
|
Database* db2 = new Database();
|
||||||
Group* root2 = db2->rootGroup();
|
Group* root2 = db2->rootGroup();
|
||||||
QSignalSpy spyModified2(db2, SIGNAL(modifiedImmediate()));
|
QSignalSpy spyModified2(db2, SIGNAL(modifiedImmediate()));
|
||||||
|
|
||||||
g1->setParent(root2);
|
group1->setParent(root2);
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
QCOMPARE(spyModified2.count(), ++spyCount2);
|
QCOMPARE(spyModified2.count(), ++spyCount2);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ void TestModified::testSignals()
|
|||||||
QCOMPARE(spyModified2.count(), ++spyCount2);
|
QCOMPARE(spyModified2.count(), ++spyCount2);
|
||||||
|
|
||||||
Entry* entry2 = new Entry();
|
Entry* entry2 = new Entry();
|
||||||
entry2->setGroup(g2);
|
entry2->setGroup(group2);
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
QCOMPARE(spyModified2.count(), spyCount2);
|
QCOMPARE(spyModified2.count(), spyCount2);
|
||||||
|
|
||||||
@ -87,15 +87,15 @@ void TestModified::testSignals()
|
|||||||
QCOMPARE(spyModified.count(), spyCount);
|
QCOMPARE(spyModified.count(), spyCount);
|
||||||
QCOMPARE(spyModified2.count(), ++spyCount2);
|
QCOMPARE(spyModified2.count(), ++spyCount2);
|
||||||
|
|
||||||
Group* g3 = new Group();
|
Group* group3 = new Group();
|
||||||
g3->setParent(root);
|
group3->setParent(root);
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
|
||||||
Group* g4 = new Group();
|
Group* group4 = new Group();
|
||||||
g4->setParent(g3);
|
group4->setParent(group3);
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
|
||||||
delete g4;
|
delete group4;
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
|
||||||
delete entry2;
|
delete entry2;
|
||||||
@ -114,8 +114,8 @@ void TestModified::testGroupSets()
|
|||||||
Database* db = new Database();
|
Database* db = new Database();
|
||||||
Group* root = db->rootGroup();
|
Group* root = db->rootGroup();
|
||||||
|
|
||||||
Group* g = new Group();
|
Group* group = new Group();
|
||||||
g->setParent(root);
|
group->setParent(root);
|
||||||
|
|
||||||
QSignalSpy spyModified(db, SIGNAL(modifiedImmediate()));
|
QSignalSpy spyModified(db, SIGNAL(modifiedImmediate()));
|
||||||
|
|
||||||
@ -145,29 +145,29 @@ void TestModified::testGroupSets()
|
|||||||
QCOMPARE(spyModified.count(), spyCount);
|
QCOMPARE(spyModified.count(), spyCount);
|
||||||
|
|
||||||
|
|
||||||
g->setUuid(Uuid::random());
|
group->setUuid(Uuid::random());
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
g->setUuid(g->uuid());
|
group->setUuid(group->uuid());
|
||||||
QCOMPARE(spyModified.count(), spyCount);
|
QCOMPARE(spyModified.count(), spyCount);
|
||||||
|
|
||||||
g->setName("test");
|
group->setName("test");
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
g->setName(g->name());
|
group->setName(group->name());
|
||||||
QCOMPARE(spyModified.count(), spyCount);
|
QCOMPARE(spyModified.count(), spyCount);
|
||||||
|
|
||||||
g->setNotes("test");
|
group->setNotes("test");
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
g->setNotes(g->notes());
|
group->setNotes(group->notes());
|
||||||
QCOMPARE(spyModified.count(), spyCount);
|
QCOMPARE(spyModified.count(), spyCount);
|
||||||
|
|
||||||
g->setIcon(1);
|
group->setIcon(1);
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
g->setIcon(g->iconNumber());
|
group->setIcon(group->iconNumber());
|
||||||
QCOMPARE(spyModified.count(), spyCount);
|
QCOMPARE(spyModified.count(), spyCount);
|
||||||
|
|
||||||
g->setIcon(Uuid::random());
|
group->setIcon(Uuid::random());
|
||||||
QCOMPARE(spyModified.count(), ++spyCount);
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
g->setIcon(g->iconUuid());
|
group->setIcon(group->iconUuid());
|
||||||
QCOMPARE(spyModified.count(), spyCount);
|
QCOMPARE(spyModified.count(), spyCount);
|
||||||
|
|
||||||
delete db;
|
delete db;
|
||||||
@ -179,10 +179,10 @@ void TestModified::testEntrySets()
|
|||||||
Database* db = new Database();
|
Database* db = new Database();
|
||||||
Group* root = db->rootGroup();
|
Group* root = db->rootGroup();
|
||||||
|
|
||||||
Group* g = new Group();
|
Group* group = new Group();
|
||||||
g->setParent(root);
|
group->setParent(root);
|
||||||
Entry* entry = new Entry();
|
Entry* entry = new Entry();
|
||||||
entry->setGroup(g);
|
entry->setGroup(group);
|
||||||
|
|
||||||
QSignalSpy spyModified(db, SIGNAL(modifiedImmediate()));
|
QSignalSpy spyModified(db, SIGNAL(modifiedImmediate()));
|
||||||
|
|
||||||
@ -298,8 +298,6 @@ void TestModified::testHistoryItems()
|
|||||||
QScopedPointer<EntryAttributes> attributes(new EntryAttributes());
|
QScopedPointer<EntryAttributes> attributes(new EntryAttributes());
|
||||||
attributes->copyCustomKeysFrom(entry->attributes());
|
attributes->copyCustomKeysFrom(entry->attributes());
|
||||||
|
|
||||||
Entry* historyEntry;
|
|
||||||
|
|
||||||
int historyItemsSize = 0;
|
int historyItemsSize = 0;
|
||||||
|
|
||||||
entry->beginUpdate();
|
entry->beginUpdate();
|
||||||
@ -315,7 +313,7 @@ void TestModified::testHistoryItems()
|
|||||||
entry->setTitle("b");
|
entry->setTitle("b");
|
||||||
entry->endUpdate();
|
entry->endUpdate();
|
||||||
QCOMPARE(entry->historyItems().size(), ++historyItemsSize);
|
QCOMPARE(entry->historyItems().size(), ++historyItemsSize);
|
||||||
historyEntry = entry->historyItems().at(historyItemsSize - 1);
|
Entry *historyEntry = entry->historyItems().at(historyItemsSize - 1);
|
||||||
QCOMPARE(historyEntry->title(), QString("a"));
|
QCOMPARE(historyEntry->title(), QString("a"));
|
||||||
QCOMPARE(historyEntry->uuid(), entry->uuid());
|
QCOMPARE(historyEntry->uuid(), entry->uuid());
|
||||||
QCOMPARE(historyEntry->tags(), entry->tags());
|
QCOMPARE(historyEntry->tags(), entry->tags());
|
||||||
@ -582,3 +580,34 @@ void TestModified::testHistoryMaxSize()
|
|||||||
QCOMPARE(entry2->autoTypeAssociations()->associationsSize(), 0);
|
QCOMPARE(entry2->autoTypeAssociations()->associationsSize(), 0);
|
||||||
QCOMPARE(entry2->historyItems().size(), 0);
|
QCOMPARE(entry2->historyItems().size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestModified::testCustomData()
|
||||||
|
{
|
||||||
|
int spyCount = 0;
|
||||||
|
Database* db = new Database();
|
||||||
|
Group* root = db->rootGroup();
|
||||||
|
|
||||||
|
Group* group = new Group();
|
||||||
|
group->setParent(root);
|
||||||
|
Entry* entry = new Entry();
|
||||||
|
entry->setGroup(group);
|
||||||
|
|
||||||
|
QSignalSpy spyModified(db, SIGNAL(modifiedImmediate()));
|
||||||
|
|
||||||
|
db->metadata()->customData()->set("Key", "Value");
|
||||||
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
db->metadata()->customData()->set("Key", "Value");
|
||||||
|
QCOMPARE(spyModified.count(), spyCount);
|
||||||
|
|
||||||
|
entry->customData()->set("Key", "Value");
|
||||||
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
entry->customData()->set("Key", "Value");
|
||||||
|
QCOMPARE(spyModified.count(), spyCount);
|
||||||
|
|
||||||
|
group->customData()->set("Key", "Value");
|
||||||
|
QCOMPARE(spyModified.count(), ++spyCount);
|
||||||
|
group->customData()->set("Key", "Value");
|
||||||
|
QCOMPARE(spyModified.count(), spyCount);
|
||||||
|
|
||||||
|
delete db;
|
||||||
|
}
|
||||||
|
@ -31,6 +31,7 @@ private slots:
|
|||||||
void testEntrySets();
|
void testEntrySets();
|
||||||
void testHistoryItems();
|
void testHistoryItems();
|
||||||
void testHistoryMaxSize();
|
void testHistoryMaxSize();
|
||||||
|
void testCustomData();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_TESTMODIFIED_H
|
#endif // KEEPASSX_TESTMODIFIED_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user