mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-22 07:29:52 -05:00
Fix test cases
* Disable quick unlock when running TestGuiBrowser * Use QString and auto pointers in TestMerge. This test was failing under Visual Studio.
This commit is contained in:
parent
48715c6bda
commit
f23b07f609
@ -119,15 +119,15 @@ void TestMerge::testResolveConflictNewer()
|
|||||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
QPointer<Group> groupSourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
auto groupSourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(groupSourceInitial != nullptr);
|
QVERIFY(groupSourceInitial != nullptr);
|
||||||
QCOMPARE(groupSourceInitial->entries().size(), 2);
|
QCOMPARE(groupSourceInitial->entries().size(), 2);
|
||||||
|
|
||||||
QPointer<Group> groupDestinationInitial = dbSource->rootGroup()->findChildByName("group1");
|
auto groupDestinationInitial = dbSource->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(groupDestinationInitial != nullptr);
|
QVERIFY(groupDestinationInitial != nullptr);
|
||||||
QCOMPARE(groupDestinationInitial->entries().size(), 2);
|
QCOMPARE(groupDestinationInitial->entries().size(), 2);
|
||||||
|
|
||||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
auto entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceInitial != nullptr);
|
QVERIFY(entrySourceInitial != nullptr);
|
||||||
QVERIFY(entrySourceInitial->group() == groupSourceInitial);
|
QVERIFY(entrySourceInitial->group() == groupSourceInitial);
|
||||||
|
|
||||||
@ -156,12 +156,12 @@ void TestMerge::testResolveConflictNewer()
|
|||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
QPointer<Group> groupDestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
auto groupDestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(groupDestinationMerged != nullptr);
|
QVERIFY(groupDestinationMerged != nullptr);
|
||||||
QCOMPARE(groupDestinationMerged->entries().size(), 2);
|
QCOMPARE(groupDestinationMerged->entries().size(), 2);
|
||||||
QCOMPARE(groupDestinationMerged->timeInfo(), groupDestinationInitialTimeInfo);
|
QCOMPARE(groupDestinationMerged->timeInfo(), groupDestinationInitialTimeInfo);
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QVERIFY(entryDestinationMerged->group() != nullptr);
|
QVERIFY(entryDestinationMerged->group() != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->password(), QString("password"));
|
QCOMPARE(entryDestinationMerged->password(), QString("password"));
|
||||||
@ -186,15 +186,15 @@ void TestMerge::testResolveConflictExisting()
|
|||||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
QPointer<Group> groupSourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
auto groupSourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(groupSourceInitial != nullptr);
|
QVERIFY(groupSourceInitial != nullptr);
|
||||||
QCOMPARE(groupSourceInitial->entries().size(), 2);
|
QCOMPARE(groupSourceInitial->entries().size(), 2);
|
||||||
|
|
||||||
QPointer<Group> groupDestinationInitial = dbDestination->rootGroup()->findChildByName("group1");
|
auto groupDestinationInitial = dbDestination->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(groupDestinationInitial != nullptr);
|
QVERIFY(groupDestinationInitial != nullptr);
|
||||||
QCOMPARE(groupSourceInitial->entries().size(), 2);
|
QCOMPARE(groupSourceInitial->entries().size(), 2);
|
||||||
|
|
||||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
auto entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceInitial != nullptr);
|
QVERIFY(entrySourceInitial != nullptr);
|
||||||
QVERIFY(entrySourceInitial->group() == groupSourceInitial);
|
QVERIFY(entrySourceInitial->group() == groupSourceInitial);
|
||||||
|
|
||||||
@ -212,10 +212,10 @@ void TestMerge::testResolveConflictExisting()
|
|||||||
const TimeInfo entrySourceUpdatedOlderTimeInfo = entrySourceInitial->timeInfo();
|
const TimeInfo entrySourceUpdatedOlderTimeInfo = entrySourceInitial->timeInfo();
|
||||||
const TimeInfo groupSourceUpdatedOlderTimeInfo = groupSourceInitial->timeInfo();
|
const TimeInfo groupSourceUpdatedOlderTimeInfo = groupSourceInitial->timeInfo();
|
||||||
|
|
||||||
QPointer<Group> groupDestinationUpdated = dbDestination->rootGroup()->findChildByName("group1");
|
auto groupDestinationUpdated = dbDestination->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(groupDestinationUpdated != nullptr);
|
QVERIFY(groupDestinationUpdated != nullptr);
|
||||||
QCOMPARE(groupDestinationUpdated->entries().size(), 2);
|
QCOMPARE(groupDestinationUpdated->entries().size(), 2);
|
||||||
QPointer<Entry> entryDestinationUpdated = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entryDestinationUpdated = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationUpdated != nullptr);
|
QVERIFY(entryDestinationUpdated != nullptr);
|
||||||
QVERIFY(entryDestinationUpdated->group() == groupDestinationUpdated);
|
QVERIFY(entryDestinationUpdated->group() == groupDestinationUpdated);
|
||||||
|
|
||||||
@ -241,12 +241,12 @@ void TestMerge::testResolveConflictExisting()
|
|||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
QPointer<Group> groupDestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
auto groupDestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(groupDestinationMerged != nullptr);
|
QVERIFY(groupDestinationMerged != nullptr);
|
||||||
QCOMPARE(groupDestinationMerged->entries().size(), 2);
|
QCOMPARE(groupDestinationMerged->entries().size(), 2);
|
||||||
QCOMPARE(groupDestinationMerged->timeInfo(), groupDestinationUpdatedNewerTimeInfo);
|
QCOMPARE(groupDestinationMerged->timeInfo(), groupDestinationUpdatedNewerTimeInfo);
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->password(), QString("password2"));
|
QCOMPARE(entryDestinationMerged->password(), QString("password2"));
|
||||||
QCOMPARE(entryDestinationMerged->timeInfo(), entryDestinationUpdatedNewerTimeInfo);
|
QCOMPARE(entryDestinationMerged->timeInfo(), entryDestinationUpdatedNewerTimeInfo);
|
||||||
@ -271,7 +271,7 @@ void TestMerge::testResolveConflictDuplicate()
|
|||||||
QCOMPARE(dbDestination->rootGroup()->children().at(0)->entries().size(), 2);
|
QCOMPARE(dbDestination->rootGroup()->children().at(0)->entries().size(), 2);
|
||||||
|
|
||||||
// make this entry newer than in original db
|
// make this entry newer than in original db
|
||||||
QPointer<Entry> updatedDestinationEntry = dbDestination->rootGroup()->children().at(0)->entries().at(0);
|
auto updatedDestinationEntry = dbDestination->rootGroup()->children().at(0)->entries().at(0);
|
||||||
const TimeInfo initialEntryTimeInfo = updatedDestinationEntry->timeInfo();
|
const TimeInfo initialEntryTimeInfo = updatedDestinationEntry->timeInfo();
|
||||||
const TimeInfo updatedEntryTimeInfo = modificationTime(initialEntryTimeInfo, 1, 0, 0);
|
const TimeInfo updatedEntryTimeInfo = modificationTime(initialEntryTimeInfo, 1, 0, 0);
|
||||||
|
|
||||||
@ -289,8 +289,8 @@ void TestMerge::testResolveConflictDuplicate()
|
|||||||
QCOMPARE(dbDestination->rootGroup()->children().at(0)->entries().size(), 3);
|
QCOMPARE(dbDestination->rootGroup()->children().at(0)->entries().size(), 3);
|
||||||
QCOMPARE(dbDestination->rootGroup()->children().at(0)->entries().at(0)->historyItems().isEmpty(), false);
|
QCOMPARE(dbDestination->rootGroup()->children().at(0)->entries().at(0)->historyItems().isEmpty(), false);
|
||||||
// the older entry was merged from the other db as last in the group
|
// the older entry was merged from the other db as last in the group
|
||||||
QPointer<Entry> newerEntry = dbDestination->rootGroup()->children().at(0)->entries().at(0);
|
auto newerEntry = dbDestination->rootGroup()->children().at(0)->entries().at(0);
|
||||||
QPointer<Entry> olderEntry = dbDestination->rootGroup()->children().at(0)->entries().at(2);
|
auto olderEntry = dbDestination->rootGroup()->children().at(0)->entries().at(2);
|
||||||
QVERIFY(newerEntry->title() == olderEntry->title());
|
QVERIFY(newerEntry->title() == olderEntry->title());
|
||||||
QVERIFY2(!newerEntry->attributes()->hasKey("merged"), "newer entry is not marked with an attribute \"merged\"");
|
QVERIFY2(!newerEntry->attributes()->hasKey("merged"), "newer entry is not marked with an attribute \"merged\"");
|
||||||
QVERIFY2(olderEntry->attributes()->hasKey("merged"), "older entry is marked with an attribute \"merged\"");
|
QVERIFY2(olderEntry->attributes()->hasKey("merged"), "older entry is marked with an attribute \"merged\"");
|
||||||
@ -304,9 +304,9 @@ void TestMerge::testResolveConflictDuplicate()
|
|||||||
|
|
||||||
void TestMerge::testResolveConflictTemplate(
|
void TestMerge::testResolveConflictTemplate(
|
||||||
int mergeMode,
|
int mergeMode,
|
||||||
std::function<void(Database*, const QMap<const char*, QDateTime>&)> verification)
|
std::function<void(Database*, const QMap<QString, QDateTime>&)> verification)
|
||||||
{
|
{
|
||||||
QMap<const char*, QDateTime> timestamps;
|
QMap<QString, QDateTime> timestamps;
|
||||||
timestamps["initialTime"] = m_clock->currentDateTimeUtc();
|
timestamps["initialTime"] = m_clock->currentDateTimeUtc();
|
||||||
QScopedPointer<Database> dbDestination(createTestDatabase());
|
QScopedPointer<Database> dbDestination(createTestDatabase());
|
||||||
|
|
||||||
@ -340,10 +340,10 @@ void TestMerge::testResolveConflictTemplate(
|
|||||||
QCOMPARE(dbSource->rootGroup()->children().at(0)->entries().at(1)->historyItems().count(), 1);
|
QCOMPARE(dbSource->rootGroup()->children().at(0)->entries().at(1)->historyItems().count(), 1);
|
||||||
|
|
||||||
// simulate some work in the dbs (manipulate the history)
|
// simulate some work in the dbs (manipulate the history)
|
||||||
QPointer<Entry> destinationEntry1 = dbDestination->rootGroup()->children().at(0)->entries().at(0);
|
auto destinationEntry1 = dbDestination->rootGroup()->children().at(0)->entries().at(0);
|
||||||
QPointer<Entry> destinationEntry2 = dbDestination->rootGroup()->children().at(0)->entries().at(1);
|
auto destinationEntry2 = dbDestination->rootGroup()->children().at(0)->entries().at(1);
|
||||||
QPointer<Entry> sourceEntry1 = dbSource->rootGroup()->children().at(0)->entries().at(0);
|
auto sourceEntry1 = dbSource->rootGroup()->children().at(0)->entries().at(0);
|
||||||
QPointer<Entry> sourceEntry2 = dbSource->rootGroup()->children().at(0)->entries().at(1);
|
auto sourceEntry2 = dbSource->rootGroup()->children().at(0)->entries().at(1);
|
||||||
|
|
||||||
timestamps["newestCommonHistoryTime"] = m_clock->advanceMinute(1);
|
timestamps["newestCommonHistoryTime"] = m_clock->advanceMinute(1);
|
||||||
|
|
||||||
@ -386,9 +386,9 @@ void TestMerge::testResolveConflictTemplate(
|
|||||||
|
|
||||||
m_clock->advanceMinute(1);
|
m_clock->advanceMinute(1);
|
||||||
|
|
||||||
QPointer<Entry> deletedEntryDestination = dbDestination->rootGroup()->findEntryByPath("deletedDestination");
|
auto deletedEntryDestination = dbDestination->rootGroup()->findEntryByPath("deletedDestination");
|
||||||
dbDestination->recycleEntry(deletedEntryDestination);
|
dbDestination->recycleEntry(deletedEntryDestination);
|
||||||
QPointer<Entry> deletedEntrySource = dbSource->rootGroup()->findEntryByPath("deletedSource");
|
auto deletedEntrySource = dbSource->rootGroup()->findEntryByPath("deletedSource");
|
||||||
dbSource->recycleEntry(deletedEntrySource);
|
dbSource->recycleEntry(deletedEntrySource);
|
||||||
|
|
||||||
m_clock->advanceMinute(1);
|
m_clock->advanceMinute(1);
|
||||||
@ -417,13 +417,13 @@ void TestMerge::testResolveConflictTemplate(
|
|||||||
Merger merger(dbSource.data(), dbDestination.data());
|
Merger merger(dbSource.data(), dbDestination.data());
|
||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
QPointer<Group> mergedRootGroup = dbDestination->rootGroup();
|
auto mergedRootGroup = dbDestination->rootGroup();
|
||||||
QCOMPARE(mergedRootGroup->entries().size(), 0);
|
QCOMPARE(mergedRootGroup->entries().size(), 0);
|
||||||
// Both databases contain their own generated recycleBin - just one is considered a real recycleBin, the other
|
// Both databases contain their own generated recycleBin - just one is considered a real recycleBin, the other
|
||||||
// exists as normal group, therefore only one entry is considered deleted
|
// exists as normal group, therefore only one entry is considered deleted
|
||||||
QCOMPARE(dbDestination->metadata()->recycleBin()->entries().size(), 1);
|
QCOMPARE(dbDestination->metadata()->recycleBin()->entries().size(), 1);
|
||||||
QPointer<Group> mergedGroup1 = mergedRootGroup->children().at(0);
|
auto mergedGroup1 = mergedRootGroup->children().at(0);
|
||||||
QPointer<Group> mergedGroup2 = mergedRootGroup->children().at(1);
|
auto mergedGroup2 = mergedRootGroup->children().at(1);
|
||||||
QVERIFY(mergedGroup1);
|
QVERIFY(mergedGroup1);
|
||||||
QVERIFY(mergedGroup2);
|
QVERIFY(mergedGroup2);
|
||||||
QCOMPARE(mergedGroup2->entries().size(), 2);
|
QCOMPARE(mergedGroup2->entries().size(), 2);
|
||||||
@ -454,7 +454,7 @@ void TestMerge::testDeletionConflictTemplate(int mergeMode,
|
|||||||
// entry indirectly deleted in target before updated in source
|
// entry indirectly deleted in target before updated in source
|
||||||
// entry indirectly deleted in target after updated in source
|
// entry indirectly deleted in target after updated in source
|
||||||
|
|
||||||
auto createGroup = [&](const char* name, Group* parent) {
|
auto createGroup = [&](QString name, Group* parent) {
|
||||||
auto group = new Group();
|
auto group = new Group();
|
||||||
group->setUuid(QUuid::createUuid());
|
group->setUuid(QUuid::createUuid());
|
||||||
group->setName(name);
|
group->setName(name);
|
||||||
@ -462,7 +462,7 @@ void TestMerge::testDeletionConflictTemplate(int mergeMode,
|
|||||||
identifiers[group->name()] = group->uuid();
|
identifiers[group->name()] = group->uuid();
|
||||||
return group;
|
return group;
|
||||||
};
|
};
|
||||||
auto createEntry = [&](const char* title, Group* parent) {
|
auto createEntry = [&](QString title, Group* parent) {
|
||||||
auto entry = new Entry();
|
auto entry = new Entry();
|
||||||
entry->setUuid(QUuid::createUuid());
|
entry->setUuid(QUuid::createUuid());
|
||||||
entry->setTitle(title);
|
entry->setTitle(title);
|
||||||
@ -501,70 +501,70 @@ void TestMerge::testDeletionConflictTemplate(int mergeMode,
|
|||||||
QScopedPointer<Database> dbSource(
|
QScopedPointer<Database> dbSource(
|
||||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneIncludeHistory, Group::CloneIncludeEntries));
|
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneIncludeHistory, Group::CloneIncludeEntries));
|
||||||
|
|
||||||
QPointer<Entry> sourceEntryDeletedInSourceBeforeChangedInTarget =
|
auto sourceEntryDeletedInSourceBeforeChangedInTarget =
|
||||||
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]);
|
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]);
|
||||||
QPointer<Entry> targetEntryDeletedInSourceBeforeChangedInTarget =
|
auto targetEntryDeletedInSourceBeforeChangedInTarget =
|
||||||
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]);
|
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]);
|
||||||
|
|
||||||
QPointer<Entry> sourceEntryDeletedInSourceAfterChangedInTarget =
|
auto sourceEntryDeletedInSourceAfterChangedInTarget =
|
||||||
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceAfterChangedInTarget"]);
|
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceAfterChangedInTarget"]);
|
||||||
QPointer<Entry> targetEntryDeletedInSourceAfterChangedInTarget =
|
auto targetEntryDeletedInSourceAfterChangedInTarget =
|
||||||
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceAfterChangedInTarget"]);
|
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceAfterChangedInTarget"]);
|
||||||
|
|
||||||
QPointer<Entry> sourceEntryDeletedInTargetBeforeChangedInSource =
|
auto sourceEntryDeletedInTargetBeforeChangedInSource =
|
||||||
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetBeforeChangedInSource"]);
|
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetBeforeChangedInSource"]);
|
||||||
QPointer<Entry> targetEntryDeletedInTargetBeforeChangedInSource =
|
auto targetEntryDeletedInTargetBeforeChangedInSource =
|
||||||
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetBeforeChangedInSource"]);
|
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetBeforeChangedInSource"]);
|
||||||
|
|
||||||
QPointer<Entry> sourceEntryDeletedInTargetAfterChangedInSource =
|
auto sourceEntryDeletedInTargetAfterChangedInSource =
|
||||||
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetAfterChangedInSource"]);
|
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetAfterChangedInSource"]);
|
||||||
QPointer<Entry> targetEntryDeletedInTargetAfterChangedInSource =
|
auto targetEntryDeletedInTargetAfterChangedInSource =
|
||||||
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetAfterChangedInSource"]);
|
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetAfterChangedInSource"]);
|
||||||
|
|
||||||
QPointer<Group> sourceGroupDeletedInSourceBeforeEntryUpdatedInTarget =
|
auto sourceGroupDeletedInSourceBeforeEntryUpdatedInTarget =
|
||||||
dbSource->rootGroup()->findGroupByUuid(identifiers["GroupDeletedInSourceBeforeEntryUpdatedInTarget"]);
|
dbSource->rootGroup()->findGroupByUuid(identifiers["GroupDeletedInSourceBeforeEntryUpdatedInTarget"]);
|
||||||
QPointer<Entry> targetEntryDeletedInSourceBeforeEntryUpdatedInTarget =
|
auto targetEntryDeletedInSourceBeforeEntryUpdatedInTarget =
|
||||||
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceBeforeEntryUpdatedInTarget"]);
|
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceBeforeEntryUpdatedInTarget"]);
|
||||||
|
|
||||||
QPointer<Group> sourceGroupDeletedInSourceAfterEntryUpdatedInTarget =
|
auto sourceGroupDeletedInSourceAfterEntryUpdatedInTarget =
|
||||||
dbSource->rootGroup()->findGroupByUuid(identifiers["GroupDeletedInSourceAfterEntryUpdatedInTarget"]);
|
dbSource->rootGroup()->findGroupByUuid(identifiers["GroupDeletedInSourceAfterEntryUpdatedInTarget"]);
|
||||||
QPointer<Entry> targetEntryDeletedInSourceAfterEntryUpdatedInTarget =
|
auto targetEntryDeletedInSourceAfterEntryUpdatedInTarget =
|
||||||
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceAfterEntryUpdatedInTarget"]);
|
dbDestination->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInSourceAfterEntryUpdatedInTarget"]);
|
||||||
|
|
||||||
QPointer<Group> targetGroupDeletedInTargetBeforeEntryUpdatedInSource =
|
auto targetGroupDeletedInTargetBeforeEntryUpdatedInSource =
|
||||||
dbDestination->rootGroup()->findGroupByUuid(identifiers["GroupDeletedInTargetBeforeEntryUpdatedInSource"]);
|
dbDestination->rootGroup()->findGroupByUuid(identifiers["GroupDeletedInTargetBeforeEntryUpdatedInSource"]);
|
||||||
QPointer<Entry> sourceEntryDeletedInTargetBeforeEntryUpdatedInSource =
|
auto sourceEntryDeletedInTargetBeforeEntryUpdatedInSource =
|
||||||
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetBeforeEntryUpdatedInSource"]);
|
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetBeforeEntryUpdatedInSource"]);
|
||||||
|
|
||||||
QPointer<Group> targetGroupDeletedInTargetAfterEntryUpdatedInSource =
|
auto targetGroupDeletedInTargetAfterEntryUpdatedInSource =
|
||||||
dbDestination->rootGroup()->findGroupByUuid(identifiers["GroupDeletedInTargetAfterEntryUpdatedInSource"]);
|
dbDestination->rootGroup()->findGroupByUuid(identifiers["GroupDeletedInTargetAfterEntryUpdatedInSource"]);
|
||||||
QPointer<Entry> sourceEntryDeletedInTargetAfterEntryUpdatedInSoruce =
|
auto sourceEntryDeletedInTargetAfterEntryUpdatedInSoruce =
|
||||||
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetAfterEntryUpdatedInSource"]);
|
dbSource->rootGroup()->findEntryByUuid(identifiers["EntryDeletedInTargetAfterEntryUpdatedInSource"]);
|
||||||
|
|
||||||
// simulate some work in the dbs (manipulate the history)
|
// simulate some work in the dbs (manipulate the history)
|
||||||
m_clock->advanceMinute(1);
|
m_clock->advanceMinute(1);
|
||||||
|
|
||||||
delete sourceEntryDeletedInSourceBeforeChangedInTarget.data();
|
delete sourceEntryDeletedInSourceBeforeChangedInTarget;
|
||||||
changeEntry(targetEntryDeletedInSourceAfterChangedInTarget);
|
changeEntry(targetEntryDeletedInSourceAfterChangedInTarget);
|
||||||
delete targetEntryDeletedInTargetBeforeChangedInSource.data();
|
delete targetEntryDeletedInTargetBeforeChangedInSource;
|
||||||
changeEntry(sourceEntryDeletedInTargetAfterChangedInSource);
|
changeEntry(sourceEntryDeletedInTargetAfterChangedInSource);
|
||||||
|
|
||||||
delete sourceGroupDeletedInSourceBeforeEntryUpdatedInTarget.data();
|
delete sourceGroupDeletedInSourceBeforeEntryUpdatedInTarget;
|
||||||
changeEntry(targetEntryDeletedInSourceAfterEntryUpdatedInTarget);
|
changeEntry(targetEntryDeletedInSourceAfterEntryUpdatedInTarget);
|
||||||
delete targetGroupDeletedInTargetBeforeEntryUpdatedInSource.data();
|
delete targetGroupDeletedInTargetBeforeEntryUpdatedInSource;
|
||||||
changeEntry(sourceEntryDeletedInTargetAfterEntryUpdatedInSoruce);
|
changeEntry(sourceEntryDeletedInTargetAfterEntryUpdatedInSoruce);
|
||||||
|
|
||||||
m_clock->advanceMinute(1);
|
m_clock->advanceMinute(1);
|
||||||
|
|
||||||
changeEntry(targetEntryDeletedInSourceBeforeChangedInTarget);
|
changeEntry(targetEntryDeletedInSourceBeforeChangedInTarget);
|
||||||
delete sourceEntryDeletedInSourceAfterChangedInTarget.data();
|
delete sourceEntryDeletedInSourceAfterChangedInTarget;
|
||||||
changeEntry(sourceEntryDeletedInTargetBeforeChangedInSource);
|
changeEntry(sourceEntryDeletedInTargetBeforeChangedInSource);
|
||||||
delete targetEntryDeletedInTargetAfterChangedInSource.data();
|
delete targetEntryDeletedInTargetAfterChangedInSource;
|
||||||
|
|
||||||
changeEntry(targetEntryDeletedInSourceBeforeEntryUpdatedInTarget);
|
changeEntry(targetEntryDeletedInSourceBeforeEntryUpdatedInTarget);
|
||||||
delete sourceGroupDeletedInSourceAfterEntryUpdatedInTarget.data();
|
delete sourceGroupDeletedInSourceAfterEntryUpdatedInTarget;
|
||||||
changeEntry(sourceEntryDeletedInTargetBeforeEntryUpdatedInSource);
|
changeEntry(sourceEntryDeletedInTargetBeforeEntryUpdatedInSource);
|
||||||
delete targetGroupDeletedInTargetAfterEntryUpdatedInSource.data();
|
delete targetGroupDeletedInTargetAfterEntryUpdatedInSource;
|
||||||
m_clock->advanceMinute(1);
|
m_clock->advanceMinute(1);
|
||||||
|
|
||||||
dbDestination->rootGroup()->setMergeMode(static_cast<Group::MergeMode>(mergeMode));
|
dbDestination->rootGroup()->setMergeMode(static_cast<Group::MergeMode>(mergeMode));
|
||||||
@ -577,7 +577,7 @@ void TestMerge::testDeletionConflictTemplate(int mergeMode,
|
|||||||
|
|
||||||
void TestMerge::assertDeletionNewerOnly(Database* db, const QMap<QString, QUuid>& identifiers)
|
void TestMerge::assertDeletionNewerOnly(Database* db, const QMap<QString, QUuid>& identifiers)
|
||||||
{
|
{
|
||||||
QPointer<Group> mergedRootGroup = db->rootGroup();
|
auto mergedRootGroup = db->rootGroup();
|
||||||
// newer change in target prevents deletion
|
// newer change in target prevents deletion
|
||||||
QVERIFY(mergedRootGroup->findEntryByUuid(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]));
|
QVERIFY(mergedRootGroup->findEntryByUuid(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]));
|
||||||
QVERIFY(!db->containsDeletedObject(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]));
|
QVERIFY(!db->containsDeletedObject(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]));
|
||||||
@ -614,7 +614,7 @@ void TestMerge::assertDeletionNewerOnly(Database* db, const QMap<QString, QUuid>
|
|||||||
|
|
||||||
void TestMerge::assertDeletionLocalOnly(Database* db, const QMap<QString, QUuid>& identifiers)
|
void TestMerge::assertDeletionLocalOnly(Database* db, const QMap<QString, QUuid>& identifiers)
|
||||||
{
|
{
|
||||||
QPointer<Group> mergedRootGroup = db->rootGroup();
|
auto mergedRootGroup = db->rootGroup();
|
||||||
|
|
||||||
QVERIFY(mergedRootGroup->findEntryByUuid(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]));
|
QVERIFY(mergedRootGroup->findEntryByUuid(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]));
|
||||||
QVERIFY(!db->containsDeletedObject(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]));
|
QVERIFY(!db->containsDeletedObject(identifiers["EntryDeletedInSourceBeforeChangedInTarget"]));
|
||||||
@ -650,8 +650,9 @@ void TestMerge::assertDeletionLocalOnly(Database* db, const QMap<QString, QUuid>
|
|||||||
QVERIFY(db->containsDeletedObject(identifiers["EntryDeletedInTargetAfterEntryUpdatedInSource"]));
|
QVERIFY(db->containsDeletedObject(identifiers["EntryDeletedInTargetAfterEntryUpdatedInSource"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestMerge::assertUpdateMergedEntry1(Entry* mergedEntry1, const QMap<const char*, QDateTime>& timestamps)
|
void TestMerge::assertUpdateMergedEntry1(Entry* mergedEntry1, const QMap<QString, QDateTime>& timestamps)
|
||||||
{
|
{
|
||||||
|
auto initial = timestamps.keys();
|
||||||
QCOMPARE(mergedEntry1->historyItems().count(), 4);
|
QCOMPARE(mergedEntry1->historyItems().count(), 4);
|
||||||
QCOMPARE(mergedEntry1->historyItems().at(0)->notes(), QString(""));
|
QCOMPARE(mergedEntry1->historyItems().at(0)->notes(), QString(""));
|
||||||
QCOMPARE(mergedEntry1->historyItems().at(0)->timeInfo().lastModificationTime(), timestamps["initialTime"]);
|
QCOMPARE(mergedEntry1->historyItems().at(0)->timeInfo().lastModificationTime(), timestamps["initialTime"]);
|
||||||
@ -668,7 +669,7 @@ void TestMerge::assertUpdateMergedEntry1(Entry* mergedEntry1, const QMap<const c
|
|||||||
QCOMPARE(mergedEntry1->timeInfo().lastModificationTime(), timestamps["newestDivergingHistoryTime"]);
|
QCOMPARE(mergedEntry1->timeInfo().lastModificationTime(), timestamps["newestDivergingHistoryTime"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestMerge::assertUpdateReappliedEntry2(Entry* mergedEntry2, const QMap<const char*, QDateTime>& timestamps)
|
void TestMerge::assertUpdateReappliedEntry2(Entry* mergedEntry2, const QMap<QString, QDateTime>& timestamps)
|
||||||
{
|
{
|
||||||
QCOMPARE(mergedEntry2->historyItems().count(), 5);
|
QCOMPARE(mergedEntry2->historyItems().count(), 5);
|
||||||
QCOMPARE(mergedEntry2->historyItems().at(0)->notes(), QString(""));
|
QCOMPARE(mergedEntry2->historyItems().at(0)->notes(), QString(""));
|
||||||
@ -689,7 +690,7 @@ void TestMerge::assertUpdateReappliedEntry2(Entry* mergedEntry2, const QMap<cons
|
|||||||
QCOMPARE(mergedEntry2->timeInfo().lastModificationTime(), timestamps["mergeTime"]);
|
QCOMPARE(mergedEntry2->timeInfo().lastModificationTime(), timestamps["mergeTime"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestMerge::assertUpdateReappliedEntry1(Entry* mergedEntry1, const QMap<const char*, QDateTime>& timestamps)
|
void TestMerge::assertUpdateReappliedEntry1(Entry* mergedEntry1, const QMap<QString, QDateTime>& timestamps)
|
||||||
{
|
{
|
||||||
QCOMPARE(mergedEntry1->historyItems().count(), 5);
|
QCOMPARE(mergedEntry1->historyItems().count(), 5);
|
||||||
QCOMPARE(mergedEntry1->historyItems().at(0)->notes(), QString(""));
|
QCOMPARE(mergedEntry1->historyItems().at(0)->notes(), QString(""));
|
||||||
@ -710,7 +711,7 @@ void TestMerge::assertUpdateReappliedEntry1(Entry* mergedEntry1, const QMap<cons
|
|||||||
QCOMPARE(mergedEntry1->timeInfo().lastModificationTime(), timestamps["mergeTime"]);
|
QCOMPARE(mergedEntry1->timeInfo().lastModificationTime(), timestamps["mergeTime"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestMerge::assertUpdateMergedEntry2(Entry* mergedEntry2, const QMap<const char*, QDateTime>& timestamps)
|
void TestMerge::assertUpdateMergedEntry2(Entry* mergedEntry2, const QMap<QString, QDateTime>& timestamps)
|
||||||
{
|
{
|
||||||
QCOMPARE(mergedEntry2->historyItems().count(), 4);
|
QCOMPARE(mergedEntry2->historyItems().count(), 4);
|
||||||
QCOMPARE(mergedEntry2->historyItems().at(0)->notes(), QString(""));
|
QCOMPARE(mergedEntry2->historyItems().at(0)->notes(), QString(""));
|
||||||
@ -758,9 +759,9 @@ void TestMerge::testDeletionConflictEntry_Duplicate()
|
|||||||
*/
|
*/
|
||||||
void TestMerge::testResolveConflictEntry_Synchronize()
|
void TestMerge::testResolveConflictEntry_Synchronize()
|
||||||
{
|
{
|
||||||
testResolveConflictTemplate(Group::Synchronize, [](Database* db, const QMap<const char*, QDateTime>& timestamps) {
|
testResolveConflictTemplate(Group::Synchronize, [](Database* db, const QMap<QString, QDateTime>& timestamps) {
|
||||||
QPointer<Group> mergedRootGroup = db->rootGroup();
|
auto mergedRootGroup = db->rootGroup();
|
||||||
QPointer<Group> mergedGroup1 = mergedRootGroup->children().at(0);
|
auto mergedGroup1 = mergedRootGroup->children().at(0);
|
||||||
TestMerge::assertUpdateMergedEntry1(mergedGroup1->entries().at(0), timestamps);
|
TestMerge::assertUpdateMergedEntry1(mergedGroup1->entries().at(0), timestamps);
|
||||||
TestMerge::assertUpdateMergedEntry2(mergedGroup1->entries().at(1), timestamps);
|
TestMerge::assertUpdateMergedEntry2(mergedGroup1->entries().at(1), timestamps);
|
||||||
});
|
});
|
||||||
@ -771,9 +772,9 @@ void TestMerge::testResolveConflictEntry_Synchronize()
|
|||||||
*/
|
*/
|
||||||
void TestMerge::testResolveConflictEntry_KeepLocal()
|
void TestMerge::testResolveConflictEntry_KeepLocal()
|
||||||
{
|
{
|
||||||
testResolveConflictTemplate(Group::KeepLocal, [](Database* db, const QMap<const char*, QDateTime>& timestamps) {
|
testResolveConflictTemplate(Group::KeepLocal, [](Database* db, const QMap<QString, QDateTime>& timestamps) {
|
||||||
QPointer<Group> mergedRootGroup = db->rootGroup();
|
auto mergedRootGroup = db->rootGroup();
|
||||||
QPointer<Group> mergedGroup1 = mergedRootGroup->children().at(0);
|
auto mergedGroup1 = mergedRootGroup->children().at(0);
|
||||||
TestMerge::assertUpdateMergedEntry1(mergedGroup1->entries().at(0), timestamps);
|
TestMerge::assertUpdateMergedEntry1(mergedGroup1->entries().at(0), timestamps);
|
||||||
TestMerge::assertUpdateReappliedEntry2(mergedGroup1->entries().at(1), timestamps);
|
TestMerge::assertUpdateReappliedEntry2(mergedGroup1->entries().at(1), timestamps);
|
||||||
});
|
});
|
||||||
@ -781,9 +782,9 @@ void TestMerge::testResolveConflictEntry_KeepLocal()
|
|||||||
|
|
||||||
void TestMerge::testResolveConflictEntry_KeepRemote()
|
void TestMerge::testResolveConflictEntry_KeepRemote()
|
||||||
{
|
{
|
||||||
testResolveConflictTemplate(Group::KeepRemote, [](Database* db, const QMap<const char*, QDateTime>& timestamps) {
|
testResolveConflictTemplate(Group::KeepRemote, [](Database* db, const QMap<QString, QDateTime>& timestamps) {
|
||||||
QPointer<Group> mergedRootGroup = db->rootGroup();
|
auto mergedRootGroup = db->rootGroup();
|
||||||
QPointer<Group> mergedGroup1 = mergedRootGroup->children().at(0);
|
auto mergedGroup1 = mergedRootGroup->children().at(0);
|
||||||
TestMerge::assertUpdateReappliedEntry1(mergedGroup1->entries().at(0), timestamps);
|
TestMerge::assertUpdateReappliedEntry1(mergedGroup1->entries().at(0), timestamps);
|
||||||
TestMerge::assertUpdateMergedEntry2(mergedGroup1->entries().at(1), timestamps);
|
TestMerge::assertUpdateMergedEntry2(mergedGroup1->entries().at(1), timestamps);
|
||||||
});
|
});
|
||||||
@ -791,9 +792,9 @@ void TestMerge::testResolveConflictEntry_KeepRemote()
|
|||||||
|
|
||||||
void TestMerge::testResolveConflictEntry_KeepNewer()
|
void TestMerge::testResolveConflictEntry_KeepNewer()
|
||||||
{
|
{
|
||||||
testResolveConflictTemplate(Group::KeepNewer, [](Database* db, const QMap<const char*, QDateTime>& timestamps) {
|
testResolveConflictTemplate(Group::KeepNewer, [](Database* db, const QMap<QString, QDateTime>& timestamps) {
|
||||||
QPointer<Group> mergedRootGroup = db->rootGroup();
|
auto mergedRootGroup = db->rootGroup();
|
||||||
QPointer<Group> mergedGroup1 = mergedRootGroup->children().at(0);
|
auto mergedGroup1 = mergedRootGroup->children().at(0);
|
||||||
TestMerge::assertUpdateMergedEntry1(mergedGroup1->entries().at(0), timestamps);
|
TestMerge::assertUpdateMergedEntry1(mergedGroup1->entries().at(0), timestamps);
|
||||||
TestMerge::assertUpdateMergedEntry2(mergedGroup1->entries().at(1), timestamps);
|
TestMerge::assertUpdateMergedEntry2(mergedGroup1->entries().at(1), timestamps);
|
||||||
});
|
});
|
||||||
@ -809,10 +810,10 @@ void TestMerge::testMoveEntry()
|
|||||||
QScopedPointer<Database> dbSource(
|
QScopedPointer<Database> dbSource(
|
||||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||||
|
|
||||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
auto entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceInitial != nullptr);
|
QVERIFY(entrySourceInitial != nullptr);
|
||||||
|
|
||||||
QPointer<Group> groupSourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
auto groupSourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
||||||
QVERIFY(groupSourceInitial != nullptr);
|
QVERIFY(groupSourceInitial != nullptr);
|
||||||
|
|
||||||
// Make sure the two changes have a different timestamp.
|
// Make sure the two changes have a different timestamp.
|
||||||
@ -826,7 +827,7 @@ void TestMerge::testMoveEntry()
|
|||||||
Merger merger(dbSource.data(), dbDestination.data());
|
Merger merger(dbSource.data(), dbDestination.data());
|
||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2"));
|
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2"));
|
||||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||||
@ -843,10 +844,10 @@ void TestMerge::testMoveEntryPreserveChanges()
|
|||||||
QScopedPointer<Database> dbSource(
|
QScopedPointer<Database> dbSource(
|
||||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||||
|
|
||||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
auto entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceInitial != nullptr);
|
QVERIFY(entrySourceInitial != nullptr);
|
||||||
|
|
||||||
QPointer<Group> group2Source = dbSource->rootGroup()->findChildByName("group2");
|
auto group2Source = dbSource->rootGroup()->findChildByName("group2");
|
||||||
QVERIFY(group2Source != nullptr);
|
QVERIFY(group2Source != nullptr);
|
||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
@ -854,7 +855,7 @@ void TestMerge::testMoveEntryPreserveChanges()
|
|||||||
entrySourceInitial->setGroup(group2Source);
|
entrySourceInitial->setGroup(group2Source);
|
||||||
QCOMPARE(entrySourceInitial->group()->name(), QString("group2"));
|
QCOMPARE(entrySourceInitial->group()->name(), QString("group2"));
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entryDestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationInitial != nullptr);
|
QVERIFY(entryDestinationInitial != nullptr);
|
||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
@ -868,7 +869,7 @@ void TestMerge::testMoveEntryPreserveChanges()
|
|||||||
Merger merger(dbSource.data(), dbDestination.data());
|
Merger merger(dbSource.data(), dbDestination.data());
|
||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2"));
|
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2"));
|
||||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||||
@ -893,7 +894,7 @@ void TestMerge::testCreateNewGroups()
|
|||||||
Merger merger(dbSource.data(), dbDestination.data());
|
Merger merger(dbSource.data(), dbDestination.data());
|
||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
QPointer<Group> groupDestinationMerged = dbDestination->rootGroup()->findChildByName("group3");
|
auto groupDestinationMerged = dbDestination->rootGroup()->findChildByName("group3");
|
||||||
QVERIFY(groupDestinationMerged != nullptr);
|
QVERIFY(groupDestinationMerged != nullptr);
|
||||||
QCOMPARE(groupDestinationMerged->name(), QString("group3"));
|
QCOMPARE(groupDestinationMerged->name(), QString("group3"));
|
||||||
}
|
}
|
||||||
@ -911,7 +912,7 @@ void TestMerge::testMoveEntryIntoNewGroup()
|
|||||||
groupSourceCreated->setUuid(QUuid::createUuid());
|
groupSourceCreated->setUuid(QUuid::createUuid());
|
||||||
groupSourceCreated->setParent(dbSource->rootGroup());
|
groupSourceCreated->setParent(dbSource->rootGroup());
|
||||||
|
|
||||||
QPointer<Entry> entrySourceMoved = dbSource->rootGroup()->findEntryByPath("entry1");
|
auto entrySourceMoved = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
entrySourceMoved->setGroup(groupSourceCreated);
|
entrySourceMoved->setGroup(groupSourceCreated);
|
||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
@ -921,12 +922,12 @@ void TestMerge::testMoveEntryIntoNewGroup()
|
|||||||
|
|
||||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||||
|
|
||||||
QPointer<Group> groupDestinationMerged = dbDestination->rootGroup()->findChildByName("group3");
|
auto groupDestinationMerged = dbDestination->rootGroup()->findChildByName("group3");
|
||||||
QVERIFY(groupDestinationMerged != nullptr);
|
QVERIFY(groupDestinationMerged != nullptr);
|
||||||
QCOMPARE(groupDestinationMerged->name(), QString("group3"));
|
QCOMPARE(groupDestinationMerged->name(), QString("group3"));
|
||||||
QCOMPARE(groupDestinationMerged->entries().size(), 1);
|
QCOMPARE(groupDestinationMerged->entries().size(), 1);
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group3"));
|
QCOMPARE(entryDestinationMerged->group()->name(), QString("group3"));
|
||||||
}
|
}
|
||||||
@ -948,7 +949,7 @@ void TestMerge::testUpdateEntryDifferentLocation()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMoved = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entryDestinationMoved = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMoved != nullptr);
|
QVERIFY(entryDestinationMoved != nullptr);
|
||||||
entryDestinationMoved->setGroup(groupDestinationCreated);
|
entryDestinationMoved->setGroup(groupDestinationCreated);
|
||||||
QUuid uuidBeforeSyncing = entryDestinationMoved->uuid();
|
QUuid uuidBeforeSyncing = entryDestinationMoved->uuid();
|
||||||
@ -957,7 +958,7 @@ void TestMerge::testUpdateEntryDifferentLocation()
|
|||||||
// Change the entry in the source db.
|
// Change the entry in the source db.
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entrySourceMoved = dbSource->rootGroup()->findEntryByPath("entry1");
|
auto entrySourceMoved = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceMoved != nullptr);
|
QVERIFY(entrySourceMoved != nullptr);
|
||||||
entrySourceMoved->beginUpdate();
|
entrySourceMoved->beginUpdate();
|
||||||
entrySourceMoved->setUsername("username");
|
entrySourceMoved->setUsername("username");
|
||||||
@ -973,7 +974,7 @@ void TestMerge::testUpdateEntryDifferentLocation()
|
|||||||
|
|
||||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QVERIFY(entryDestinationMerged->group() != nullptr);
|
QVERIFY(entryDestinationMerged->group() != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->username(), QString("username"));
|
QCOMPARE(entryDestinationMerged->username(), QString("username"));
|
||||||
@ -994,14 +995,14 @@ void TestMerge::testUpdateGroup()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Group> groupSourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
auto groupSourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
||||||
groupSourceInitial->setName("group2 renamed");
|
groupSourceInitial->setName("group2 renamed");
|
||||||
groupSourceInitial->setNotes("updated notes");
|
groupSourceInitial->setNotes("updated notes");
|
||||||
QUuid customIconId = QUuid::createUuid();
|
QUuid customIconId = QUuid::createUuid();
|
||||||
dbSource->metadata()->addCustomIcon(customIconId, QString("custom icon").toLocal8Bit());
|
dbSource->metadata()->addCustomIcon(customIconId, QString("custom icon").toLocal8Bit());
|
||||||
groupSourceInitial->setIcon(customIconId);
|
groupSourceInitial->setIcon(customIconId);
|
||||||
|
|
||||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
auto entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceInitial != nullptr);
|
QVERIFY(entrySourceInitial != nullptr);
|
||||||
entrySourceInitial->setGroup(groupSourceInitial);
|
entrySourceInitial->setGroup(groupSourceInitial);
|
||||||
entrySourceInitial->setTitle("entry1 renamed");
|
entrySourceInitial->setTitle("entry1 renamed");
|
||||||
@ -1014,13 +1015,13 @@ void TestMerge::testUpdateGroup()
|
|||||||
|
|
||||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1 renamed");
|
auto entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1 renamed");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QVERIFY(entryDestinationMerged->group() != nullptr);
|
QVERIFY(entryDestinationMerged->group() != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2 renamed"));
|
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2 renamed"));
|
||||||
QCOMPARE(uuidBeforeSyncing, entryDestinationMerged->uuid());
|
QCOMPARE(uuidBeforeSyncing, entryDestinationMerged->uuid());
|
||||||
|
|
||||||
QPointer<Group> groupMerged = dbDestination->rootGroup()->findChildByName("group2 renamed");
|
auto groupMerged = dbDestination->rootGroup()->findChildByName("group2 renamed");
|
||||||
QCOMPARE(groupMerged->notes(), QString("updated notes"));
|
QCOMPARE(groupMerged->notes(), QString("updated notes"));
|
||||||
QCOMPARE(groupMerged->iconUuid(), customIconId);
|
QCOMPARE(groupMerged->iconUuid(), customIconId);
|
||||||
}
|
}
|
||||||
@ -1038,14 +1039,14 @@ void TestMerge::testUpdateGroupLocation()
|
|||||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
QPointer<Group> group3SourceInitial = dbSource->rootGroup()->findGroupByUuid(group3Uuid);
|
auto group3SourceInitial = dbSource->rootGroup()->findGroupByUuid(group3Uuid);
|
||||||
QVERIFY(group3DestinationCreated != nullptr);
|
QVERIFY(group3DestinationCreated != nullptr);
|
||||||
|
|
||||||
QDateTime initialLocationChanged = group3SourceInitial->timeInfo().locationChanged();
|
QDateTime initialLocationChanged = group3SourceInitial->timeInfo().locationChanged();
|
||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Group> group3SourceMoved = dbSource->rootGroup()->findGroupByUuid(group3Uuid);
|
auto group3SourceMoved = dbSource->rootGroup()->findGroupByUuid(group3Uuid);
|
||||||
QVERIFY(group3SourceMoved != nullptr);
|
QVERIFY(group3SourceMoved != nullptr);
|
||||||
group3SourceMoved->setParent(dbSource->rootGroup()->findChildByName("group2"));
|
group3SourceMoved->setParent(dbSource->rootGroup()->findChildByName("group2"));
|
||||||
|
|
||||||
@ -1057,7 +1058,7 @@ void TestMerge::testUpdateGroupLocation()
|
|||||||
Merger merger1(dbSource.data(), dbDestination.data());
|
Merger merger1(dbSource.data(), dbDestination.data());
|
||||||
merger1.merge();
|
merger1.merge();
|
||||||
|
|
||||||
QPointer<Group> group3DestinationMerged1 = dbDestination->rootGroup()->findGroupByUuid(group3Uuid);
|
auto group3DestinationMerged1 = dbDestination->rootGroup()->findGroupByUuid(group3Uuid);
|
||||||
QVERIFY(group3DestinationMerged1 != nullptr);
|
QVERIFY(group3DestinationMerged1 != nullptr);
|
||||||
QCOMPARE(group3DestinationMerged1->parent(), dbDestination->rootGroup()->findChildByName("group2"));
|
QCOMPARE(group3DestinationMerged1->parent(), dbDestination->rootGroup()->findChildByName("group2"));
|
||||||
QCOMPARE(group3DestinationMerged1->timeInfo().locationChanged(), movedLocaltionChanged);
|
QCOMPARE(group3DestinationMerged1->timeInfo().locationChanged(), movedLocaltionChanged);
|
||||||
@ -1067,7 +1068,7 @@ void TestMerge::testUpdateGroupLocation()
|
|||||||
Merger merger2(dbSource.data(), dbDestination.data());
|
Merger merger2(dbSource.data(), dbDestination.data());
|
||||||
merger2.merge();
|
merger2.merge();
|
||||||
|
|
||||||
QPointer<Group> group3DestinationMerged2 = dbDestination->rootGroup()->findGroupByUuid(group3Uuid);
|
auto group3DestinationMerged2 = dbDestination->rootGroup()->findGroupByUuid(group3Uuid);
|
||||||
QVERIFY(group3DestinationMerged2 != nullptr);
|
QVERIFY(group3DestinationMerged2 != nullptr);
|
||||||
QCOMPARE(group3DestinationMerged2->parent(), dbDestination->rootGroup()->findChildByName("group2"));
|
QCOMPARE(group3DestinationMerged2->parent(), dbDestination->rootGroup()->findChildByName("group2"));
|
||||||
QCOMPARE(group3DestinationMerged1->timeInfo().locationChanged(), movedLocaltionChanged);
|
QCOMPARE(group3DestinationMerged1->timeInfo().locationChanged(), movedLocaltionChanged);
|
||||||
@ -1244,7 +1245,7 @@ void TestMerge::testDeletedEntry()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
auto entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1SourceInitial != nullptr);
|
QVERIFY(entry1SourceInitial != nullptr);
|
||||||
QUuid entry1Uuid = entry1SourceInitial->uuid();
|
QUuid entry1Uuid = entry1SourceInitial->uuid();
|
||||||
delete entry1SourceInitial;
|
delete entry1SourceInitial;
|
||||||
@ -1252,7 +1253,7 @@ void TestMerge::testDeletedEntry()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entry2DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry2");
|
auto entry2DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2DestinationInitial != nullptr);
|
QVERIFY(entry2DestinationInitial != nullptr);
|
||||||
QUuid entry2Uuid = entry2DestinationInitial->uuid();
|
QUuid entry2Uuid = entry2DestinationInitial->uuid();
|
||||||
delete entry2DestinationInitial;
|
delete entry2DestinationInitial;
|
||||||
@ -1263,10 +1264,10 @@ void TestMerge::testDeletedEntry()
|
|||||||
Merger merger(dbSource.data(), dbDestination.data());
|
Merger merger(dbSource.data(), dbDestination.data());
|
||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1DestinationMerged);
|
QVERIFY(entry1DestinationMerged);
|
||||||
QVERIFY(!dbDestination->containsDeletedObject(entry1Uuid));
|
QVERIFY(!dbDestination->containsDeletedObject(entry1Uuid));
|
||||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
auto entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2DestinationMerged);
|
QVERIFY(entry2DestinationMerged);
|
||||||
// Uuid in db and deletedObjects is intended according to KeePass #1752
|
// Uuid in db and deletedObjects is intended according to KeePass #1752
|
||||||
QVERIFY(dbDestination->containsDeletedObject(entry2Uuid));
|
QVERIFY(dbDestination->containsDeletedObject(entry2Uuid));
|
||||||
@ -1282,7 +1283,7 @@ void TestMerge::testDeletedGroup()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Group> group2DestinationInitial = dbDestination->rootGroup()->findChildByName("group2");
|
auto group2DestinationInitial = dbDestination->rootGroup()->findChildByName("group2");
|
||||||
QVERIFY(group2DestinationInitial != nullptr);
|
QVERIFY(group2DestinationInitial != nullptr);
|
||||||
auto entry3DestinationCreated = new Entry();
|
auto entry3DestinationCreated = new Entry();
|
||||||
entry3DestinationCreated->beginUpdate();
|
entry3DestinationCreated->beginUpdate();
|
||||||
@ -1293,11 +1294,11 @@ void TestMerge::testDeletedGroup()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Group> group1SourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
auto group1SourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(group1SourceInitial != nullptr);
|
QVERIFY(group1SourceInitial != nullptr);
|
||||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
auto entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1SourceInitial != nullptr);
|
QVERIFY(entry1SourceInitial != nullptr);
|
||||||
QPointer<Entry> entry2SourceInitial = dbSource->rootGroup()->findEntryByPath("entry2");
|
auto entry2SourceInitial = dbSource->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2SourceInitial != nullptr);
|
QVERIFY(entry2SourceInitial != nullptr);
|
||||||
QUuid group1Uuid = group1SourceInitial->uuid();
|
QUuid group1Uuid = group1SourceInitial->uuid();
|
||||||
QUuid entry1Uuid = entry1SourceInitial->uuid();
|
QUuid entry1Uuid = entry1SourceInitial->uuid();
|
||||||
@ -1309,7 +1310,7 @@ void TestMerge::testDeletedGroup()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Group> group2SourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
auto group2SourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
||||||
QVERIFY(group2SourceInitial != nullptr);
|
QVERIFY(group2SourceInitial != nullptr);
|
||||||
QUuid group2Uuid = group2SourceInitial->uuid();
|
QUuid group2Uuid = group2SourceInitial->uuid();
|
||||||
delete group2SourceInitial;
|
delete group2SourceInitial;
|
||||||
@ -1325,15 +1326,15 @@ void TestMerge::testDeletedGroup()
|
|||||||
QVERIFY(!dbDestination->containsDeletedObject(entry2Uuid));
|
QVERIFY(!dbDestination->containsDeletedObject(entry2Uuid));
|
||||||
QVERIFY(!dbDestination->containsDeletedObject(group2Uuid));
|
QVERIFY(!dbDestination->containsDeletedObject(group2Uuid));
|
||||||
|
|
||||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1DestinationMerged);
|
QVERIFY(entry1DestinationMerged);
|
||||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
auto entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2DestinationMerged);
|
QVERIFY(entry2DestinationMerged);
|
||||||
QPointer<Entry> entry3DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry3");
|
auto entry3DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry3");
|
||||||
QVERIFY(entry3DestinationMerged);
|
QVERIFY(entry3DestinationMerged);
|
||||||
QPointer<Group> group1DestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
auto group1DestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(group1DestinationMerged);
|
QVERIFY(group1DestinationMerged);
|
||||||
QPointer<Group> group2DestinationMerged = dbDestination->rootGroup()->findChildByName("group2");
|
auto group2DestinationMerged = dbDestination->rootGroup()->findChildByName("group2");
|
||||||
QVERIFY(group2DestinationMerged);
|
QVERIFY(group2DestinationMerged);
|
||||||
|
|
||||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 3);
|
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 3);
|
||||||
@ -1347,7 +1348,7 @@ void TestMerge::testDeletedRevertedEntry()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entry1DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entry1DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1DestinationInitial != nullptr);
|
QVERIFY(entry1DestinationInitial != nullptr);
|
||||||
QUuid entry1Uuid = entry1DestinationInitial->uuid();
|
QUuid entry1Uuid = entry1DestinationInitial->uuid();
|
||||||
delete entry1DestinationInitial;
|
delete entry1DestinationInitial;
|
||||||
@ -1355,7 +1356,7 @@ void TestMerge::testDeletedRevertedEntry()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entry2SourceInitial = dbSource->rootGroup()->findEntryByPath("entry2");
|
auto entry2SourceInitial = dbSource->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2SourceInitial != nullptr);
|
QVERIFY(entry2SourceInitial != nullptr);
|
||||||
QUuid entry2Uuid = entry2SourceInitial->uuid();
|
QUuid entry2Uuid = entry2SourceInitial->uuid();
|
||||||
delete entry2SourceInitial;
|
delete entry2SourceInitial;
|
||||||
@ -1363,11 +1364,11 @@ void TestMerge::testDeletedRevertedEntry()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
auto entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1SourceInitial != nullptr);
|
QVERIFY(entry1SourceInitial != nullptr);
|
||||||
entry1SourceInitial->setNotes("Updated");
|
entry1SourceInitial->setNotes("Updated");
|
||||||
|
|
||||||
QPointer<Entry> entry2DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry2");
|
auto entry2DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2DestinationInitial != nullptr);
|
QVERIFY(entry2DestinationInitial != nullptr);
|
||||||
entry2DestinationInitial->setNotes("Updated");
|
entry2DestinationInitial->setNotes("Updated");
|
||||||
|
|
||||||
@ -1378,10 +1379,10 @@ void TestMerge::testDeletedRevertedEntry()
|
|||||||
QVERIFY(dbDestination->containsDeletedObject(entry1Uuid));
|
QVERIFY(dbDestination->containsDeletedObject(entry1Uuid));
|
||||||
QVERIFY(!dbDestination->containsDeletedObject(entry2Uuid));
|
QVERIFY(!dbDestination->containsDeletedObject(entry2Uuid));
|
||||||
|
|
||||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
auto entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1DestinationMerged);
|
QVERIFY(entry1DestinationMerged);
|
||||||
QVERIFY(entry1DestinationMerged->notes() == "Updated");
|
QVERIFY(entry1DestinationMerged->notes() == "Updated");
|
||||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
auto entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2DestinationMerged);
|
QVERIFY(entry2DestinationMerged);
|
||||||
QVERIFY(entry2DestinationMerged->notes() == "Updated");
|
QVERIFY(entry2DestinationMerged->notes() == "Updated");
|
||||||
}
|
}
|
||||||
@ -1394,7 +1395,7 @@ void TestMerge::testDeletedRevertedGroup()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Group> group2SourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
auto group2SourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
||||||
QVERIFY(group2SourceInitial);
|
QVERIFY(group2SourceInitial);
|
||||||
QUuid group2Uuid = group2SourceInitial->uuid();
|
QUuid group2Uuid = group2SourceInitial->uuid();
|
||||||
delete group2SourceInitial;
|
delete group2SourceInitial;
|
||||||
@ -1402,7 +1403,7 @@ void TestMerge::testDeletedRevertedGroup()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Group> group1DestinationInitial = dbDestination->rootGroup()->findChildByName("group1");
|
auto group1DestinationInitial = dbDestination->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(group1DestinationInitial);
|
QVERIFY(group1DestinationInitial);
|
||||||
QUuid group1Uuid = group1DestinationInitial->uuid();
|
QUuid group1Uuid = group1DestinationInitial->uuid();
|
||||||
delete group1DestinationInitial;
|
delete group1DestinationInitial;
|
||||||
@ -1410,13 +1411,13 @@ void TestMerge::testDeletedRevertedGroup()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Group> group1SourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
auto group1SourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(group1SourceInitial);
|
QVERIFY(group1SourceInitial);
|
||||||
group1SourceInitial->setNotes("Updated");
|
group1SourceInitial->setNotes("Updated");
|
||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Group> group2DestinationInitial = dbDestination->rootGroup()->findChildByName("group2");
|
auto group2DestinationInitial = dbDestination->rootGroup()->findChildByName("group2");
|
||||||
QVERIFY(group2DestinationInitial);
|
QVERIFY(group2DestinationInitial);
|
||||||
group2DestinationInitial->setNotes("Updated");
|
group2DestinationInitial->setNotes("Updated");
|
||||||
|
|
||||||
@ -1429,10 +1430,10 @@ void TestMerge::testDeletedRevertedGroup()
|
|||||||
QVERIFY(dbDestination->containsDeletedObject(group1Uuid));
|
QVERIFY(dbDestination->containsDeletedObject(group1Uuid));
|
||||||
QVERIFY(!dbDestination->containsDeletedObject(group2Uuid));
|
QVERIFY(!dbDestination->containsDeletedObject(group2Uuid));
|
||||||
|
|
||||||
QPointer<Group> group1DestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
auto group1DestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(group1DestinationMerged);
|
QVERIFY(group1DestinationMerged);
|
||||||
QVERIFY(group1DestinationMerged->notes() == "Updated");
|
QVERIFY(group1DestinationMerged->notes() == "Updated");
|
||||||
QPointer<Group> group2DestinationMerged = dbDestination->rootGroup()->findChildByName("group2");
|
auto group2DestinationMerged = dbDestination->rootGroup()->findChildByName("group2");
|
||||||
QVERIFY(group2DestinationMerged);
|
QVERIFY(group2DestinationMerged);
|
||||||
QVERIFY(group2DestinationMerged->notes() == "Updated");
|
QVERIFY(group2DestinationMerged->notes() == "Updated");
|
||||||
}
|
}
|
||||||
@ -1449,7 +1450,7 @@ void TestMerge::testResolveGroupConflictOlder()
|
|||||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
QPointer<Group> groupSourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
auto groupSourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(groupSourceInitial != nullptr);
|
QVERIFY(groupSourceInitial != nullptr);
|
||||||
|
|
||||||
// Make sure the two changes have a different timestamp.
|
// Make sure the two changes have a different timestamp.
|
||||||
@ -1460,7 +1461,7 @@ void TestMerge::testResolveGroupConflictOlder()
|
|||||||
// Make sure the two changes have a different timestamp.
|
// Make sure the two changes have a different timestamp.
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Group> groupDestinationUpdated = dbDestination->rootGroup()->findChildByName("group1");
|
auto groupDestinationUpdated = dbDestination->rootGroup()->findChildByName("group1");
|
||||||
groupDestinationUpdated->setName("group1 updated in destination");
|
groupDestinationUpdated->setName("group1 updated in destination");
|
||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
@ -1469,7 +1470,7 @@ void TestMerge::testResolveGroupConflictOlder()
|
|||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
QPointer<Group> groupDestinationMerged =
|
auto groupDestinationMerged =
|
||||||
dbDestination->rootGroup()->findChildByName("group1 updated in destination");
|
dbDestination->rootGroup()->findChildByName("group1 updated in destination");
|
||||||
QVERIFY(groupDestinationMerged != nullptr);
|
QVERIFY(groupDestinationMerged != nullptr);
|
||||||
}
|
}
|
||||||
|
@ -66,15 +66,15 @@ private:
|
|||||||
Database* createTestDatabase();
|
Database* createTestDatabase();
|
||||||
Database* createTestDatabaseStructureClone(Database* source, int entryFlags, int groupFlags);
|
Database* createTestDatabaseStructureClone(Database* source, int entryFlags, int groupFlags);
|
||||||
void testResolveConflictTemplate(int mergeMode,
|
void testResolveConflictTemplate(int mergeMode,
|
||||||
std::function<void(Database*, const QMap<const char*, QDateTime>&)> verification);
|
std::function<void(Database*, const QMap<QString, QDateTime>&)> verification);
|
||||||
void testDeletionConflictTemplate(int mergeMode,
|
void testDeletionConflictTemplate(int mergeMode,
|
||||||
std::function<void(Database*, const QMap<QString, QUuid>&)> verification);
|
std::function<void(Database*, const QMap<QString, QUuid>&)> verification);
|
||||||
static void assertDeletionNewerOnly(Database* db, const QMap<QString, QUuid>& identifiers);
|
static void assertDeletionNewerOnly(Database* db, const QMap<QString, QUuid>& identifiers);
|
||||||
static void assertDeletionLocalOnly(Database* db, const QMap<QString, QUuid>& identifiers);
|
static void assertDeletionLocalOnly(Database* db, const QMap<QString, QUuid>& identifiers);
|
||||||
static void assertUpdateMergedEntry1(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
|
static void assertUpdateMergedEntry1(Entry* entry, const QMap<QString, QDateTime>& timestamps);
|
||||||
static void assertUpdateReappliedEntry2(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
|
static void assertUpdateReappliedEntry2(Entry* entry, const QMap<QString, QDateTime>& timestamps);
|
||||||
static void assertUpdateReappliedEntry1(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
|
static void assertUpdateReappliedEntry1(Entry* entry, const QMap<QString, QDateTime>& timestamps);
|
||||||
static void assertUpdateMergedEntry2(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
|
static void assertUpdateMergedEntry2(Entry* entry, const QMap<QString, QDateTime>& timestamps);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_TESTMERGE_H
|
#endif // KEEPASSX_TESTMERGE_H
|
||||||
|
@ -70,6 +70,10 @@ void TestGuiBrowser::initTestCase()
|
|||||||
config()->set(Config::GUI_AdvancedSettings, false);
|
config()->set(Config::GUI_AdvancedSettings, false);
|
||||||
// Disable the update check first time alert
|
// Disable the update check first time alert
|
||||||
config()->set(Config::UpdateCheckMessageShown, true);
|
config()->set(Config::UpdateCheckMessageShown, true);
|
||||||
|
// Disable quick unlock
|
||||||
|
config()->set(Config::Security_QuickUnlock, false);
|
||||||
|
// Disable showing expired entries on unlock
|
||||||
|
config()->set(Config::GUI_ShowExpiredEntriesOnDatabaseUnlock, false);
|
||||||
|
|
||||||
m_mainWindow.reset(new MainWindow());
|
m_mainWindow.reset(new MainWindow());
|
||||||
m_tabWidget = m_mainWindow->findChild<DatabaseTabWidget*>("tabWidget");
|
m_tabWidget = m_mainWindow->findChild<DatabaseTabWidget*>("tabWidget");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user